Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5e67474 authored by Aaron Whyte's avatar Aaron Whyte
Browse files

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
parent 6462615c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1505,4 +1505,6 @@
        <item>users</item>
    </string-array>

    <bool name="config_networkSamplingWakesDevice">true</bool>

</resources>
+1 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@
  <java-symbol type="bool" name="config_enable_emergency_call_while_sim_locked" />
  <java-symbol type="bool" name="config_enable_puk_unlock_screen" />
  <java-symbol type="bool" name="config_mms_content_disposition_support" />
  <java-symbol type="bool" name="config_networkSamplingWakesDevice" />
  <java-symbol type="bool" name="config_showMenuShortcutsWhenKeyboardPresent" />
  <java-symbol type="bool" name="config_sip_wifi_only" />
  <java-symbol type="bool" name="config_sms_capable" />
+11 −1
Original line number Diff line number Diff line
@@ -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);
    }
}