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

Commit dcbd0748 authored by Alex Johnston's avatar Alex Johnston Committed by Android (Google) Code Review
Browse files

Merge "Add assist content admin control" into main

parents 6041a507 c1ec858e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ package android {
    field public static final String MANAGE_DEVICE_POLICY_APPS_CONTROL = "android.permission.MANAGE_DEVICE_POLICY_APPS_CONTROL";
    field public static final String MANAGE_DEVICE_POLICY_APP_RESTRICTIONS = "android.permission.MANAGE_DEVICE_POLICY_APP_RESTRICTIONS";
    field public static final String MANAGE_DEVICE_POLICY_APP_USER_DATA = "android.permission.MANAGE_DEVICE_POLICY_APP_USER_DATA";
    field @FlaggedApi("android.app.admin.flags.assist_content_user_restriction_enabled") public static final String MANAGE_DEVICE_POLICY_ASSIST_CONTENT = "android.permission.MANAGE_DEVICE_POLICY_ASSIST_CONTENT";
    field public static final String MANAGE_DEVICE_POLICY_AUDIO_OUTPUT = "android.permission.MANAGE_DEVICE_POLICY_AUDIO_OUTPUT";
    field public static final String MANAGE_DEVICE_POLICY_AUTOFILL = "android.permission.MANAGE_DEVICE_POLICY_AUTOFILL";
    field public static final String MANAGE_DEVICE_POLICY_BACKUP_SERVICE = "android.permission.MANAGE_DEVICE_POLICY_BACKUP_SERVICE";
@@ -33880,6 +33881,7 @@ package android.os {
    field public static final String DISALLOW_AIRPLANE_MODE = "no_airplane_mode";
    field public static final String DISALLOW_AMBIENT_DISPLAY = "no_ambient_display";
    field public static final String DISALLOW_APPS_CONTROL = "no_control_apps";
    field @FlaggedApi("android.app.admin.flags.assist_content_user_restriction_enabled") public static final String DISALLOW_ASSIST_CONTENT = "no_assist_content";
    field public static final String DISALLOW_AUTOFILL = "no_autofill";
    field public static final String DISALLOW_BLUETOOTH = "no_bluetooth";
    field public static final String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing";
+21 −0
Original line number Diff line number Diff line
@@ -1954,6 +1954,26 @@ public class UserManager {
    public static final String DISALLOW_SIM_GLOBALLY =
            "no_sim_globally";

    /**
     * This user restriction specifies if assist content is disallowed from being sent to
     * a privileged app such as the Assistant app. Assist content includes screenshots and
     * information about an app, such as package name.
     *
     * <p>This restriction can only be set by a device owner or a profile owner. When it is set
     * by a device owner, it disables the assist contextual data on the entire device. When it is
     * set by a profile owner, it disables assist content on the profile.
     *
     * <p>Default is <code>false</code>.
     *
     * <p>Key for user restrictions.
     * <p>Type: Boolean
     * @see DevicePolicyManager#addUserRestriction(ComponentName, String)
     * @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
     * @see #getUserRestrictions()
     */
    @FlaggedApi(android.app.admin.flags.Flags.FLAG_ASSIST_CONTENT_USER_RESTRICTION_ENABLED)
    public static final String DISALLOW_ASSIST_CONTENT = "no_assist_content";

    /**
     * List of key values that can be passed into the various user restriction related methods
     * in {@link UserManager} & {@link DevicePolicyManager}.
@@ -2042,6 +2062,7 @@ public class UserManager {
            DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO,
            DISALLOW_THREAD_NETWORK,
            DISALLOW_SIM_GLOBALLY,
            DISALLOW_ASSIST_CONTENT,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface UserRestrictionKey {}
+7 −0
Original line number Diff line number Diff line
@@ -3618,6 +3618,13 @@
    <permission android:name="android.permission.MANAGE_DEVICE_POLICY_THREAD_NETWORK"
                android:protectionLevel="internal|role" />

    <!-- Allows an application to set policy related to sending assist content to a
        privileged app such as the Assistant app.
        @FlaggedApi("android.app.admin.flags.assist_content_user_restriction_enabled")
    -->
    <permission android:name="android.permission.MANAGE_DEVICE_POLICY_ASSIST_CONTENT"
        android:protectionLevel="internal|role" />

    <!-- Allows an application to set policy related to windows.
        <p>{@link Manifest.permission#MANAGE_DEVICE_POLICY_ACROSS_USERS_FULL} is
        required to call APIs protected by this permission on users different to the calling user.
+4 −2
Original line number Diff line number Diff line
@@ -154,7 +154,8 @@ public class UserRestrictionsUtils {
            UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,
            UserManager.DISALLOW_CONFIG_DEFAULT_APPS,
            UserManager.DISALLOW_NEAR_FIELD_COMMUNICATION_RADIO,
            UserManager.DISALLOW_SIM_GLOBALLY
            UserManager.DISALLOW_SIM_GLOBALLY,
            UserManager.DISALLOW_ASSIST_CONTENT
    });

    public static final Set<String> DEPRECATED_USER_RESTRICTIONS = Sets.newArraySet(
@@ -230,7 +231,8 @@ public class UserRestrictionsUtils {
            UserManager.DISALLOW_RUN_IN_BACKGROUND,
            UserManager.DISALLOW_UNMUTE_MICROPHONE,
            UserManager.DISALLOW_UNMUTE_DEVICE,
            UserManager.DISALLOW_CAMERA
            UserManager.DISALLOW_CAMERA,
            UserManager.DISALLOW_ASSIST_CONTENT
    );

    /**
+7 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ import static android.Manifest.permission.MANAGE_DEVICE_POLICY_THREAD_NETWORK;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_TIME;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_USB_DATA_SIGNALLING;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_USB_FILE_TRANSFER;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_ASSIST_CONTENT;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_VPN;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_WALLPAPER;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_WIFI;
@@ -230,6 +231,7 @@ import static android.app.admin.flags.Flags.backupServiceSecurityLogEventEnabled
import static android.app.admin.flags.Flags.dumpsysPolicyEngineMigrationEnabled;
import static android.app.admin.flags.Flags.headlessDeviceOwnerSingleUserEnabled;
import static android.app.admin.flags.Flags.policyEngineMigrationV2Enabled;
import static android.app.admin.flags.Flags.assistContentUserRestrictionEnabled;
import static android.content.Intent.ACTION_MANAGED_PROFILE_AVAILABLE;
import static android.content.Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
@@ -13374,6 +13376,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    UserManager.DISALLOW_THREAD_NETWORK,
                    new String[]{MANAGE_DEVICE_POLICY_THREAD_NETWORK});
        }
        if (assistContentUserRestrictionEnabled()) {
            USER_RESTRICTION_PERMISSIONS.put(
                    UserManager.DISALLOW_ASSIST_CONTENT,
                    new String[]{MANAGE_DEVICE_POLICY_ASSIST_CONTENT});
        }
        USER_RESTRICTION_PERMISSIONS.put(
                UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO, new String[]{MANAGE_DEVICE_POLICY_NEARBY_COMMUNICATION});
        USER_RESTRICTION_PERMISSIONS.put(
Loading