Merge "Adding a shell command to AlarmManager" into sc-dev
diff --git a/apex/jobscheduler/framework/java/android/app/IAlarmManager.aidl b/apex/jobscheduler/framework/java/android/app/IAlarmManager.aidl
index 2f21ce3..a10cbbe 100644
--- a/apex/jobscheduler/framework/java/android/app/IAlarmManager.aidl
+++ b/apex/jobscheduler/framework/java/android/app/IAlarmManager.aidl
@@ -42,4 +42,5 @@
AlarmManager.AlarmClockInfo getNextAlarmClock(int userId);
long currentNetworkTimeMillis();
boolean canScheduleExactAlarms();
+ int getConfigVersion();
}
diff --git a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
index 901daa7..08e1a95 100644
--- a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
@@ -538,6 +538,7 @@
public long PRIORITY_ALARM_DELAY = DEFAULT_PRIORITY_ALARM_DELAY;
private long mLastAllowWhileIdleWhitelistDuration = -1;
+ private int mVersion = 0;
Constants() {
updateAllowWhileIdleWhitelistDurationLocked();
@@ -546,6 +547,12 @@
}
}
+ public int getVersion() {
+ synchronized (mLock) {
+ return mVersion;
+ }
+ }
+
public void start() {
mInjector.registerDeviceConfigListener(this);
onPropertiesChanged(DeviceConfig.getProperties(DeviceConfig.NAMESPACE_ALARM_MANAGER));
@@ -568,6 +575,7 @@
public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
boolean standbyQuotaUpdated = false;
synchronized (mLock) {
+ mVersion++;
for (String name : properties.getKeyset()) {
if (name == null) {
continue;
@@ -749,6 +757,9 @@
pw.increaseIndent();
+ pw.print("version", mVersion);
+ pw.println();
+
pw.print(KEY_MIN_FUTURITY);
pw.print("=");
TimeUtils.formatDuration(MIN_FUTURITY, pw);
@@ -2219,6 +2230,13 @@
}
@Override
+ public int getConfigVersion() {
+ getContext().enforceCallingOrSelfPermission(Manifest.permission.DUMP,
+ "getConfigVersion");
+ return mConstants.getVersion();
+ }
+
+ @Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (!DumpUtils.checkDumpAndUsageStatsPermission(getContext(), TAG, pw)) return;
@@ -4698,6 +4716,10 @@
final String tz = getNextArgRequired();
getBinderService().setTimeZone(tz);
return 0;
+ case "get-config-version":
+ final int version = getBinderService().getConfigVersion();
+ pw.println(version);
+ return 0;
default:
return handleDefaultCommands(cmd);
}
@@ -4718,6 +4740,10 @@
pw.println(" since the Epoch.");
pw.println(" set-timezone TZ");
pw.println(" Set the system timezone to TZ where TZ is an Olson id.");
+ pw.println(" get-config-version");
+ pw.println(" Returns an integer denoting the version of device_config keys the"
+ + " service is sync'ed to. As long as this returns the same version, the values"
+ + " of the config are guaranteed to remain the same.");
}
}
}