1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 17:27:24 +01:00

Xiaomi: Refuse delete of active watchface

This commit is contained in:
José Rebelo 2023-10-22 11:58:55 +01:00
parent 1b645f44d7
commit e2d7798e36

View File

@ -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);