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

Commit bcb678b9 authored by Jonathan Scott's avatar Jonathan Scott Committed by Android (Google) Code Review
Browse files

Merge changes from topic "docheckfix9"

* changes:
  Add DISALLOW_ADD_USER to all users when Device Owner is set.
  Make getUserProvisioningState work cross-user.
  Fix Connected Apps on headless
  Update canAdminGrantSensorsPermissions to always check system user.
parents d2f840df 1f7ca400
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -56,10 +56,9 @@ public abstract class DevicePolicyCache {
    public abstract int getPermissionPolicy(@UserIdInt int userHandle);

    /**
     * Caches {@link DevicePolicyManager#canAdminGrantSensorsPermissionsForUser(int)} for the
     * given user.
     * True if there is an admin on the device who can grant sensor permissions.
     */
    public abstract boolean canAdminGrantSensorsPermissionsForUser(@UserIdInt int userHandle);
    public abstract boolean canAdminGrantSensorsPermissions();

    /**
     * Empty implementation.
@@ -83,7 +82,7 @@ public abstract class DevicePolicyCache {
        }

        @Override
        public boolean canAdminGrantSensorsPermissionsForUser(int userHandle) {
        public boolean canAdminGrantSensorsPermissions() {
            return false;
        }
    }
+9 −4
Original line number Diff line number Diff line
@@ -16,12 +16,14 @@
package android.app.admin;
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.QUERY_ADMIN_POLICY;
import static android.Manifest.permission.SET_TIME;
import static android.Manifest.permission.SET_TIME_ZONE;
import static android.content.Intent.LOCAL_FLAG_FROM_SYSTEM;
import static android.net.NetworkCapabilities.NET_ENTERPRISE_ID_1;
import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
@@ -13546,11 +13548,14 @@ public class DevicePolicyManager {
            android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS
    })
    @UserProvisioningState
    @UserHandleAware(
            enabledSinceTargetSdkVersion = UPSIDE_DOWN_CAKE,
            requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public int getUserProvisioningState() {
        throwIfParentInstance("getUserProvisioningState");
        if (mService != null) {
            try {
                return mService.getUserProvisioningState();
                return mService.getUserProvisioningState(mContext.getUserId());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
@@ -15776,7 +15781,7 @@ public class DevicePolicyManager {
    }
    /**
     * Returns true if the caller is running on a device where the admin can grant
     * Returns true if the caller is running on a device where an admin can grant
     * permissions related to device sensors.
     * This is a signal that the device is a fully-managed device where personal usage is
     * discouraged.
@@ -15784,7 +15789,7 @@ public class DevicePolicyManager {
     * {@link #setPermissionGrantState(ComponentName, String, String, int)}.
     *
     * May be called by any app.
     * @return true if the app can grant device sensors-related permissions, false otherwise.
     * @return true if an admin can grant device sensors-related permissions, false otherwise.
     */
    public boolean canAdminGrantSensorsPermissions() {
        throwIfParentInstance("canAdminGrantSensorsPermissions");
@@ -15792,7 +15797,7 @@ public class DevicePolicyManager {
            return false;
        }
        try {
            return mService.canAdminGrantSensorsPermissionsForUser(myUserId());
            return mService.canAdminGrantSensorsPermissions();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
+2 −2
Original line number Diff line number Diff line
@@ -415,7 +415,7 @@ interface IDevicePolicyManager {
    CharSequence getDeviceOwnerOrganizationName();
    CharSequence getOrganizationNameForUser(int userHandle);

    int getUserProvisioningState();
    int getUserProvisioningState(int userHandle);
    void setUserProvisioningState(int state, int userHandle);

    void setAffiliationIds(in ComponentName admin, in List<String> ids);
@@ -553,7 +553,7 @@ interface IDevicePolicyManager {
    int getDeviceOwnerType(in ComponentName admin);

    void resetDefaultCrossProfileIntentFilters(int userId);
    boolean canAdminGrantSensorsPermissionsForUser(int userId);
    boolean canAdminGrantSensorsPermissions();

    void setUsbDataSignalingEnabled(String callerPackage, boolean enabled);
    boolean isUsbDataSignalingEnabled(String callerPackage);
+30 −10
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.content.pm;

import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.app.admin.DevicePolicyResources.Strings.Core.SWITCH_TO_PERSONAL_LABEL;
import static android.app.admin.DevicePolicyResources.Strings.Core.SWITCH_TO_WORK_LABEL;

@@ -23,6 +24,7 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UserHandleAware;
import android.app.Activity;
import android.app.AppOpsManager.Mode;
import android.app.admin.DevicePolicyManager;
@@ -32,6 +34,7 @@ import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -167,7 +170,7 @@ public class CrossProfileApps {
     */
    @RequiresPermission(anyOf = {
            android.Manifest.permission.INTERACT_ACROSS_PROFILES,
            android.Manifest.permission.INTERACT_ACROSS_USERS})
            INTERACT_ACROSS_USERS})
    public void startActivity(
            @NonNull Intent intent,
            @NonNull UserHandle targetUser,
@@ -196,7 +199,7 @@ public class CrossProfileApps {
     */
    @RequiresPermission(anyOf = {
            android.Manifest.permission.INTERACT_ACROSS_PROFILES,
            android.Manifest.permission.INTERACT_ACROSS_USERS})
            INTERACT_ACROSS_USERS})
    public void startActivity(
            @NonNull Intent intent,
            @NonNull UserHandle targetUser,
@@ -500,10 +503,13 @@ public class CrossProfileApps {
     */
    @RequiresPermission(
            allOf={android.Manifest.permission.CONFIGURE_INTERACT_ACROSS_PROFILES,
                    android.Manifest.permission.INTERACT_ACROSS_USERS})
                    INTERACT_ACROSS_USERS})
    @UserHandleAware(
            enabledSinceTargetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE,
            requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public void setInteractAcrossProfilesAppOp(@NonNull String packageName, @Mode int newMode) {
        try {
            mService.setInteractAcrossProfilesAppOp(packageName, newMode);
            mService.setInteractAcrossProfilesAppOp(mContext.getUserId(), packageName, newMode);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
@@ -519,9 +525,12 @@ public class CrossProfileApps {
     * @hide
     */
    @TestApi
    @UserHandleAware(
            enabledSinceTargetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE,
            requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public boolean canConfigureInteractAcrossProfiles(@NonNull String packageName) {
        try {
            return mService.canConfigureInteractAcrossProfiles(packageName);
            return mService.canConfigureInteractAcrossProfiles(mContext.getUserId(), packageName);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
@@ -540,9 +549,13 @@ public class CrossProfileApps {
     *
     * @hide
     */
    @UserHandleAware(
            enabledSinceTargetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE,
            requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public boolean canUserAttemptToConfigureInteractAcrossProfiles(String packageName) {
        try {
            return mService.canUserAttemptToConfigureInteractAcrossProfiles(packageName);
            return mService.canUserAttemptToConfigureInteractAcrossProfiles(
                    mContext.getUserId(), packageName);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
@@ -569,7 +582,10 @@ public class CrossProfileApps {
     */
    @RequiresPermission(
            allOf={android.Manifest.permission.CONFIGURE_INTERACT_ACROSS_PROFILES,
                    android.Manifest.permission.INTERACT_ACROSS_USERS})
                    INTERACT_ACROSS_USERS})
    @UserHandleAware(
            enabledSinceTargetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE,
            requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public void resetInteractAcrossProfilesAppOps(
            @NonNull Collection<String> previousCrossProfilePackages,
            @NonNull Set<String> newCrossProfilePackages) {
@@ -584,7 +600,8 @@ public class CrossProfileApps {
            return;
        }
        try {
            mService.resetInteractAcrossProfilesAppOps(unsetCrossProfilePackages);
            mService.resetInteractAcrossProfilesAppOps(
                    mContext.getUserId(), unsetCrossProfilePackages);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
@@ -609,10 +626,13 @@ public class CrossProfileApps {
     */
    @RequiresPermission(
            allOf={android.Manifest.permission.CONFIGURE_INTERACT_ACROSS_PROFILES,
                    android.Manifest.permission.INTERACT_ACROSS_USERS})
                    INTERACT_ACROSS_USERS})
    @UserHandleAware(
            enabledSinceTargetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE,
            requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public void clearInteractAcrossProfilesAppOps() {
        try {
            mService.clearInteractAcrossProfilesAppOps();
            mService.clearInteractAcrossProfilesAppOps(mContext.getUserId());
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
+5 −5
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@ interface ICrossProfileApps {
    List<UserHandle> getTargetUserProfiles(in String callingPackage);
    boolean canInteractAcrossProfiles(in String callingPackage);
    boolean canRequestInteractAcrossProfiles(in String callingPackage);
    void setInteractAcrossProfilesAppOp(in String packageName, int newMode);
    boolean canConfigureInteractAcrossProfiles(in String packageName);
    boolean canUserAttemptToConfigureInteractAcrossProfiles(in String packageName);
    void resetInteractAcrossProfilesAppOps(in List<String> packageNames);
    void clearInteractAcrossProfilesAppOps();
    void setInteractAcrossProfilesAppOp(int userId, in String packageName, int newMode);
    boolean canConfigureInteractAcrossProfiles(int userId, in String packageName);
    boolean canUserAttemptToConfigureInteractAcrossProfiles(int userId, in String packageName);
    void resetInteractAcrossProfilesAppOps(int userId, in List<String> packageNames);
    void clearInteractAcrossProfilesAppOps(int userId);
}
Loading