mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-13 11:17:33 +01:00
Xiaomi: Implement Screen On on Notification setting
Works on Redmi Watch 3 Active Does not work on Mi Watch Lite
This commit is contained in:
parent
b9b91db06f
commit
6e5bedb365
@ -63,6 +63,7 @@ public class XiaomiSystemService extends AbstractXiaomiService implements Xiaomi
|
|||||||
public static final int CMD_CLOCK = 3;
|
public static final int CMD_CLOCK = 3;
|
||||||
public static final int CMD_FIRMWARE_INSTALL = 5;
|
public static final int CMD_FIRMWARE_INSTALL = 5;
|
||||||
public static final int CMD_LANGUAGE = 6;
|
public static final int CMD_LANGUAGE = 6;
|
||||||
|
public static final int CMD_SCREEN_ON_ON_NOTIFICAIONS = 7;
|
||||||
public static final int CMD_PASSWORD_GET = 9;
|
public static final int CMD_PASSWORD_GET = 9;
|
||||||
public static final int CMD_FIND_PHONE = 17;
|
public static final int CMD_FIND_PHONE = 17;
|
||||||
public static final int CMD_FIND_WATCH = 18;
|
public static final int CMD_FIND_WATCH = 18;
|
||||||
@ -145,9 +146,13 @@ public class XiaomiSystemService extends AbstractXiaomiService implements Xiaomi
|
|||||||
case PasswordCapabilityImpl.PREF_PASSWORD_ENABLED:
|
case PasswordCapabilityImpl.PREF_PASSWORD_ENABLED:
|
||||||
case PasswordCapabilityImpl.PREF_PASSWORD:
|
case PasswordCapabilityImpl.PREF_PASSWORD:
|
||||||
setPassword();
|
setPassword();
|
||||||
|
return true;
|
||||||
case HuamiConst.PREF_DISPLAY_ITEMS_SORTABLE:
|
case HuamiConst.PREF_DISPLAY_ITEMS_SORTABLE:
|
||||||
setDisplayItems();
|
setDisplayItems();
|
||||||
return true;
|
return true;
|
||||||
|
case DeviceSettingsPreferenceConst.PREF_SCREEN_ON_ON_NOTIFICATIONS:
|
||||||
|
setScreenOnOnNotifications();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onSendConfiguration(config, prefs);
|
return super.onSendConfiguration(config, prefs);
|
||||||
@ -282,6 +287,23 @@ public class XiaomiSystemService extends AbstractXiaomiService implements Xiaomi
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setScreenOnOnNotifications() {
|
||||||
|
final Prefs prefs = getDevicePrefs();
|
||||||
|
|
||||||
|
final boolean screenOnOnNotificationsEnabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_SCREEN_ON_ON_NOTIFICATIONS, true);
|
||||||
|
|
||||||
|
LOG.info("Setting screen on on notification: {}", screenOnOnNotificationsEnabled);
|
||||||
|
|
||||||
|
getSupport().sendCommand(
|
||||||
|
"set password",
|
||||||
|
XiaomiProto.Command.newBuilder()
|
||||||
|
.setType(CMD_SCREEN_ON_ON_NOTIFICAIONS) // Why? Would also expect COMMAND_TYPE here
|
||||||
|
.setSubtype(CMD_SCREEN_ON_ON_NOTIFICAIONS)
|
||||||
|
.setNotification(XiaomiProto.Notification.newBuilder().setScreenOnOnNotifications(screenOnOnNotificationsEnabled).build())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private void handlePassword(final XiaomiProto.Password password) {
|
private void handlePassword(final XiaomiProto.Password password) {
|
||||||
LOG.debug("Got device password");
|
LOG.debug("Got device password");
|
||||||
final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences(
|
final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences(
|
||||||
|
@ -564,6 +564,7 @@ message Notification {
|
|||||||
optional Notification2 notification2 = 3;
|
optional Notification2 notification2 = 3;
|
||||||
optional NotificationDismiss notification4 = 4;
|
optional NotificationDismiss notification4 = 4;
|
||||||
|
|
||||||
|
optional bool screenOnOnNotifications = 7;
|
||||||
optional uint32 unknown8 = 8; // 1 on canned replies request?
|
optional uint32 unknown8 = 8; // 1 on canned replies request?
|
||||||
// 7, 9 get | 7, 12 set
|
// 7, 9 get | 7, 12 set
|
||||||
optional CannedMessages cannedMessages = 9;
|
optional CannedMessages cannedMessages = 9;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user