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

Commit 60403a35 authored by Tue Le's avatar Tue Le Committed by Android (Google) Code Review
Browse files

Merge "Add setCrossProfileWidgetProviders" into main

parents 2dfd0e66 6a789cc1
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -8277,6 +8277,7 @@ package android.app.admin {
    field public static final String BACKUP_SERVICE_POLICY = "backupService";
    field public static final String CAMERA_DISABLED_POLICY = "cameraDisabled";
    field @FlaggedApi("android.view.contentprotection.flags.manage_device_policy_enabled") public static final String CONTENT_PROTECTION_POLICY = "contentProtection";
    field @FlaggedApi("android.app.admin.flags.cross_profile_widget_provider_bulk_apis") public static final String CROSS_PROFILE_WIDGET_PROVIDER_POLICY = "crossProfileWidgetProvider";
    field public static final String KEYGUARD_DISABLED_FEATURES_POLICY = "keyguardDisabledFeatures";
    field public static final String LOCK_TASK_POLICY = "lockTask";
    field @FlaggedApi("android.app.admin.flags.set_mte_policy_coexistence") public static final String MEMORY_TAGGING_POLICY = "memoryTagging";
@@ -8295,7 +8296,7 @@ package android.app.admin {
  @RestrictedForEnvironment(environments=android.annotation.RestrictedForEnvironment.ENVIRONMENT_SDK_RUNTIME, from=android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class DevicePolicyManager {
    method public void acknowledgeDeviceCompliant();
    method @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional=true) public void addCrossProfileIntentFilter(@Nullable android.content.ComponentName, android.content.IntentFilter, int);
    method @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional=true) public boolean addCrossProfileWidgetProvider(@Nullable android.content.ComponentName, String);
    method @Deprecated @FlaggedApi("android.app.admin.flags.cross_profile_widget_provider_bulk_apis") @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional=true) public boolean addCrossProfileWidgetProvider(@Nullable android.content.ComponentName, String);
    method public int addOverrideApn(@NonNull android.content.ComponentName, @NonNull android.telephony.data.ApnSetting);
    method @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_LOCK_TASK, conditional=true) public void addPersistentPreferredActivity(@Nullable android.content.ComponentName, android.content.IntentFilter, @NonNull android.content.ComponentName);
    method public void addUserRestriction(@Nullable android.content.ComponentName, String);
@@ -8464,7 +8465,7 @@ package android.app.admin {
    method public int logoutUser(@NonNull android.content.ComponentName);
    method public void reboot(@NonNull android.content.ComponentName);
    method public void removeActiveAdmin(@NonNull android.content.ComponentName);
    method @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional=true) public boolean removeCrossProfileWidgetProvider(@Nullable android.content.ComponentName, String);
    method @Deprecated @FlaggedApi("android.app.admin.flags.cross_profile_widget_provider_bulk_apis") @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional=true) public boolean removeCrossProfileWidgetProvider(@Nullable android.content.ComponentName, String);
    method @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_CERTIFICATES, conditional=true) public boolean removeKeyPair(@Nullable android.content.ComponentName, @NonNull String);
    method public boolean removeOverrideApn(@NonNull android.content.ComponentName, int);
    method public boolean removeUser(@NonNull android.content.ComponentName, @NonNull android.os.UserHandle);
@@ -8501,6 +8502,7 @@ package android.app.admin {
    method @Deprecated public void setCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName, boolean);
    method @Deprecated public void setCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName, boolean);
    method public void setCrossProfilePackages(@NonNull android.content.ComponentName, @NonNull java.util.Set<java.lang.String>);
    method @FlaggedApi("android.app.admin.flags.cross_profile_widget_provider_bulk_apis") @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional=true) public void setCrossProfileWidgetProviders(@NonNull java.util.Set<java.lang.String>);
    method public void setDefaultDialerApplication(@NonNull String);
    method @RequiresPermission(value=android.Manifest.permission.MANAGE_DEVICE_POLICY_DEFAULT_SMS, conditional=true) public void setDefaultSmsApplication(@Nullable android.content.ComponentName, @NonNull String);
    method public void setDelegatedScopes(@NonNull android.content.ComponentName, @NonNull String, @NonNull java.util.List<java.lang.String>);
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app.admin;

