mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 11:26:47 +01:00
Xiaomi: Refuse delete of active watchface
This commit is contained in:
parent
1b645f44d7
commit
e2d7798e36
@ -46,6 +46,7 @@ public class XiaomiWatchfaceService extends AbstractXiaomiService {
|
||||
|
||||
private final Set<UUID> allWatchfaces = new HashSet<>();
|
||||
private final Set<UUID> userWatchfaces = new HashSet<>();
|
||||
private UUID activeWatchface = null;
|
||||
|
||||
public XiaomiWatchfaceService(final XiaomiSupport support) {
|
||||
super(support);
|
||||
@ -89,6 +90,7 @@ public class XiaomiWatchfaceService extends AbstractXiaomiService {
|
||||
|
||||
allWatchfaces.clear();
|
||||
userWatchfaces.clear();
|
||||
activeWatchface = null;
|
||||
|
||||
final List<GBDeviceApp> gbDeviceApps = new ArrayList<>();
|
||||
|
||||
@ -98,6 +100,9 @@ public class XiaomiWatchfaceService extends AbstractXiaomiService {
|
||||
if (watchface.getCanDelete()) {
|
||||
userWatchfaces.add(uuid);
|
||||
}
|
||||
if (watchface.getActive()) {
|
||||
activeWatchface = uuid;
|
||||
}
|
||||
|
||||
GBDeviceApp gbDeviceApp = new GBDeviceApp(
|
||||
uuid,
|
||||
@ -120,6 +125,8 @@ public class XiaomiWatchfaceService extends AbstractXiaomiService {
|
||||
return;
|
||||
}
|
||||
|
||||
activeWatchface = uuid;
|
||||
|
||||
LOG.debug("Set watchface to {}", uuid);
|
||||
|
||||
getSupport().sendCommand(
|
||||
@ -147,6 +154,11 @@ public class XiaomiWatchfaceService extends AbstractXiaomiService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (uuid.equals(activeWatchface)) {
|
||||
LOG.warn("Refusing to delete active watchface {}", uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG.debug("Delete watchface {}", uuid);
|
||||
|
||||
allWatchfaces.remove(uuid);
|
||||
|
Loading…
Reference in New Issue
Block a user