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

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

Merge "Remove ownerName as argument in DPMS.setDeviceOwner"

parents e90385c5 c98b9182
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -523,8 +523,8 @@ package android.app.admin {
    method @NonNull public static String operationToString(int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public void resetDefaultCrossProfileIntentFilters(int);
    method @RequiresPermission(allOf={android.Manifest.permission.MANAGE_DEVICE_ADMINS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}) public void setActiveAdmin(@NonNull android.content.ComponentName, boolean, int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public boolean setDeviceOwner(@NonNull android.content.ComponentName, @Nullable String, int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public boolean setDeviceOwnerOnly(@NonNull android.content.ComponentName, @Nullable String, int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public boolean setDeviceOwner(@NonNull android.content.ComponentName, int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public boolean setDeviceOwnerOnly(@NonNull android.content.ComponentName, int);
    method public void setDeviceOwnerType(@NonNull android.content.ComponentName, int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_DEVICE_ADMINS) public void setNextOperationSafety(int, int);
    method @RequiresPermission(anyOf={android.Manifest.permission.MARK_DEVICE_ORGANIZATION_OWNED, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}, conditional=true) public void setProfileOwnerOnOrganizationOwnedDevice(@NonNull android.content.ComponentName, boolean);
+5 −7
Original line number Diff line number Diff line
@@ -8689,7 +8689,6 @@ public class DevicePolicyManager {
     * and no accounts.
     *
     * @param who the component name to be registered as device owner.
     * @param ownerName the human readable name of the institution that owns this device.
     * @param userId ID of the user on which the device owner runs.
     *
     * @return whether the package was successfully registered as the device owner.
@@ -8701,11 +8700,10 @@ public class DevicePolicyManager {
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS)
    public boolean setDeviceOwner(@NonNull ComponentName who, @Nullable String ownerName,
            @UserIdInt int userId) {
    public boolean setDeviceOwner(@NonNull ComponentName who, @UserIdInt int userId) {
        if (mService != null) {
            try {
                return mService.setDeviceOwner(who, ownerName, userId,
                return mService.setDeviceOwner(who, userId,
                        /* setProfileOwnerOnCurrentUserIfNecessary= */ true);
            } catch (RemoteException re) {
                throw re.rethrowFromSystemServer();
@@ -8715,7 +8713,7 @@ public class DevicePolicyManager {
    }
    /**
     * Same as {@link #setDeviceOwner(ComponentName, String, int)}, but without setting the profile
     * Same as {@link #setDeviceOwner(ComponentName, int)}, but without setting the profile
     * owner on current user when running on headless system user mode - should be used only by
     * testing infra.
     *
@@ -8724,10 +8722,10 @@ public class DevicePolicyManager {
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS)
    public boolean setDeviceOwnerOnly(
            @NonNull ComponentName who, @Nullable String ownerName, @UserIdInt int userId) {
            @NonNull ComponentName who, @UserIdInt int userId) {
        if (mService != null) {
            try {
                return mService.setDeviceOwner(who, ownerName, userId,
                return mService.setDeviceOwner(who, userId,
                        /* setProfileOwnerOnCurrentUserIfNecessary= */ false);
            } catch (RemoteException re) {
                throw re.rethrowFromSystemServer();
+1 −1
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ interface IDevicePolicyManager {
    void reportKeyguardDismissed(int userHandle);
    void reportKeyguardSecured(int userHandle);

    boolean setDeviceOwner(in ComponentName who, String ownerName, int userId, boolean setProfileOwnerOnCurrentUserIfNecessary);
    boolean setDeviceOwner(in ComponentName who, int userId, boolean setProfileOwnerOnCurrentUserIfNecessary);
    ComponentName getDeviceOwnerComponent(boolean callingUserOnly);
    boolean hasDeviceOwner();
    String getDeviceOwnerName();
+5 −8
Original line number Diff line number Diff line
@@ -8336,9 +8336,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                + PackageManager.FEATURE_DEVICE_ADMIN + " feature.");
    }
    // TODO(b/240562946): Remove owner name from API parameters.
    @Override
    public boolean setDeviceOwner(ComponentName admin, String ownerName, int userId,
    public boolean setDeviceOwner(ComponentName admin, int userId,
            boolean setProfileOwnerOnCurrentUserIfNecessary) {
        if (!mHasFeature) {
            logMissingFeatureAction("Cannot set " + ComponentName.flattenToShortString(admin)
@@ -18048,11 +18047,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            }
            if (!setActiveAdminAndDeviceOwner(
                    deviceOwnerUserId, deviceAdmin, provisioningParams.getOwnerName())) {
            if (!setActiveAdminAndDeviceOwner(deviceOwnerUserId, deviceAdmin)) {
                throw new ServiceSpecificException(
                        ERROR_SET_DEVICE_OWNER_FAILED,
                        "Failed to set device owner.");
                        ERROR_SET_DEVICE_OWNER_FAILED, "Failed to set device owner.");
            }
            disallowAddUser();
@@ -18179,12 +18176,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    }
    private boolean setActiveAdminAndDeviceOwner(
            @UserIdInt int userId, ComponentName adminComponent, String name) {
            @UserIdInt int userId, ComponentName adminComponent) {
        enableAndSetActiveAdmin(userId, userId, adminComponent);
        // TODO(b/178187130): Directly set DO and remove the check once silent provisioning is no
        //  longer used.
        if (getDeviceOwnerComponent(/* callingUserOnly= */ true) == null) {
            return setDeviceOwner(adminComponent, name, userId,
            return setDeviceOwner(adminComponent, userId,
                    /* setProfileOwnerOnCurrentUserIfNecessary= */ true);
        }
        return true;
+1 −1
Original line number Diff line number Diff line
@@ -256,7 +256,7 @@ final class DevicePolicyManagerServiceShellCommand extends ShellCommand {
        mService.setActiveAdmin(mComponent, /* refreshing= */ true, mUserId);

        try {
            if (!mService.setDeviceOwner(mComponent, mName, mUserId,
            if (!mService.setDeviceOwner(mComponent, mUserId,
                    /* setProfileOwnerOnCurrentUserIfNecessary= */ !mSetDoOnly)) {
                throw new RuntimeException(
                        "Can't set package " + mComponent + " as device owner.");
Loading