LINT: WakeLocks
This commit is contained in:
parent
a339e0cf28
commit
eee3bc4838
8 changed files with 24 additions and 24 deletions
|
@ -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))
|
||||||
|
@ -199,7 +199,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
} else {
|
} else {
|
||||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
||||||
}
|
}
|
||||||
if(sharedPrefs.getBoolean("showAvgDelta", true)){
|
if (sharedPrefs.getBoolean("showAvgDelta", true)) {
|
||||||
textView.append(" " + getAvgDelta());
|
textView.append(" " + getAvgDelta());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,11 +519,10 @@ 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) {
|
||||||
DataMap dataMap = DataMap.fromBundle(bundle);
|
DataMap dataMap = DataMap.fromBundle(bundle);
|
||||||
setSgvLevel((int) dataMap.getLong("sgvLevel"));
|
setSgvLevel((int) dataMap.getLong("sgvLevel"));
|
||||||
Log.d("CircleWatchface", "sgv level : " + getSgvLevel());
|
Log.d("CircleWatchface", "sgv level : " + getSgvLevel());
|
||||||
|
@ -561,7 +561,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
|
|
||||||
public synchronized void addToWatchSet(DataMap dataMap) {
|
public synchronized void addToWatchSet(DataMap dataMap) {
|
||||||
|
|
||||||
if(!sharedPrefs.getBoolean("showRingHistory", false)){
|
if (!sharedPrefs.getBoolean("showRingHistory", false)) {
|
||||||
bgDataList.clear();
|
bgDataList.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -706,14 +706,14 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
@Override
|
@Override
|
||||||
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
|
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
|
||||||
|
|
||||||
int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0;
|
int extra = mSgv != null ? (mSgv.getRight() - mSgv.getLeft()) / 2 : 0;
|
||||||
|
|
||||||
if (tapType == TAP_TYPE_TAP&&
|
if (tapType == TAP_TYPE_TAP &&
|
||||||
x + extra >=mSgv.getLeft() &&
|
x + extra >= mSgv.getLeft() &&
|
||||||
x - extra <= mSgv.getRight()&&
|
x - extra <= mSgv.getRight() &&
|
||||||
y >= mSgv.getTop() &&
|
y >= mSgv.getTop() &&
|
||||||
y <= mSgv.getBottom()){
|
y <= mSgv.getBottom()) {
|
||||||
if (eventTime - sgvTapTime < 800){
|
if (eventTime - sgvTapTime < 800) {
|
||||||
Intent intent = new Intent(this, MainMenuActivity.class);
|
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -723,7 +723,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WatchFaceStyle getWatchFaceStyle(){
|
protected WatchFaceStyle getWatchFaceStyle() {
|
||||||
return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build();
|
return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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