Merge "Adding a shell command to AlarmManager" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cebea4ced8
@@ -42,4 +42,5 @@ interface IAlarmManager {
|
|||||||
AlarmManager.AlarmClockInfo getNextAlarmClock(int userId);
|
AlarmManager.AlarmClockInfo getNextAlarmClock(int userId);
|
||||||
long currentNetworkTimeMillis();
|
long currentNetworkTimeMillis();
|
||||||
boolean canScheduleExactAlarms();
|
boolean canScheduleExactAlarms();
|
||||||
|
int getConfigVersion();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -538,6 +538,7 @@ public class AlarmManagerService extends SystemService {
|
|||||||
public long PRIORITY_ALARM_DELAY = DEFAULT_PRIORITY_ALARM_DELAY;
|
public long PRIORITY_ALARM_DELAY = DEFAULT_PRIORITY_ALARM_DELAY;
|
||||||
|
|
||||||
private long mLastAllowWhileIdleWhitelistDuration = -1;
|
private long mLastAllowWhileIdleWhitelistDuration = -1;
|
||||||
|
private int mVersion = 0;
|
||||||
|
|
||||||
Constants() {
|
Constants() {
|
||||||
updateAllowWhileIdleWhitelistDurationLocked();
|
updateAllowWhileIdleWhitelistDurationLocked();
|
||||||
@@ -546,6 +547,12 @@ public class AlarmManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getVersion() {
|
||||||
|
synchronized (mLock) {
|
||||||
|
return mVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
mInjector.registerDeviceConfigListener(this);
|
mInjector.registerDeviceConfigListener(this);
|
||||||
onPropertiesChanged(DeviceConfig.getProperties(DeviceConfig.NAMESPACE_ALARM_MANAGER));
|
onPropertiesChanged(DeviceConfig.getProperties(DeviceConfig.NAMESPACE_ALARM_MANAGER));
|
||||||
@@ -568,6 +575,7 @@ public class AlarmManagerService extends SystemService {
|
|||||||
public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
|
public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
|
||||||
boolean standbyQuotaUpdated = false;
|
boolean standbyQuotaUpdated = false;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
mVersion++;
|
||||||
for (String name : properties.getKeyset()) {
|
for (String name : properties.getKeyset()) {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -749,6 +757,9 @@ public class AlarmManagerService extends SystemService {
|
|||||||
|
|
||||||
pw.increaseIndent();
|
pw.increaseIndent();
|
||||||
|
|
||||||
|
pw.print("version", mVersion);
|
||||||
|
pw.println();
|
||||||
|
|
||||||
pw.print(KEY_MIN_FUTURITY);
|
pw.print(KEY_MIN_FUTURITY);
|
||||||
pw.print("=");
|
pw.print("=");
|
||||||
TimeUtils.formatDuration(MIN_FUTURITY, pw);
|
TimeUtils.formatDuration(MIN_FUTURITY, pw);
|
||||||
@@ -2218,6 +2229,13 @@ public class AlarmManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getConfigVersion() {
|
||||||
|
getContext().enforceCallingOrSelfPermission(Manifest.permission.DUMP,
|
||||||
|
"getConfigVersion");
|
||||||
|
return mConstants.getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
if (!DumpUtils.checkDumpAndUsageStatsPermission(getContext(), TAG, pw)) return;
|
if (!DumpUtils.checkDumpAndUsageStatsPermission(getContext(), TAG, pw)) return;
|
||||||
@@ -4698,6 +4716,10 @@ public class AlarmManagerService extends SystemService {
|
|||||||
final String tz = getNextArgRequired();
|
final String tz = getNextArgRequired();
|
||||||
getBinderService().setTimeZone(tz);
|
getBinderService().setTimeZone(tz);
|
||||||
return 0;
|
return 0;
|
||||||
|
case "get-config-version":
|
||||||
|
final int version = getBinderService().getConfigVersion();
|
||||||
|
pw.println(version);
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
return handleDefaultCommands(cmd);
|
return handleDefaultCommands(cmd);
|
||||||
}
|
}
|
||||||
@@ -4718,6 +4740,10 @@ public class AlarmManagerService extends SystemService {
|
|||||||
pw.println(" since the Epoch.");
|
pw.println(" since the Epoch.");
|
||||||
pw.println(" set-timezone TZ");
|
pw.println(" set-timezone TZ");
|
||||||
pw.println(" Set the system timezone to TZ where TZ is an Olson id.");
|
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user