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

Commit ab57e18d authored by Charles He's avatar Charles He Committed by Android (Google) Code Review
Browse files

Merge "DPM: introduce setLockTaskFeatures()."

parents 5b11eec5 e078db75
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -6328,6 +6328,7 @@ package android.app.admin {
    method public java.lang.CharSequence getDeviceOwnerLockScreenInfo();
    method public java.util.List<byte[]> getInstalledCaCerts(android.content.ComponentName);
    method public int getKeyguardDisabledFeatures(android.content.ComponentName);
    method public int getLockTaskFeatures(android.content.ComponentName);
    method public java.lang.String[] getLockTaskPackages(android.content.ComponentName);
    method public java.lang.CharSequence getLongSupportMessage(android.content.ComponentName);
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
@@ -6414,6 +6415,7 @@ package android.app.admin {
    method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
    method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
    method public void setLockTaskFeatures(android.content.ComponentName, int);
    method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
    method public void setLongSupportMessage(android.content.ComponentName, java.lang.CharSequence);
    method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
@@ -6530,6 +6532,13 @@ package android.app.admin {
    field public static final int KEYGUARD_DISABLE_TRUST_AGENTS = 16; // 0x10
    field public static final int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS = 8; // 0x8
    field public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 1; // 0x1
    field public static final int LOCK_TASK_FEATURE_GLOBAL_ACTIONS = 16; // 0x10
    field public static final int LOCK_TASK_FEATURE_HOME = 4; // 0x4
    field public static final int LOCK_TASK_FEATURE_KEYGUARD = 32; // 0x20
    field public static final int LOCK_TASK_FEATURE_NONE = 0; // 0x0
    field public static final int LOCK_TASK_FEATURE_NOTIFICATIONS = 2; // 0x2
    field public static final int LOCK_TASK_FEATURE_RECENTS = 8; // 0x8
    field public static final int LOCK_TASK_FEATURE_SYSTEM_INFO = 1; // 0x1
    field public static final java.lang.String MIME_TYPE_PROVISIONING_NFC = "application/com.android.managedprovisioning";
    field public static final int PASSWORD_QUALITY_ALPHABETIC = 262144; // 0x40000
    field public static final int PASSWORD_QUALITY_ALPHANUMERIC = 327680; // 0x50000
+9 −0
Original line number Diff line number Diff line
@@ -6550,6 +6550,7 @@ package android.app.admin {
    method public java.lang.CharSequence getDeviceOwnerOrganizationName();
    method public java.util.List<byte[]> getInstalledCaCerts(android.content.ComponentName);
    method public int getKeyguardDisabledFeatures(android.content.ComponentName);
    method public int getLockTaskFeatures(android.content.ComponentName);
    method public java.lang.String[] getLockTaskPackages(android.content.ComponentName);
    method public java.lang.CharSequence getLongSupportMessage(android.content.ComponentName);
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
@@ -6649,6 +6650,7 @@ package android.app.admin {
    method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
    method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
    method public void setLockTaskFeatures(android.content.ComponentName, int);
    method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
    method public void setLongSupportMessage(android.content.ComponentName, java.lang.CharSequence);
    method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
@@ -6776,6 +6778,13 @@ package android.app.admin {
    field public static final int KEYGUARD_DISABLE_TRUST_AGENTS = 16; // 0x10
    field public static final int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS = 8; // 0x8
    field public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 1; // 0x1
    field public static final int LOCK_TASK_FEATURE_GLOBAL_ACTIONS = 16; // 0x10
    field public static final int LOCK_TASK_FEATURE_HOME = 4; // 0x4
    field public static final int LOCK_TASK_FEATURE_KEYGUARD = 32; // 0x20
    field public static final int LOCK_TASK_FEATURE_NONE = 0; // 0x0
    field public static final int LOCK_TASK_FEATURE_NOTIFICATIONS = 2; // 0x2
    field public static final int LOCK_TASK_FEATURE_RECENTS = 8; // 0x8
    field public static final int LOCK_TASK_FEATURE_SYSTEM_INFO = 1; // 0x1
    field public static final java.lang.String MIME_TYPE_PROVISIONING_NFC = "application/com.android.managedprovisioning";
    field public static final int PASSWORD_QUALITY_ALPHABETIC = 262144; // 0x40000
    field public static final int PASSWORD_QUALITY_ALPHANUMERIC = 327680; // 0x50000
+9 −0
Original line number Diff line number Diff line
@@ -6393,6 +6393,7 @@ package android.app.admin {
    method public long getLastBugReportRequestTime();
    method public long getLastNetworkLogRetrievalTime();
    method public long getLastSecurityLogRetrievalTime();
    method public int getLockTaskFeatures(android.content.ComponentName);
    method public java.lang.String[] getLockTaskPackages(android.content.ComponentName);
    method public java.lang.CharSequence getLongSupportMessage(android.content.ComponentName);
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
@@ -6482,6 +6483,7 @@ package android.app.admin {
    method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
    method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
    method public void setLockTaskFeatures(android.content.ComponentName, int);
    method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
    method public void setLongSupportMessage(android.content.ComponentName, java.lang.CharSequence);
    method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
@@ -6601,6 +6603,13 @@ package android.app.admin {
    field public static final int KEYGUARD_DISABLE_TRUST_AGENTS = 16; // 0x10
    field public static final int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS = 8; // 0x8
    field public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 1; // 0x1
    field public static final int LOCK_TASK_FEATURE_GLOBAL_ACTIONS = 16; // 0x10
    field public static final int LOCK_TASK_FEATURE_HOME = 4; // 0x4
    field public static final int LOCK_TASK_FEATURE_KEYGUARD = 32; // 0x20
    field public static final int LOCK_TASK_FEATURE_NONE = 0; // 0x0
    field public static final int LOCK_TASK_FEATURE_NOTIFICATIONS = 2; // 0x2
    field public static final int LOCK_TASK_FEATURE_RECENTS = 8; // 0x8
    field public static final int LOCK_TASK_FEATURE_SYSTEM_INFO = 1; // 0x1
    field public static final java.lang.String MIME_TYPE_PROVISIONING_NFC = "application/com.android.managedprovisioning";
    field public static final int PASSWORD_QUALITY_ALPHABETIC = 262144; // 0x40000
    field public static final int PASSWORD_QUALITY_ALPHANUMERIC = 327680; // 0x50000
+4 −1
Original line number Diff line number Diff line
@@ -656,6 +656,9 @@ interface IActivityManager {
     */
    void backgroundWhitelistUid(int uid);

    // Start of P transactions
    void updateLockTaskFeatures(int userId, int flags);

    // WARNING: when these transactions are updated, check if they are any callers on the native
    // side. If so, make sure they are using the correct transaction ids and arguments.
    // If a transaction which will also be used on the native side is being inserted, add it
+147 −0
Original line number Diff line number Diff line
@@ -1541,6 +1541,92 @@ public class DevicePolicyManager {
            CODE_SPLIT_SYSTEM_USER_DEVICE_SYSTEM_USER, CODE_ADD_MANAGED_PROFILE_DISALLOWED})
    public @interface ProvisioningPreCondition {}

    /**
     * Disable all configurable SystemUI features during LockTask mode. This includes,
     * <ul>
     *     <li>system info area in the status bar (connectivity icons, clock, etc.)
     *     <li>notifications (including alerts, icons, and the notification shade)
     *     <li>Home button
     *     <li>Recents button and UI
     *     <li>global actions menu (i.e. power button menu)
     *     <li>keyguard
     * </ul>
     *
     * This is the default configuration for LockTask.
     *
     * @see #setLockTaskFeatures(ComponentName, int)
     */
    public static final int LOCK_TASK_FEATURE_NONE = 0;

    /**
     * Enable the system info area in the status bar during LockTask mode. The system info area
     * usually occupies the right side of the status bar (although this can differ across OEMs). It
     * includes all system information indicators, such as date and time, connectivity, battery,
     * vibration mode, etc.
     *
     * @see #setLockTaskFeatures(ComponentName, int)
     */
    public static final int LOCK_TASK_FEATURE_SYSTEM_INFO = 1;

    /**
     * Enable notifications during LockTask mode. This includes notification icons on the status
     * bar, heads-up notifications, and the expandable notification shade. Note that the Quick
     * Settings panel will still be disabled.
     *
     * @see #setLockTaskFeatures(ComponentName, int)
     */
    public static final int LOCK_TASK_FEATURE_NOTIFICATIONS = 1 << 1;

    /**
     * Enable the Home button during LockTask mode. Note that if a custom launcher is used, it has
     * to be registered as the default launcher with
     * {@link #addPersistentPreferredActivity(ComponentName, IntentFilter, ComponentName)}, and its
     * package needs to be whitelisted for LockTask with
     * {@link #setLockTaskPackages(ComponentName, String[])}.
     *
     * @see #setLockTaskFeatures(ComponentName, int)
     */
    public static final int LOCK_TASK_FEATURE_HOME = 1 << 2;

    /**
     * Enable the Recents button and the Recents screen during LockTask mode.
     *
     * @see #setLockTaskFeatures(ComponentName, int)
     */
    public static final int LOCK_TASK_FEATURE_RECENTS = 1 << 3;

    /**
     * Enable the global actions dialog during LockTask mode. This is the dialog that shows up when
     * the user long-presses the power button, for example. Note that the user may not be able to
     * power off the device if this flag is not set.
     *
     * @see #setLockTaskFeatures(ComponentName, int)
     */
    public static final int LOCK_TASK_FEATURE_GLOBAL_ACTIONS = 1 << 4;

    /**
     * Enable the keyguard during LockTask mode. Note that if the keyguard is already disabled with
     * {@link #setKeyguardDisabled(ComponentName, boolean)}, setting this flag will have no effect.
     * If this flag is not set, the keyguard will not be shown even if the user has a lock screen
     * credential.
     *
     * @see #setLockTaskFeatures(ComponentName, int)
     */
    public static final int LOCK_TASK_FEATURE_KEYGUARD = 1 << 5;

    /**
     * Flags supplied to {@link #setLockTaskFeatures(ComponentName, int)}.
     *
     * @hide
     */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(flag = true,
            value = {LOCK_TASK_FEATURE_NONE, LOCK_TASK_FEATURE_SYSTEM_INFO,
                    LOCK_TASK_FEATURE_NOTIFICATIONS, LOCK_TASK_FEATURE_HOME,
                    LOCK_TASK_FEATURE_RECENTS, LOCK_TASK_FEATURE_GLOBAL_ACTIONS,
                    LOCK_TASK_FEATURE_KEYGUARD})
    public @interface LockTaskFeature {}

    /**
     * Service action: Action for a service that device owner and profile owner can optionally
     * own.  If a device owner or a profile owner has such a service, the system tries to keep
@@ -6483,6 +6569,61 @@ public class DevicePolicyManager {
        return false;
    }

    /**
     * Sets which system features to enable for LockTask mode.
     * <p>
     * Feature flags set through this method will only take effect for the duration when the device
     * is in LockTask mode. If this method is not called, none of the features listed here will be
     * enabled.
     * <p>
     * This function can only be called by the device owner or by a profile owner of a user/profile
     * that is affiliated with the device owner user. See {@link #setAffiliationIds}. Any features
     * set via this method will be cleared if the user becomes unaffiliated.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param flags Bitfield of feature flags:
     *              {@link #LOCK_TASK_FEATURE_NONE} (default),
     *              {@link #LOCK_TASK_FEATURE_SYSTEM_INFO},
     *              {@link #LOCK_TASK_FEATURE_NOTIFICATIONS},
     *              {@link #LOCK_TASK_FEATURE_HOME},
     *              {@link #LOCK_TASK_FEATURE_RECENTS},
     *              {@link #LOCK_TASK_FEATURE_GLOBAL_ACTIONS},
     *              {@link #LOCK_TASK_FEATURE_KEYGUARD}
     * @throws SecurityException if {@code admin} is not the device owner, or the profile owner of
     * an affiliated user or profile.
     */
    public void setLockTaskFeatures(@NonNull ComponentName admin, @LockTaskFeature int flags) {
        throwIfParentInstance("setLockTaskFeatures");
        if (mService != null) {
            try {
                mService.setLockTaskFeatures(admin, flags);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }

    /**
     * Gets which system features are enabled for LockTask mode.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @return bitfield of flags. See {@link #setLockTaskFeatures(ComponentName, int)} for a list.
     * @throws SecurityException if {@code admin} is not the device owner, or the profile owner of
     * an affiliated user or profile.
     * @see #setLockTaskFeatures(ComponentName, int)
     */
    public @LockTaskFeature int getLockTaskFeatures(@NonNull ComponentName admin) {
        throwIfParentInstance("getLockTaskFeatures");
        if (mService != null) {
            try {
                return mService.getLockTaskFeatures(admin);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return 0;
    }

    /**
     * Called by device owners to update {@link android.provider.Settings.Global} settings.
     * Validation that the value of the setting is in the correct form for the setting type should
@@ -6901,6 +7042,12 @@ public class DevicePolicyManager {
     * Called by device owner to disable the status bar. Disabling the status bar blocks
     * notifications, quick settings and other screen overlays that allow escaping from a single use
     * device.
     * <p>
     * <strong>Note:</strong> This method has no effect for LockTask mode. The behavior of the
     * status bar in LockTask mode can be configured with
     * {@link #setLockTaskFeatures(ComponentName, int)}. Calls to this method when the device is in
     * LockTask mode will be registered, but will only take effect when the device leaves LockTask
     * mode.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param disabled {@code true} disables the status bar, {@code false} reenables it.
Loading