Allow overlays to configure ConnectivityService's network sampling to not wake the device.
This can increase clockwork device battery life. Bug:15455204 Change-Id: Ifc551e6a522627dc8e5cfdfb8f56d4e3cbeea936
This commit is contained in:
@@ -5038,8 +5038,18 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
setAlarm(samplingIntervalInSeconds * 1000, mSampleIntervalElapsedIntent);
|
setAlarm(samplingIntervalInSeconds * 1000, mSampleIntervalElapsedIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a network sampling alarm.
|
||||||
|
*/
|
||||||
void setAlarm(int timeoutInMilliseconds, PendingIntent intent) {
|
void setAlarm(int timeoutInMilliseconds, PendingIntent intent) {
|
||||||
long wakeupTime = SystemClock.elapsedRealtime() + timeoutInMilliseconds;
|
long wakeupTime = SystemClock.elapsedRealtime() + timeoutInMilliseconds;
|
||||||
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, wakeupTime, intent);
|
int alarmType;
|
||||||
|
if (Resources.getSystem().getBoolean(
|
||||||
|
R.bool.config_networkSamplingWakesDevice)) {
|
||||||
|
alarmType = AlarmManager.ELAPSED_REALTIME_WAKEUP;
|
||||||
|
} else {
|
||||||
|
alarmType = AlarmManager.ELAPSED_REALTIME;
|
||||||
|
}
|
||||||
|
mAlarmManager.set(alarmType, wakeupTime, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user