Huawei: reply only if quick actions allow it

This commit is contained in:
Me7c7 2025-01-04 10:14:39 +02:00 committed by José Rebelo
parent b7641f6e45
commit 8da2b68eed
4 changed files with 31 additions and 24 deletions

View File

@ -664,7 +664,7 @@ public class HuaweiCoordinator {
return false;
}
public boolean supportsNotificationsReply() {
public boolean supportsNotificationsReplyActions() {
if (supportsExpandCapability())
return supportsExpandCapability(73);
return false;
@ -676,7 +676,7 @@ public class HuaweiCoordinator {
return false;
}
public boolean supportsNotificationsSyncKey() {
public boolean supportsNotificationsReply() {
if (supportsExpandCapability())
return supportsExpandCapability(89);
return false;

View File

@ -37,12 +37,13 @@ public class Notifications {
public static class AdditionalParams {
public boolean supportsSyncKey = false;
public boolean supportsReply = false;
public boolean supportsRepeatedNotify = false;
public boolean supportsRemoveSingle = false;
public boolean supportsReply = false;
public boolean supportsReplyActions = false;
public boolean supportsTimestamp = false;
public String replyKey = "";
public String notificationKey = "";
public int notificationId = -1;
public String channelId = "";
@ -126,32 +127,24 @@ public class Notifications {
if(addParams != null) {
if(!TextUtils.isEmpty(addParams.category)) { //TODO: device type >=34
if(!TextUtils.isEmpty(addParams.category)) { // type >= 34
this.tlv.put(0x12, addParams.category); // "imcall" also possible value, not standard for android
}
if (addParams.supportsSyncKey)
this.tlv.put(0x18, (addParams.notificationKey != null) ? addParams.notificationKey : "");
//if(addParams.repeatedNotifySupports) {
// this.tlv.put(0x13, 0); // 0x13 - reminder 15 = vibrate, 0 - default
//}
if (addParams.supportsReply && notificationType == NotificationType.sms) {
if (addParams.supportsReply) {
this.tlv.put(0x18, (addParams.replyKey != null) ? addParams.replyKey : "");
}
if (addParams.supportsReplyActions && notificationType == NotificationType.sms) {
this.tlv.put(0x14, addParams.subscriptionId);
this.tlv.put(0x17, addParams.address);
}
if (addParams.supportsTimestamp) {
this.tlv.put(0x15, (int) (System.currentTimeMillis() / 1000));
}
if (addParams.supportsRepeatedNotify || addParams.supportsRemoveSingle) {
this.tlv.put(0x19, (addParams.notificationKey != null) ? addParams.notificationKey : "");
this.tlv.put(0x1a, addParams.notificationId);
this.tlv.put(0x1b, (addParams.channelId != null) ? addParams.channelId : "");
}
if (addParams.supportsTimestamp) {
this.tlv.put(0x15, (int) (System.currentTimeMillis() / 1000));
}
}
this.complete = true;

View File

@ -91,7 +91,7 @@ public class HuaweiNotificationsManager {
void onReplyResponse(Notifications.NotificationReply.ReplyResponse response) {
LOG.info(" KEY: {}, Text: {}", response.key, response.text);
if(!this.support.getHuaweiCoordinator().supportsNotificationsReply()) {
if(!this.support.getHuaweiCoordinator().supportsNotificationsReplyActions()) {
LOG.info("Reply is not supported");
return;
}
@ -131,7 +131,6 @@ public class HuaweiNotificationsManager {
}
}
}
}
this.support.evaluateGBDeviceEvent(deviceEvtNotificationControl);
//TODO: maybe should be send reply. Service: 0x2, command: 0x10, tlv 7 and/or 1, type byte, 7f on error

View File

@ -66,16 +66,31 @@ public class SendNotificationRequest extends Request {
body = notificationSpec.body.substring(0x0, supportProvider.getHuaweiCoordinator().getContentLength() - 0xD);
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();
params.supportsSyncKey = supportProvider.getHuaweiCoordinator().supportsNotificationsSyncKey();
params.supportsReply = supportProvider.getHuaweiCoordinator().supportsNotificationsReply();
params.supportsRepeatedNotify = supportProvider.getHuaweiCoordinator().supportsNotificationsRepeatedNotify();
params.supportsRemoveSingle = supportProvider.getHuaweiCoordinator().supportsNotificationsRemoveSingle();
params.supportsReply = supportProvider.getHuaweiCoordinator().supportsNotificationsReply();
params.supportsReplyActions = supportProvider.getHuaweiCoordinator().supportsNotificationsReplyActions();
params.supportsTimestamp = supportProvider.getHuaweiCoordinator().supportsNotificationsTimestamp();
params.notificationId = notificationSpec.getId();
params.notificationKey = notificationSpec.key;
params.replyKey = replyKey;
params.channelId = notificationSpec.channelId;
params.category = notificationSpec.category;