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:
parent
d03a49b4aa
commit
39a9ec20d4
1 changed files with 11 additions and 1 deletions
|
|
@ -5038,8 +5038,18 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||
setAlarm(samplingIntervalInSeconds * 1000, mSampleIntervalElapsedIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a network sampling alarm.
|
||||
*/
|
||||
void setAlarm(int timeoutInMilliseconds, PendingIntent intent) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue