mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Huawei: reply only if quick actions allow it
This commit is contained in:
parent
b7641f6e45
commit
8da2b68eed
@ -664,7 +664,7 @@ public class HuaweiCoordinator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsNotificationsReply() {
|
public boolean supportsNotificationsReplyActions() {
|
||||||
if (supportsExpandCapability())
|
if (supportsExpandCapability())
|
||||||
return supportsExpandCapability(73);
|
return supportsExpandCapability(73);
|
||||||
return false;
|
return false;
|
||||||
@ -676,7 +676,7 @@ public class HuaweiCoordinator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsNotificationsSyncKey() {
|
public boolean supportsNotificationsReply() {
|
||||||
if (supportsExpandCapability())
|
if (supportsExpandCapability())
|
||||||
return supportsExpandCapability(89);
|
return supportsExpandCapability(89);
|
||||||
return false;
|
return false;
|
||||||
|
@ -37,12 +37,13 @@ public class Notifications {
|
|||||||
|
|
||||||
public static class AdditionalParams {
|
public static class AdditionalParams {
|
||||||
|
|
||||||
public boolean supportsSyncKey = false;
|
public boolean supportsReply = false;
|
||||||
public boolean supportsRepeatedNotify = false;
|
public boolean supportsRepeatedNotify = false;
|
||||||
public boolean supportsRemoveSingle = false;
|
public boolean supportsRemoveSingle = false;
|
||||||
public boolean supportsReply = false;
|
public boolean supportsReplyActions = false;
|
||||||
public boolean supportsTimestamp = false;
|
public boolean supportsTimestamp = false;
|
||||||
|
|
||||||
|
public String replyKey = "";
|
||||||
public String notificationKey = "";
|
public String notificationKey = "";
|
||||||
public int notificationId = -1;
|
public int notificationId = -1;
|
||||||
public String channelId = "";
|
public String channelId = "";
|
||||||
@ -126,32 +127,24 @@ public class Notifications {
|
|||||||
|
|
||||||
if(addParams != null) {
|
if(addParams != null) {
|
||||||
|
|
||||||
|
if(!TextUtils.isEmpty(addParams.category)) { // type >= 34
|
||||||
if(!TextUtils.isEmpty(addParams.category)) { //TODO: device type >=34
|
|
||||||
this.tlv.put(0x12, addParams.category); // "imcall" also possible value, not standard for android
|
this.tlv.put(0x12, addParams.category); // "imcall" also possible value, not standard for android
|
||||||
}
|
}
|
||||||
|
if (addParams.supportsReply) {
|
||||||
if (addParams.supportsSyncKey)
|
this.tlv.put(0x18, (addParams.replyKey != null) ? addParams.replyKey : "");
|
||||||
this.tlv.put(0x18, (addParams.notificationKey != null) ? addParams.notificationKey : "");
|
}
|
||||||
|
if (addParams.supportsReplyActions && notificationType == NotificationType.sms) {
|
||||||
//if(addParams.repeatedNotifySupports) {
|
|
||||||
// this.tlv.put(0x13, 0); // 0x13 - reminder 15 = vibrate, 0 - default
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (addParams.supportsReply && notificationType == NotificationType.sms) {
|
|
||||||
this.tlv.put(0x14, addParams.subscriptionId);
|
this.tlv.put(0x14, addParams.subscriptionId);
|
||||||
this.tlv.put(0x17, addParams.address);
|
this.tlv.put(0x17, addParams.address);
|
||||||
}
|
}
|
||||||
|
if (addParams.supportsTimestamp) {
|
||||||
|
this.tlv.put(0x15, (int) (System.currentTimeMillis() / 1000));
|
||||||
|
}
|
||||||
if (addParams.supportsRepeatedNotify || addParams.supportsRemoveSingle) {
|
if (addParams.supportsRepeatedNotify || addParams.supportsRemoveSingle) {
|
||||||
this.tlv.put(0x19, (addParams.notificationKey != null) ? addParams.notificationKey : "");
|
this.tlv.put(0x19, (addParams.notificationKey != null) ? addParams.notificationKey : "");
|
||||||
this.tlv.put(0x1a, addParams.notificationId);
|
this.tlv.put(0x1a, addParams.notificationId);
|
||||||
this.tlv.put(0x1b, (addParams.channelId != null) ? addParams.channelId : "");
|
this.tlv.put(0x1b, (addParams.channelId != null) ? addParams.channelId : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addParams.supportsTimestamp) {
|
|
||||||
this.tlv.put(0x15, (int) (System.currentTimeMillis() / 1000));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.complete = true;
|
this.complete = true;
|
||||||
|
@ -91,7 +91,7 @@ public class HuaweiNotificationsManager {
|
|||||||
|
|
||||||
void onReplyResponse(Notifications.NotificationReply.ReplyResponse response) {
|
void onReplyResponse(Notifications.NotificationReply.ReplyResponse response) {
|
||||||
LOG.info(" KEY: {}, Text: {}", response.key, response.text);
|
LOG.info(" KEY: {}, Text: {}", response.key, response.text);
|
||||||
if(!this.support.getHuaweiCoordinator().supportsNotificationsReply()) {
|
if(!this.support.getHuaweiCoordinator().supportsNotificationsReplyActions()) {
|
||||||
LOG.info("Reply is not supported");
|
LOG.info("Reply is not supported");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,6 @@ public class HuaweiNotificationsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
this.support.evaluateGBDeviceEvent(deviceEvtNotificationControl);
|
this.support.evaluateGBDeviceEvent(deviceEvtNotificationControl);
|
||||||
//TODO: maybe should be send reply. Service: 0x2, command: 0x10, tlv 7 and/or 1, type byte, 7f on error
|
//TODO: maybe should be send reply. Service: 0x2, command: 0x10, tlv 7 and/or 1, type byte, 7f on error
|
||||||
|
@ -66,16 +66,31 @@ public class SendNotificationRequest extends Request {
|
|||||||
body = notificationSpec.body.substring(0x0, supportProvider.getHuaweiCoordinator().getContentLength() - 0xD);
|
body = notificationSpec.body.substring(0x0, supportProvider.getHuaweiCoordinator().getContentLength() - 0xD);
|
||||||
body += "...";
|
body += "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String replyKey = "";
|
||||||
|
final boolean hasActions = (null != notificationSpec.attachedActions && !notificationSpec.attachedActions.isEmpty());
|
||||||
|
if (hasActions) {
|
||||||
|
for (int i = 0; i < notificationSpec.attachedActions.size(); i++) {
|
||||||
|
final NotificationSpec.Action action = notificationSpec.attachedActions.get(i);
|
||||||
|
if (action.type == NotificationSpec.Action.TYPE_WEARABLE_REPLY || action.type == NotificationSpec.Action.TYPE_SYNTECTIC_REPLY_PHONENR) {
|
||||||
|
//NOTE: store notification key instead action key. The watch returns this key so it is more easier to find action by notification key
|
||||||
|
replyKey = notificationSpec.key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Notifications.NotificationActionRequest.AdditionalParams params = new Notifications.NotificationActionRequest.AdditionalParams();
|
Notifications.NotificationActionRequest.AdditionalParams params = new Notifications.NotificationActionRequest.AdditionalParams();
|
||||||
|
|
||||||
params.supportsSyncKey = supportProvider.getHuaweiCoordinator().supportsNotificationsSyncKey();
|
params.supportsReply = supportProvider.getHuaweiCoordinator().supportsNotificationsReply();
|
||||||
params.supportsRepeatedNotify = supportProvider.getHuaweiCoordinator().supportsNotificationsRepeatedNotify();
|
params.supportsRepeatedNotify = supportProvider.getHuaweiCoordinator().supportsNotificationsRepeatedNotify();
|
||||||
params.supportsRemoveSingle = supportProvider.getHuaweiCoordinator().supportsNotificationsRemoveSingle();
|
params.supportsRemoveSingle = supportProvider.getHuaweiCoordinator().supportsNotificationsRemoveSingle();
|
||||||
params.supportsReply = supportProvider.getHuaweiCoordinator().supportsNotificationsReply();
|
params.supportsReplyActions = supportProvider.getHuaweiCoordinator().supportsNotificationsReplyActions();
|
||||||
params.supportsTimestamp = supportProvider.getHuaweiCoordinator().supportsNotificationsTimestamp();
|
params.supportsTimestamp = supportProvider.getHuaweiCoordinator().supportsNotificationsTimestamp();
|
||||||
|
|
||||||
params.notificationId = notificationSpec.getId();
|
params.notificationId = notificationSpec.getId();
|
||||||
params.notificationKey = notificationSpec.key;
|
params.notificationKey = notificationSpec.key;
|
||||||
|
params.replyKey = replyKey;
|
||||||
params.channelId = notificationSpec.channelId;
|
params.channelId = notificationSpec.channelId;
|
||||||
params.category = notificationSpec.category;
|
params.category = notificationSpec.category;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user