1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 12:56:49 +01:00

Garmin: fix regression in call handling

Add a fictitious action to the notification to enable reply/hangup/reject from the watch.
Also fixes the behavior on sms reply, which should also reject the incoming call.

Change the log level in case some of the canned messages types are left as default to info, as this is a supported scenario.
This commit is contained in:
Daniele Gobbetti 2024-05-03 09:30:38 +02:00
parent 179f8a3a9e
commit a5dbb7fea7
3 changed files with 22 additions and 10 deletions

View File

@ -84,6 +84,11 @@ public class NotificationsHandler implements MessageHandler {
callNotificationSpec.type = NotificationType.GENERIC_PHONE;
callNotificationSpec.body = StringUtils.isEmpty(callSpec.name) ? callSpec.number : callSpec.name;
// add an empty bogus action to toggle the hasActions boolean. The actions are hardcoded on the watch in case of incoming calls.
callNotificationSpec.attachedActions = new ArrayList<>();
callNotificationSpec.attachedActions.add(0, new NotificationSpec.Action());
return onNotification(callNotificationSpec);
} else {
if (callSpec.number != null) // this happens in debug screen
@ -180,6 +185,8 @@ public class NotificationsHandler implements MessageHandler {
final GBDeviceEventCallControl deviceEvtCallControl = new GBDeviceEventCallControl();
switch (message.getNotificationAction()) {
case REPLY_INCOMING_CALL:
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.REJECT;
message.addGbDeviceEvent(deviceEvtCallControl);
case REPLY_MESSAGES:
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY;
deviceEvtNotificationControl.reply = message.getActionString();
@ -188,23 +195,23 @@ public class NotificationsHandler implements MessageHandler {
} else {
deviceEvtNotificationControl.handle = mNotificationReplyAction.lookup(notificationSpec.getId()); //handle of wearable action is needed
}
message.setDeviceEvent(deviceEvtNotificationControl);
message.addGbDeviceEvent(deviceEvtNotificationControl);
break;
case ACCEPT_INCOMING_CALL:
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.ACCEPT;
message.setDeviceEvent(deviceEvtCallControl);
message.addGbDeviceEvent(deviceEvtCallControl);
break;
case REJECT_INCOMING_CALL:
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.REJECT;
message.setDeviceEvent(deviceEvtCallControl);
message.addGbDeviceEvent(deviceEvtCallControl);
break;
case DISMISS_NOTIFICATION:
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.DISMISS;
message.setDeviceEvent(deviceEvtNotificationControl);
message.addGbDeviceEvent(deviceEvtNotificationControl);
break;
case BLOCK_APPLICATION:
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.MUTE;
message.setDeviceEvent(deviceEvtNotificationControl);
message.addGbDeviceEvent(deviceEvtNotificationControl);
break;
}
}

View File

@ -349,7 +349,7 @@ public class ProtocolBufferHandler implements MessageHandler {
);
} else {
builder.setStatus(GdiSmsNotification.SmsNotificationService.ResponseStatus.GENERIC_ERROR);
LOG.error("Missing canned messages data for type {}", requestedType);
LOG.info("Missing canned messages data for type {}", requestedType);
}
}

View File

@ -1,5 +1,6 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@ -21,7 +22,7 @@ public class NotificationControlMessage extends GFDIMessage {
private NotificationsHandler.LegacyNotificationAction legacyNotificationAction;
private NotificationsHandler.NotificationAction notificationAction;
private String actionString;
private GBDeviceEvent deviceEvent;
private List<GBDeviceEvent> gbDeviceEventList;
public NotificationControlMessage(GarminMessage garminMessage, NotificationsHandler.NotificationCommand command, int notificationId, NotificationsHandler.NotificationAction notificationAction, String actionString) {
this.garminMessage = garminMessage;
@ -108,13 +109,17 @@ public class NotificationControlMessage extends GFDIMessage {
return actionString;
}
public void setDeviceEvent(GBDeviceEvent deviceEvent) {
this.deviceEvent = deviceEvent;
public void addGbDeviceEvent(GBDeviceEvent gbDeviceEvent) {
if (null == this.gbDeviceEventList)
this.gbDeviceEventList = new ArrayList<>();
this.gbDeviceEventList.add(gbDeviceEvent);
}
@Override
public List<GBDeviceEvent> getGBDeviceEvent() {
return Collections.singletonList(deviceEvent);
if (null == this.gbDeviceEventList)
return Collections.emptyList();
return gbDeviceEventList;
}
public NotificationsHandler.LegacyNotificationAction getLegacyNotificationAction() {