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

Commit 18337650 authored by kholoud mohamed's avatar kholoud mohamed
Browse files

Add a new broadcast to notify when dpm constants change

Added a new hidden broadcast DEVICE_POLICY_CONSTANTS_CHANGED
to notify tests that a value in DEVICE_POLICY_CONSTANTS has changed.
This will replace the current polling/sleep mechanism in the tests
that change it.

Bug: 176463102
Bug: 180500227
Test: confirmed that tests can receive this broadcast.
Change-Id: I430596b1da446af3b62269596a0f7e025c92a968
parent f48c8fc6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -398,6 +398,7 @@ package android.app.admin {
    method @RequiresPermission("android.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS") public void resetDefaultCrossProfileIntentFilters(int);
    method @RequiresPermission("android.permission.MANAGE_DEVICE_ADMINS") public void setNextOperationSafety(int, int);
    field public static final String ACTION_DATA_SHARING_RESTRICTION_APPLIED = "android.app.action.DATA_SHARING_RESTRICTION_APPLIED";
    field public static final String ACTION_DEVICE_POLICY_CONSTANTS_CHANGED = "android.app.action.DEVICE_POLICY_CONSTANTS_CHANGED";
    field public static final int CODE_ACCOUNTS_NOT_EMPTY = 6; // 0x6
    field public static final int CODE_CANNOT_ADD_MANAGED_PROFILE = 11; // 0xb
    field public static final int CODE_DEVICE_ADMIN_NOT_SUPPORTED = 13; // 0xd
+10 −0
Original line number Diff line number Diff line
@@ -1764,6 +1764,16 @@ public class DevicePolicyManager {
    public static final String ACTION_DATA_SHARING_RESTRICTION_APPLIED =
            "android.app.action.DATA_SHARING_RESTRICTION_APPLIED";
    /**
     * Broadcast action: notify that a value of {@link Settings.Global#DEVICE_POLICY_CONSTANTS}
     * has been changed.
     * @hide
     */
    @TestApi
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_DEVICE_POLICY_CONSTANTS_CHANGED =
            "android.app.action.DEVICE_POLICY_CONSTANTS_CHANGED";
    /**
     * Permission policy to prompt user for new permission requests for runtime permissions.
     * Already granted or denied permissions are not affected by this.
+1 −0
Original line number Diff line number Diff line
@@ -692,6 +692,7 @@

    <!-- Added in S -->
    <protected-broadcast android:name="android.intent.action.REBOOT_READY" />
    <protected-broadcast android:name="android.app.action.DEVICE_POLICY_CONSTANTS_CHANGED" />

    <!-- ====================================================================== -->
    <!--                          RUNTIME PERMISSIONS                           -->
+10 −0
Original line number Diff line number Diff line
@@ -11908,6 +11908,16 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        @Override
        public void onChange(boolean selfChange, Uri uri, int userId) {
            mConstants = loadConstants();
            mInjector.binderWithCleanCallingIdentity(() -> {
                final Intent intent = new Intent(
                        DevicePolicyManager.ACTION_DEVICE_POLICY_CONSTANTS_CHANGED);
                intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
                final List<UserInfo> users = mUserManager.getAliveUsers();
                for (int i = 0; i < users.size(); i++) {
                    mContext.sendBroadcastAsUser(intent, UserHandle.of(users.get(i).id));
                }
            });
        }
    }