Merge "Add a new key to Settings.Global to obtain the number of boot." into nyc-dev

am: d517e6aeed

* commit 'd517e6aeed993cb5467e2997c1ab2edd90bbc133':
  Add a new key to Settings.Global to obtain the number of boot.
This commit is contained in:
Daichi Hirono
2016-03-08 02:14:19 +00:00
committed by android-build-merger
5 changed files with 29 additions and 1 deletions

View File

@@ -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";

View File

@@ -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";

View File

@@ -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";

View File

@@ -8281,6 +8281,13 @@ public final class Settings {
public static final String ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED =
"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.

View File

@@ -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;
}