Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cebea4ce authored by Suprabh Shukla's avatar Suprabh Shukla Committed by Android (Google) Code Review
Browse files

Merge "Adding a shell command to AlarmManager" into sc-dev

parents 3d8971e4 98b41398
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -42,4 +42,5 @@ interface IAlarmManager {
    AlarmManager.AlarmClockInfo getNextAlarmClock(int userId);
    long currentNetworkTimeMillis();
    boolean canScheduleExactAlarms();
    int getConfigVersion();
}
+26 −0
Original line number Diff line number Diff line
@@ -538,6 +538,7 @@ public class AlarmManagerService extends SystemService {
        public long PRIORITY_ALARM_DELAY = DEFAULT_PRIORITY_ALARM_DELAY;

        private long mLastAllowWhileIdleWhitelistDuration = -1;
        private int mVersion = 0;

        Constants() {
            updateAllowWhileIdleWhitelistDurationLocked();
@@ -546,6 +547,12 @@ public class AlarmManagerService extends SystemService {
            }
        }

        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 class AlarmManagerService extends SystemService {
        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 @@ public class AlarmManagerService extends SystemService {

            pw.increaseIndent();

            pw.print("version", mVersion);
            pw.println();

            pw.print(KEY_MIN_FUTURITY);
            pw.print("=");
            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
        protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            if (!DumpUtils.checkDumpAndUsageStatsPermission(getContext(), TAG, pw)) return;
@@ -4698,6 +4716,10 @@ public class AlarmManagerService extends SystemService {
                        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 @@ public class AlarmManagerService extends SystemService {
            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.");
        }
    }
}