mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-06-05 21:49:48 +02:00
Xiaomi: Refuse delete of active watchface
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user