diff options
| author | 2015-11-03 06:57:24 +0000 | |
|---|---|---|
| committer | 2015-11-03 06:57:24 +0000 | |
| commit | 45c001db40e91d1465682eb4b3843b01fe1d2eb9 (patch) | |
| tree | 7ada2ba030d0f6b26c3b1efac3498f53fb5b7628 | |
| parent | faa09f531f3a6fcd6518057315a52fdd0ffd3cba (diff) | |
| parent | 271dd1da81735a3cb0856db0dbb8634a6c4cc831 (diff) | |
Merge "NetworkTimeUpdateService: Grab a wakelock when manipulating system time" into mnc-dr-dev am: 1942be506e am: b1fe11fde4 am: 6efac0595f
am: 271dd1da81
* commit '271dd1da81735a3cb0856db0dbb8634a6c4cc831':
NetworkTimeUpdateService: Grab a wakelock when manipulating system time
| -rw-r--r-- | services/core/java/com/android/server/NetworkTimeUpdateService.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/NetworkTimeUpdateService.java b/services/core/java/com/android/server/NetworkTimeUpdateService.java index a0d305cdf2c6..3f0664defbf9 100644 --- a/services/core/java/com/android/server/NetworkTimeUpdateService.java +++ b/services/core/java/com/android/server/NetworkTimeUpdateService.java @@ -30,6 +30,7 @@ import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.os.SystemClock; +import android.os.PowerManager; import android.provider.Settings; import android.util.Log; import android.util.NtpTrustedTime; @@ -75,6 +76,7 @@ public class NetworkTimeUpdateService { private SettingsObserver mSettingsObserver; // The last time that we successfully fetched the NTP time. private long mLastNtpFetchTime = NOT_SET; + private final PowerManager.WakeLock mWakeLock; // Normal polling frequency private final long mPollingIntervalMs; @@ -104,6 +106,9 @@ public class NetworkTimeUpdateService { com.android.internal.R.integer.config_ntpRetry); mTimeErrorThresholdMs = mContext.getResources().getInteger( com.android.internal.R.integer.config_ntpThreshold); + + mWakeLock = ((PowerManager) context.getSystemService(Context.POWER_SERVICE)).newWakeLock( + PowerManager.PARTIAL_WAKE_LOCK, TAG); } /** Initialize the receivers and initiate the first NTP request */ @@ -148,7 +153,15 @@ public class NetworkTimeUpdateService { private void onPollNetworkTime(int event) { // If Automatic time is not set, don't bother. if (!isAutomaticTimeRequested()) return; + mWakeLock.acquire(); + try { + onPollNetworkTimeUnderWakeLock(event); + } finally { + mWakeLock.release(); + } + } + private void onPollNetworkTimeUnderWakeLock(int event) { final long refTime = SystemClock.elapsedRealtime(); // If NITZ time was received less than mPollingIntervalMs time ago, // no need to sync to NTP. |