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

Commit b1442277 authored by Neil Fuller's avatar Neil Fuller
Browse files

Add support for time zone notifications

Add support for time zone notifications to RulesManagerService.

This change adds new intents that are broadcast after
a time zone rules update is staged / unstaged. This will allow
another component on the device to handle notifications telling
the user to restart the device.

Bug: 69443060
Test: atest FrameworksServicesTests
Test: Manual install
Change-Id: I4fc4b5715380d84d87cdb43c05aee2f8f9c5d277
parent f85d9162
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -68,6 +68,23 @@ public final class RulesManager {
    private static final String TAG = "timezone.RulesManager";
    private static final boolean DEBUG = false;

    /**
     * The action of the intent that the Android system will broadcast when a time zone rules update
     * operation has been successfully staged  (i.e. to be applied next reboot) or unstaged.
     *
     * <p>See {@link #EXTRA_OPERATION_STAGED}
     *
     * <p>This is a protected intent that can only be sent by the system.
     */
    public static final String ACTION_RULES_UPDATE_OPERATION =
            "com.android.intent.action.timezone.RULES_UPDATE_OPERATION";

    /**
     * The key for a boolean extra for the {@link #ACTION_RULES_UPDATE_OPERATION} intent used to
     * indicate whether the operation was a "stage" or an "unstage".
     */
    public static final String EXTRA_OPERATION_STAGED = "staged";

    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = { "SUCCESS", "ERROR_" }, value = {
            SUCCESS,
+4 −0
Original line number Diff line number Diff line
@@ -571,6 +571,10 @@
    <protected-broadcast android:name="android.media.tv.action.CHANNEL_BROWSABLE_REQUESTED" />
    <protected-broadcast android:name="com.android.server.InputMethodManagerService.SHOW_INPUT_METHOD_PICKER" />

    <!-- Time zone rules update intents fired by the system server -->
    <protected-broadcast android:name="com.android.intent.action.timezone.RULES_UPDATE_OPERATION" />
    <protected-broadcast android:name="com.android.intent.action.timezone.TRIGGER_RULES_UPDATE_CHECK" />

    <!-- Made protected in P (was introduced in JB-MR2) -->
    <protected-broadcast android:name="android.intent.action.GET_RESTRICTION_ENTRIES" />
    <protected-broadcast android:name="android.telephony.euicc.action.OTA_STATUS_CHANGED" />
+3 −3
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class PackageTracker {
    private static final String TAG = "timezone.PackageTracker";

    private final PackageManagerHelper mPackageManagerHelper;
    private final IntentHelper mIntentHelper;
    private final PackageTrackerIntentHelper mIntentHelper;
    private final ConfigHelper mConfigHelper;
    private final PackageStatusStorage mPackageStatusStorage;
    private final Clock mElapsedRealtimeClock;
@@ -103,13 +103,13 @@ public class PackageTracker {
                helperImpl /* configHelper */,
                helperImpl /* packageManagerHelper */,
                new PackageStatusStorage(storageDir),
                new IntentHelperImpl(context));
                new PackageTrackerIntentHelperImpl(context));
    }

    // A constructor that can be used by tests to supply mocked / faked dependencies.
    PackageTracker(Clock elapsedRealtimeClock, ConfigHelper configHelper,
            PackageManagerHelper packageManagerHelper, PackageStatusStorage packageStatusStorage,
            IntentHelper intentHelper) {
            PackageTrackerIntentHelper intentHelper) {
        mElapsedRealtimeClock = elapsedRealtimeClock;
        mConfigHelper = configHelper;
        mPackageManagerHelper = packageManagerHelper;
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ package com.android.server.timezone;
 * it is not possible to test various cases with the real one because of the need to simulate
 * receiving and broadcasting intents.
 */
interface IntentHelper {
interface PackageTrackerIntentHelper {

    void initialize(String updateAppPackageName, String dataAppPackageName,
            PackageTracker packageTracker);
+4 −4
Original line number Diff line number Diff line
@@ -28,16 +28,16 @@ import android.os.UserHandle;
import android.util.Slog;

/**
 * The bona fide implementation of {@link IntentHelper}.
 * The bona fide implementation of {@link PackageTrackerIntentHelper}.
 */
final class IntentHelperImpl implements IntentHelper {
final class PackageTrackerIntentHelperImpl implements PackageTrackerIntentHelper {

    private final static String TAG = "timezone.IntentHelperImpl";
    private final static String TAG = "timezone.PackageTrackerIntentHelperImpl";

    private final Context mContext;
    private String mUpdaterAppPackageName;

    IntentHelperImpl(Context context) {
    PackageTrackerIntentHelperImpl(Context context) {
        mContext = context;
    }

Loading