mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 00:30:37 +02:00
Xiaomi: Delete notification from watch when dismissed from phone
This commit is contained in:
parent
ef73ea1bd5
commit
18686e98c5
@ -46,6 +46,7 @@ import nodomain.freeyourgadget.gadgetbridge.proto.xiaomi.XiaomiProto;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiPreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
@ -73,6 +74,10 @@ public class XiaomiNotificationService extends AbstractXiaomiService implements
|
||||
// requests with the package name truncated, and without an ID
|
||||
private final Queue<String> mPackages = new LinkedList<>();
|
||||
|
||||
// Keep track of package names and keys for notification dismissal
|
||||
private final LimitedQueue<Integer, String> mNotificationPackageName = new LimitedQueue<>(128);
|
||||
private final LimitedQueue<Integer, String> mNotificationKey = new LimitedQueue<>(128);
|
||||
|
||||
private String iconPackageName;
|
||||
|
||||
public XiaomiNotificationService(final XiaomiSupport support) {
|
||||
@ -166,6 +171,9 @@ public class XiaomiNotificationService extends AbstractXiaomiService implements
|
||||
notification3.setPackage(BuildConfig.APPLICATION_ID);
|
||||
}
|
||||
|
||||
mNotificationPackageName.add(notificationSpec.getId(), notificationSpec.sourceAppId);
|
||||
mNotificationKey.add(notificationSpec.getId(), notificationSpec.key);
|
||||
|
||||
mPackages.add(notification3.getPackage());
|
||||
if (mPackages.size() > 32) {
|
||||
mPackages.poll();
|
||||
@ -213,7 +221,28 @@ public class XiaomiNotificationService extends AbstractXiaomiService implements
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO
|
||||
final XiaomiProto.NotificationId notificationId = XiaomiProto.NotificationId.newBuilder()
|
||||
.setId(id)
|
||||
.setPackage(mNotificationPackageName.lookup(id))
|
||||
.setKey(mNotificationKey.lookup(id))
|
||||
.build();
|
||||
|
||||
final XiaomiProto.NotificationDismiss notificationDismiss = XiaomiProto.NotificationDismiss.newBuilder()
|
||||
.addNotificationId(notificationId)
|
||||
.build();
|
||||
|
||||
final XiaomiProto.Notification notification = XiaomiProto.Notification.newBuilder()
|
||||
.setNotificationDismiss(notificationDismiss)
|
||||
.build();
|
||||
|
||||
getSupport().sendCommand(
|
||||
"delete notification " + id,
|
||||
XiaomiProto.Command.newBuilder()
|
||||
.setType(COMMAND_TYPE)
|
||||
.setSubtype(CMD_NOTIFICATION_DISMISS)
|
||||
.setNotification(notification)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
public void onSetCallState(final CallSpec callSpec) {
|
||||
|
@ -624,7 +624,7 @@ message NotificationDismiss {
|
||||
message NotificationId {
|
||||
optional uint32 id = 1;
|
||||
optional string package = 2; // truncated
|
||||
optional string unknown4 = 4; // ""
|
||||
optional string key = 4; // ""
|
||||
}
|
||||
|
||||
message CannedMessages {
|
||||
|
Loading…
Reference in New Issue
Block a user