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

Commit 93e2e94a authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Automerger Merge Worker
Browse files

Merge "Add API to check if device policy role qualification is bypassable"...

Merge "Add API to check if device policy role qualification is bypassable" into tm-dev am: caf50b5f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17073805

Change-Id: I0f32d791d87051b061246c6dcd44a625f8e5528a
parents 3fc54163 caf50b5f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1114,6 +1114,7 @@ package android.app.admin {
    method public void setSecondaryLockscreenEnabled(@NonNull android.content.ComponentName, boolean);
    method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_MANAGEMENT_RESOURCES) public void setStrings(@NonNull java.util.Set<android.app.admin.DevicePolicyStringResource>);
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public void setUserProvisioningState(int, @NonNull android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) public boolean shouldAllowBypassingDevicePolicyManagementRoleQualification();
    field public static final String ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED = "android.account.DEVICE_OR_PROFILE_OWNER_ALLOWED";
    field public static final String ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_DISALLOWED = "android.account.DEVICE_OR_PROFILE_OWNER_DISALLOWED";
    field public static final String ACTION_BIND_SECONDARY_LOCKSCREEN_SERVICE = "android.app.action.BIND_SECONDARY_LOCKSCREEN_SERVICE";
+19 −0
Original line number Diff line number Diff line
@@ -15765,4 +15765,23 @@ public class DevicePolicyManager {
        }
        return deviceManagerConfig;
    }
    /**
     * @return {@code true} if bypassing the device policy management role qualification is allowed
     * with the current state of the device.
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
    public boolean shouldAllowBypassingDevicePolicyManagementRoleQualification() {
        if (mService != null) {
            try {
                return mService.shouldAllowBypassingDevicePolicyManagementRoleQualification();
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return false;
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -558,4 +558,6 @@ interface IDevicePolicyManager {
    void setStrings(in List<DevicePolicyStringResource> strings);
    void resetStrings(in String[] stringIds);
    ParcelableResource getString(String stringId);

    boolean shouldAllowBypassingDevicePolicyManagementRoleQualification();
}
+5 −0
Original line number Diff line number Diff line
@@ -189,4 +189,9 @@ abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub {
    public ParcelableResource getString(String stringId) {
        return null;
    }

    @Override
    public boolean shouldAllowBypassingDevicePolicyManagementRoleQualification() {
        return false;
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -18790,4 +18790,18 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        mInjector.binderWithCleanCallingIdentity(() -> Settings.Secure.putInt(
                mContext.getContentResolver(), MANAGED_PROVISIONING_DPC_DOWNLOADED, setTo));
    }
    @Override
    public boolean shouldAllowBypassingDevicePolicyManagementRoleQualification() {
        Preconditions.checkCallAuthorization(hasCallingOrSelfPermission(
                android.Manifest.permission.MANAGE_ROLE_HOLDERS));
        return mInjector.binderWithCleanCallingIdentity(() -> {
            if (mUserManager.getUserCount() > 1) {
                return false;
            }
            AccountManager am = AccountManager.get(mContext);
            Account[] accounts = am.getAccounts();
            return accounts.length == 0;
        });
    }
}