diff options
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | api/system-current.txt | 1 | ||||
| -rw-r--r-- | api/test-current.txt | 1 | ||||
| -rwxr-xr-x | core/java/android/provider/Settings.java | 7 | ||||
| -rw-r--r-- | services/core/java/com/android/server/power/PowerManagerService.java | 20 |
5 files changed, 29 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt index 999c690f905e..3fdcf0bd568b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -32211,6 +32211,7 @@ package android.provider { field public static final java.lang.String AUTO_TIME = "auto_time"; field public static final java.lang.String AUTO_TIME_ZONE = "auto_time_zone"; field public static final java.lang.String BLUETOOTH_ON = "bluetooth_on"; + field public static final java.lang.String BOOT_COUNT = "boot_count"; field public static final java.lang.String CONTACT_METADATA_SYNC = "contact_metadata_sync"; field public static final android.net.Uri CONTENT_URI; field public static final java.lang.String DATA_ROAMING = "data_roaming"; diff --git a/api/system-current.txt b/api/system-current.txt index 6ea023cae4a8..59d53e0e0443 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -34698,6 +34698,7 @@ package android.provider { field public static final java.lang.String AUTO_TIME = "auto_time"; field public static final java.lang.String AUTO_TIME_ZONE = "auto_time_zone"; field public static final java.lang.String BLUETOOTH_ON = "bluetooth_on"; + field public static final java.lang.String BOOT_COUNT = "boot_count"; field public static final java.lang.String CONTACT_METADATA_SYNC = "contact_metadata_sync"; field public static final android.net.Uri CONTENT_URI; field public static final java.lang.String DATA_ROAMING = "data_roaming"; diff --git a/api/test-current.txt b/api/test-current.txt index d2afda5d4a4e..f298dc492dd3 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -32226,6 +32226,7 @@ package android.provider { field public static final java.lang.String AUTO_TIME = "auto_time"; field public static final java.lang.String AUTO_TIME_ZONE = "auto_time_zone"; field public static final java.lang.String BLUETOOTH_ON = "bluetooth_on"; + field public static final java.lang.String BOOT_COUNT = "boot_count"; field public static final java.lang.String CONTACT_METADATA_SYNC = "contact_metadata_sync"; field public static final android.net.Uri CONTENT_URI; field public static final java.lang.String DATA_ROAMING = "data_roaming"; diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 940ac48a7c31..4f185e6771e2 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -8282,6 +8282,13 @@ public final class Settings { "allow_user_switching_when_system_user_locked"; /** + * Boot count since the device starts running APK level 24. + * <p> + * Type: int + */ + public static final String BOOT_COUNT = "boot_count"; + + /** * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. * diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 6218c4e61b59..91d86710a1a9 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -50,6 +50,7 @@ import android.os.UserHandle; import android.os.WorkSource; import android.provider.Settings; import android.provider.Settings.Secure; +import android.provider.Settings.SettingNotFoundException; import android.service.dreams.DreamManagerInternal; import android.util.EventLog; import android.util.Slog; @@ -57,6 +58,7 @@ import android.util.SparseIntArray; import android.util.TimeUtils; import android.view.Display; import android.view.WindowManagerPolicy; + import com.android.internal.app.IAppOpsService; import com.android.internal.app.IBatteryStats; import com.android.internal.os.BackgroundThread; @@ -537,6 +539,8 @@ public final class PowerManagerService extends SystemService } } mBootCompletedRunnables = null; + + incrementBootCount(); } } } @@ -772,7 +776,7 @@ public final class PowerManagerService extends SystemService } } - void updateLowPowerModeLocked() { + private void updateLowPowerModeLocked() { if (mIsPowered && mLowPowerModeSetting) { if (DEBUG_SPEW) { Slog.d(TAG, "updateLowPowerModeLocked: powered, turning setting off"); @@ -2912,6 +2916,20 @@ public final class PowerManagerService extends SystemService return suspendBlocker; } + private void incrementBootCount() { + synchronized (mLock) { + int count; + try { + count = Settings.Global.getInt( + getContext().getContentResolver(), Settings.Global.BOOT_COUNT); + } catch (SettingNotFoundException e) { + count = 0; + } + Settings.Global.putInt( + getContext().getContentResolver(), Settings.Global.BOOT_COUNT, count + 1); + } + } + private static WorkSource copyWorkSource(WorkSource workSource) { return workSource != null ? new WorkSource(workSource) : null; } |