LINT: WakeLocks
This commit is contained in:
parent
a339e0cf28
commit
eee3bc4838
|
@ -172,7 +172,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
boolean keepScreenOn = SP.getBoolean(R.string.key_keep_screen_on, false);
|
boolean keepScreenOn = SP.getBoolean(R.string.key_keep_screen_on, false);
|
||||||
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
if (keepScreenOn) {
|
if (keepScreenOn) {
|
||||||
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AAPS");
|
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AndroidAPS:MainActivity_onEventPreferenceChange");
|
||||||
if (!mWakeLock.isHeld())
|
if (!mWakeLock.isHeld())
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class NSClientService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "NSClientService");
|
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:NSClientService");
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ public class NSClientService extends Service {
|
||||||
public void run() {
|
public void run() {
|
||||||
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
||||||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||||
"onDataUpdate");
|
"AndroidAPS:NSClientService_onDataUpdate");
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class QueueThread extends Thread {
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "QueueThread");
|
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:QueueThread");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent rIntent) {
|
public void onReceive(Context context, Intent rIntent) {
|
||||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "");
|
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:KeepAliveReciever");
|
||||||
wl.acquire();
|
wl.acquire();
|
||||||
|
|
||||||
LocalAlertUtils.shortenSnoozeInterval();
|
LocalAlertUtils.shortenSnoozeInterval();
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
||||||
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
||||||
.getDefaultDisplay();
|
.getDefaultDisplay();
|
||||||
display.getSize(displaySize);
|
display.getSize(displaySize);
|
||||||
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");
|
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:BIGChart");
|
||||||
|
|
||||||
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x,
|
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x,
|
||||||
View.MeasureSpec.EXACTLY);
|
View.MeasureSpec.EXACTLY);
|
||||||
|
|
|
@ -116,7 +116,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||||
display.getSize(displaySize);
|
display.getSize(displaySize);
|
||||||
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");
|
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:BaseWatchFace");
|
||||||
|
|
||||||
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x, View.MeasureSpec.EXACTLY);
|
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x, View.MeasureSpec.EXACTLY);
|
||||||
if (forceSquareCanvas) {
|
if (forceSquareCanvas) {
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "CreateWakelock");
|
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:CircleWatchface");
|
||||||
wakeLock.acquire(30000);
|
wakeLock.acquire(30000);
|
||||||
|
|
||||||
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
||||||
|
@ -322,7 +322,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
|
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
|
||||||
if (oldTime.hasMinuteChanged(newTime)) {
|
if (oldTime.hasMinuteChanged(newTime)) {
|
||||||
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TimeChangedWakelock");
|
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:CircleWatchface_onTimeChanged");
|
||||||
wakeLock.acquire(30000);
|
wakeLock.acquire(30000);
|
||||||
/*Preparing the layout just on every minute tick:
|
/*Preparing the layout just on every minute tick:
|
||||||
* - hopefully better battery life
|
* - hopefully better battery life
|
||||||
|
@ -472,6 +472,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
private String getAvgDelta() {
|
private String getAvgDelta() {
|
||||||
return avgDelta;
|
return avgDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAvgDelta(String avgDelta) {
|
private void setAvgDelta(String avgDelta) {
|
||||||
this.avgDelta = avgDelta;
|
this.avgDelta = avgDelta;
|
||||||
}
|
}
|
||||||
|
@ -518,8 +519,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:MessageReceiver");
|
||||||
"MyWakelockTag");
|
|
||||||
wakeLock.acquire(30000);
|
wakeLock.acquire(30000);
|
||||||
Bundle bundle = intent.getBundleExtra("data");
|
Bundle bundle = intent.getBundleExtra("data");
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class NOChart extends WatchFace implements SharedPreferences.OnSharedPref
|
||||||
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
||||||
.getDefaultDisplay();
|
.getDefaultDisplay();
|
||||||
display.getSize(displaySize);
|
display.getSize(displaySize);
|
||||||
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");
|
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:NOChart");
|
||||||
|
|
||||||
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x,
|
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x,
|
||||||
View.MeasureSpec.EXACTLY);
|
View.MeasureSpec.EXACTLY);
|
||||||
|
|
Loading…
Reference in a new issue