Wear: re-enable wakelock

This commit is contained in:
Andries Smit 2022-01-06 08:31:12 +01:00
parent 4dd97e75ea
commit 6e5d14d470
2 changed files with 8 additions and 4 deletions

View file

@ -135,7 +135,7 @@ public class RawDisplayData {
} }
private void updateData(DataMap dataMap) { private void updateData(DataMap dataMap) {
// wearUtil.getWakeLock("readingPrefs", 50); PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50);
sgvLevel = dataMap.getLong("sgvLevel"); sgvLevel = dataMap.getLong("sgvLevel");
datetime = dataMap.getLong("timestamp"); datetime = dataMap.getLong("timestamp");
sSgv = dataMap.getString("sgvString"); sSgv = dataMap.getString("sgvString");
@ -143,6 +143,7 @@ public class RawDisplayData {
sDelta = dataMap.getString("delta"); sDelta = dataMap.getString("delta");
sAvgDelta = dataMap.getString("avgDelta"); sAvgDelta = dataMap.getString("avgDelta");
sUnits = dataMap.getString("glucoseUnits"); sUnits = dataMap.getString("glucoseUnits");
wearUtil.releaseWakeLock(wl);
} }
public DataMap updateStatusFromMessage(Intent intent, PowerManager.WakeLock wakeLock) { public DataMap updateStatusFromMessage(Intent intent, PowerManager.WakeLock wakeLock) {
@ -156,7 +157,7 @@ public class RawDisplayData {
} }
private void updateStatus(DataMap dataMap) { private void updateStatus(DataMap dataMap) {
// wearUtil.getWakeLock("readingPrefs", 50); PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50);
sBasalRate = dataMap.getString("currentBasal"); sBasalRate = dataMap.getString("currentBasal");
sUploaderBattery = dataMap.getString("battery"); sUploaderBattery = dataMap.getString("battery");
sRigBattery = dataMap.getString("rigBattery"); sRigBattery = dataMap.getString("rigBattery");
@ -170,6 +171,7 @@ public class RawDisplayData {
externalStatusString = dataMap.getString("externalStatusString"); externalStatusString = dataMap.getString("externalStatusString");
batteryLevel = dataMap.getInt("batteryLevel"); batteryLevel = dataMap.getInt("batteryLevel");
openApsStatus = dataMap.getLong("openApsStatus"); openApsStatus = dataMap.getLong("openApsStatus");
wearUtil.releaseWakeLock(wl);
} }
public DataMap updateBasalsFromMessage(Intent intent, PowerManager.WakeLock wakeLock) { public DataMap updateBasalsFromMessage(Intent intent, PowerManager.WakeLock wakeLock) {
@ -183,8 +185,9 @@ public class RawDisplayData {
} }
private void updateBasals(DataMap dataMap) { private void updateBasals(DataMap dataMap) {
// wearUtil.getWakeLock("readingPrefs", 500); PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 500);
loadBasalsAndTemps(dataMap); loadBasalsAndTemps(dataMap);
wearUtil.releaseWakeLock(wl);
} }
private void loadBasalsAndTemps(DataMap dataMap) { private void loadBasalsAndTemps(DataMap dataMap) {

View file

@ -303,7 +303,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
Log.i(TAG, "onTimeChanged: "); Log.i(TAG, "onTimeChanged: ");
if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
Log.i(TAG, "onTimeChanged: time changed"); Log.i(TAG, "onTimeChanged: time changed");
// wakeLock.acquire(50); PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50);
setDataFields(); setDataFields();
setColor(); setColor();
@ -316,6 +316,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} else { } else {
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
} }
wearUtil.releaseWakeLock(wl);
// invalidate(); // invalidate();
} }
} }