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

Commit 9cc7ea55 authored by Coco Duan's avatar Coco Duan
Browse files

Allow disabling keyguard widgets for work profile

Add the flag `KEYGUARD_DISABLE_WIDGETS_ALL` to the flag mask to allow
it to be always set on the profile, as well as on the parent profile
of a COPE device.
This will provide flexibility for DPM to control keyguard widgets on
work profile separately.

Bug: b/332590662
Test: toggle the setting in TestDPC and run command to verify
`adb shell dumpsys device_policy | grep disabledKeyguardFeatures`
Flag: N/A

Change-Id: I198371b6a5139393cc98b41148831b3b813c031d
parent d08d92ee
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -7055,9 +7055,10 @@ public class DevicePolicyManager {
    public static final int KEYGUARD_DISABLE_FEATURES_NONE = 0;
    /**
     * Disable all keyguard widgets. Has no effect starting from
     * {@link android.os.Build.VERSION_CODES#LOLLIPOP} since keyguard widget is only supported
     * on Android versions lower than 5.0.
     * Disable all keyguard widgets. Has no effect between {@link
     * android.os.Build.VERSION_CODES#LOLLIPOP} and {@link
     * android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE} (both inclusive), since keyguard widget is
     * only supported on Android versions lower than 5.0 and versions higher than 14.
     */
    public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 1 << 0;
@@ -7156,7 +7157,8 @@ public class DevicePolicyManager {
    public static final int ORG_OWNED_PROFILE_KEYGUARD_FEATURES_PARENT_ONLY =
            DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA
                    | DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
                    | DevicePolicyManager.KEYGUARD_DISABLE_SHORTCUTS_ALL;
                    | DevicePolicyManager.KEYGUARD_DISABLE_SHORTCUTS_ALL
                    | DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_ALL;
    /**
     * Keyguard features that when set on a normal or organization-owned managed profile, have
@@ -8977,6 +8979,10 @@ public class DevicePolicyManager {
     * by applications in the managed profile.
     * </ul>
     * <p>
     * From version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM}, the profile owner of a
     * managed profile can also set {@link #KEYGUARD_DISABLE_WIDGETS_ALL} which disables keyguard
     * widgets for the managed profile.
     * <p>
     * From version {@link android.os.Build.VERSION_CODES#R} the profile owner of an
     * organization-owned managed profile can set:
     * <ul>
@@ -8985,6 +8991,12 @@ public class DevicePolicyManager {
     * <li>{@link #KEYGUARD_DISABLE_SECURE_NOTIFICATIONS} which affects the parent user when called
     * on the parent profile.
     * </ul>
     * Starting from version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} the profile
     * owner of an organization-owned managed profile can set:
     * <ul>
     * <li>{@link #KEYGUARD_DISABLE_WIDGETS_ALL} which affects the parent user when called on the
     * parent profile.
     * </ul>
     * {@link #KEYGUARD_DISABLE_TRUST_AGENTS}, {@link #KEYGUARD_DISABLE_FINGERPRINT},
     * {@link #KEYGUARD_DISABLE_FACE}, {@link #KEYGUARD_DISABLE_IRIS},
     * {@link #KEYGUARD_DISABLE_SECURE_CAMERA} and {@link #KEYGUARD_DISABLE_SECURE_NOTIFICATIONS}
+2 −1
Original line number Diff line number Diff line
@@ -742,7 +742,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
     * These cannot be set on the managed profile's parent DPM instance
     */
    private static final int PROFILE_KEYGUARD_FEATURES_PROFILE_ONLY =
            DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
            DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS
                    | DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_ALL;
    /** Keyguard features that are allowed to be set on a managed profile */
    private static final int PROFILE_KEYGUARD_FEATURES =