import static android.app.admin.flags.Flags.FLAG_CROSS_PROFILE_WIDGET_PROVIDER_BULK_APIS;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.SystemApi;
@@ -170,9 +172,8 @@ public final class DevicePolicyIdentifiers {

    /**
     * String identifier for {@link DevicePolicyManager#addCrossProfileWidgetProvider}.
     *
     * @hide
     */
    @FlaggedApi(FLAG_CROSS_PROFILE_WIDGET_PROVIDER_BULK_APIS)
    public static final String CROSS_PROFILE_WIDGET_PROVIDER_POLICY = "crossProfileWidgetProvider";

    /**
+45 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import static android.annotation.RestrictedForEnvironment.ENVIRONMENT_SDK_RUNTIM
import static android.app.admin.DeviceAdminInfo.HEADLESS_DEVICE_OWNER_MODE_UNSUPPORTED;
import static android.app.admin.flags.Flags.FLAG_DEVICE_THEFT_API_ENABLED;
import static android.app.admin.flags.Flags.FLAG_REMOVE_MANAGED_PROFILE_ENABLED;
import static android.app.admin.flags.Flags.FLAG_CROSS_PROFILE_WIDGET_PROVIDER_BULK_APIS;
import static android.app.admin.flags.Flags.FLAG_SECONDARY_LOCKSCREEN_API_ENABLED;
import static android.app.admin.flags.Flags.FLAG_SPLIT_CREATE_MANAGED_PROFILE_ENABLED;
import static android.app.admin.flags.Flags.onboardingBugreportV2Enabled;
@@ -13889,8 +13890,12 @@ public class DevicePolicyManager {
     * permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILE_INTERACTION}.
     * @see #removeCrossProfileWidgetProvider(android.content.ComponentName, String)
     * @see #getCrossProfileWidgetProviders(android.content.ComponentName)
     * @deprecated While this API still works to mutate the current allowlist, please consider
     * switching to {@link #setCrossProfileWidgetProviders} for better performance.
     */
    @Deprecated
    @RequiresPermission(value = MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional = true)
    @FlaggedApi(FLAG_CROSS_PROFILE_WIDGET_PROVIDER_BULK_APIS)
    public boolean addCrossProfileWidgetProvider(@Nullable ComponentName admin,
            String packageName) {
        throwIfParentInstance("addCrossProfileWidgetProvider");
@@ -13905,6 +13910,42 @@ public class DevicePolicyManager {
        return false;
    }
    /**
     * Called by the profile owner of a managed profile or a holder of the permission
     * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILE_INTERACTION} to enable
     * widget providers from packages to be available in the parent profile. As a result the
     * user will be able to add widgets from the allowlisted package running under the profile to a
     * widget host which runs under the parent profile, for example the home screen. Note that a
     * package may have zero or more provider components, where each component provides a different
     * widget type.
     * <p>
     * <strong>Note:</strong> By default no widget provider package is allowlisted.
     *
     * <p>
     * <strong>Note:</strong> This API updates the entire allowlist in one-go, overriding any
     * previous allowlist. This is more efficient than using {@link #addCrossProfileWidgetProvider}
     * and {@link #removeCrossProfileWidgetProvider} to update the allowlist one package a time,
     * especially if the allowlist consists of many packages.
     *
     * @param packageNames The packages from which widget providers are allowlisted.
     * @throws SecurityException if {@code admin} is not a profile owner and not a holder of the
     * permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILE_INTERACTION}.
     * @see #getCrossProfileWidgetProviders(android.content.ComponentName)
     */
    @RequiresPermission(value = MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional = true)
    @FlaggedApi(FLAG_CROSS_PROFILE_WIDGET_PROVIDER_BULK_APIS)
    public void setCrossProfileWidgetProviders(@NonNull Set<String> packageNames) {
        throwIfParentInstance("addCrossProfileWidgetProviders");
        if (mService != null) {
            try {
                mService.setCrossProfileWidgetProviders(
                        mContext.getPackageName(), List.copyOf(packageNames));
            } catch (RemoteException re) {
                throw re.rethrowFromSystemServer();
            }
        }
    }
    /**
     * Called by the profile owner of a managed profile or a holder of the permission
     * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILE_INTERACTION} to disable
@@ -13922,8 +13963,12 @@ public class DevicePolicyManager {
     * permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILE_INTERACTION}.
     * @see #addCrossProfileWidgetProvider(android.content.ComponentName, String)
     * @see #getCrossProfileWidgetProviders(android.content.ComponentName)
     * @deprecated While this API still works to mutate the current allowlist, please consider
     * switching to {@link #setCrossProfileWidgetProviders} for better performance.
     */
    @Deprecated
    @RequiresPermission(value = MANAGE_DEVICE_POLICY_PROFILE_INTERACTION, conditional = true)
    @FlaggedApi(FLAG_CROSS_PROFILE_WIDGET_PROVIDER_BULK_APIS)
    public boolean removeCrossProfileWidgetProvider(@Nullable ComponentName admin,
            String packageName) {
        throwIfParentInstance("removeCrossProfileWidgetProvider");
+7 −0
Original line number Diff line number Diff line
@@ -80,6 +80,13 @@ public abstract class DevicePolicyManagerInternal {
    public abstract void addOnCrossProfileWidgetProvidersChangeListener(
            OnCrossProfileWidgetProvidersChangeListener listener);

    /**
     * Notifies the listeners that the cross profile widget provider list has changed.
     *
     * Should only be called by {@link com.android.server.devicepolicy.PolicyEnforcerCallbacks}.
     */
    public abstract void notifyCrossProfileProvidersChanged(int userId, List<String> packages);

    /**
     * @param userHandle the handle of the user whose profile owner is being fetched.
     * @return the configured supervision app if it exists and is the device owner or policy owner.
+2 −0
Original line number Diff line number Diff line
@@ -371,6 +371,8 @@ interface IDevicePolicyManager {
            in ComponentName agent, int userId, boolean parent);

    boolean addCrossProfileWidgetProvider(in ComponentName admin, String callerPackageName, String packageName);
    void setCrossProfileWidgetProviders(String callerPackageName, in List<String> packageNames);

    boolean removeCrossProfileWidgetProvider(in ComponentName admin, String callerPackageName, String packageName);
    List<String> getCrossProfileWidgetProviders(in ComponentName admin, String callerPackageName);

Loading