mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 19:06:53 +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:
parent
179f8a3a9e
commit
a5dbb7fea7
@ -84,6 +84,11 @@ public class NotificationsHandler implements MessageHandler {
|
|||||||
callNotificationSpec.type = NotificationType.GENERIC_PHONE;
|
callNotificationSpec.type = NotificationType.GENERIC_PHONE;
|
||||||
callNotificationSpec.body = StringUtils.isEmpty(callSpec.name) ? callSpec.number : callSpec.name;
|
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);
|
return onNotification(callNotificationSpec);
|
||||||
} else {
|
} else {
|
||||||
if (callSpec.number != null) // this happens in debug screen
|
if (callSpec.number != null) // this happens in debug screen
|
||||||
@ -180,6 +185,8 @@ public class NotificationsHandler implements MessageHandler {
|
|||||||
final GBDeviceEventCallControl deviceEvtCallControl = new GBDeviceEventCallControl();
|
final GBDeviceEventCallControl deviceEvtCallControl = new GBDeviceEventCallControl();
|
||||||
switch (message.getNotificationAction()) {
|
switch (message.getNotificationAction()) {
|
||||||
case REPLY_INCOMING_CALL:
|
case REPLY_INCOMING_CALL:
|
||||||
|
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.REJECT;
|
||||||
|
message.addGbDeviceEvent(deviceEvtCallControl);
|
||||||
case REPLY_MESSAGES:
|
case REPLY_MESSAGES:
|
||||||
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY;
|
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY;
|
||||||
deviceEvtNotificationControl.reply = message.getActionString();
|
deviceEvtNotificationControl.reply = message.getActionString();
|
||||||
@ -188,23 +195,23 @@ public class NotificationsHandler implements MessageHandler {
|
|||||||
} else {
|
} else {
|
||||||
deviceEvtNotificationControl.handle = mNotificationReplyAction.lookup(notificationSpec.getId()); //handle of wearable action is needed
|
deviceEvtNotificationControl.handle = mNotificationReplyAction.lookup(notificationSpec.getId()); //handle of wearable action is needed
|
||||||
}
|
}
|
||||||
message.setDeviceEvent(deviceEvtNotificationControl);
|
message.addGbDeviceEvent(deviceEvtNotificationControl);
|
||||||
break;
|
break;
|
||||||
case ACCEPT_INCOMING_CALL:
|
case ACCEPT_INCOMING_CALL:
|
||||||
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.ACCEPT;
|
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.ACCEPT;
|
||||||
message.setDeviceEvent(deviceEvtCallControl);
|
message.addGbDeviceEvent(deviceEvtCallControl);
|
||||||
break;
|
break;
|
||||||
case REJECT_INCOMING_CALL:
|
case REJECT_INCOMING_CALL:
|
||||||
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.REJECT;
|
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.REJECT;
|
||||||
message.setDeviceEvent(deviceEvtCallControl);
|
message.addGbDeviceEvent(deviceEvtCallControl);
|
||||||
break;
|
break;
|
||||||
case DISMISS_NOTIFICATION:
|
case DISMISS_NOTIFICATION:
|
||||||
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.DISMISS;
|
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.DISMISS;
|
||||||
message.setDeviceEvent(deviceEvtNotificationControl);
|
message.addGbDeviceEvent(deviceEvtNotificationControl);
|
||||||
break;
|
break;
|
||||||
case BLOCK_APPLICATION:
|
case BLOCK_APPLICATION:
|
||||||
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.MUTE;
|
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.MUTE;
|
||||||
message.setDeviceEvent(deviceEvtNotificationControl);
|
message.addGbDeviceEvent(deviceEvtNotificationControl);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ public class ProtocolBufferHandler implements MessageHandler {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
builder.setStatus(GdiSmsNotification.SmsNotificationService.ResponseStatus.GENERIC_ERROR);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -21,7 +22,7 @@ public class NotificationControlMessage extends GFDIMessage {
|
|||||||
private NotificationsHandler.LegacyNotificationAction legacyNotificationAction;
|
private NotificationsHandler.LegacyNotificationAction legacyNotificationAction;
|
||||||
private NotificationsHandler.NotificationAction notificationAction;
|
private NotificationsHandler.NotificationAction notificationAction;
|
||||||
private String actionString;
|
private String actionString;
|
||||||
private GBDeviceEvent deviceEvent;
|
private List<GBDeviceEvent> gbDeviceEventList;
|
||||||
|
|
||||||
public NotificationControlMessage(GarminMessage garminMessage, NotificationsHandler.NotificationCommand command, int notificationId, NotificationsHandler.NotificationAction notificationAction, String actionString) {
|
public NotificationControlMessage(GarminMessage garminMessage, NotificationsHandler.NotificationCommand command, int notificationId, NotificationsHandler.NotificationAction notificationAction, String actionString) {
|
||||||
this.garminMessage = garminMessage;
|
this.garminMessage = garminMessage;
|
||||||
@ -108,13 +109,17 @@ public class NotificationControlMessage extends GFDIMessage {
|
|||||||
return actionString;
|
return actionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceEvent(GBDeviceEvent deviceEvent) {
|
public void addGbDeviceEvent(GBDeviceEvent gbDeviceEvent) {
|
||||||
this.deviceEvent = deviceEvent;
|
if (null == this.gbDeviceEventList)
|
||||||
|
this.gbDeviceEventList = new ArrayList<>();
|
||||||
|
this.gbDeviceEventList.add(gbDeviceEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GBDeviceEvent> getGBDeviceEvent() {
|
public List<GBDeviceEvent> getGBDeviceEvent() {
|
||||||
return Collections.singletonList(deviceEvent);
|
if (null == this.gbDeviceEventList)
|
||||||
|
return Collections.emptyList();
|
||||||
|
return gbDeviceEventList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotificationsHandler.LegacyNotificationAction getLegacyNotificationAction() {
|
public NotificationsHandler.LegacyNotificationAction getLegacyNotificationAction() {
|
||||||
|
Loading…
Reference in New Issue
Block a user