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

Commit a98a0c6f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make the method for finding out if a device is org-owned public."

parents acc4f313 41c2aed9
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -6839,6 +6839,7 @@ package android.app.admin {
    method public boolean isManagedProfile(@NonNull android.content.ComponentName);
    method public boolean isManagedProfile(@NonNull android.content.ComponentName);
    method public boolean isMasterVolumeMuted(@NonNull android.content.ComponentName);
    method public boolean isMasterVolumeMuted(@NonNull android.content.ComponentName);
    method public boolean isNetworkLoggingEnabled(@Nullable android.content.ComponentName);
    method public boolean isNetworkLoggingEnabled(@Nullable android.content.ComponentName);
    method public boolean isOrganizationOwnedDeviceWithManagedProfile();
    method public boolean isOverrideApnEnabled(@NonNull android.content.ComponentName);
    method public boolean isOverrideApnEnabled(@NonNull android.content.ComponentName);
    method public boolean isPackageSuspended(@NonNull android.content.ComponentName, String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public boolean isPackageSuspended(@NonNull android.content.ComponentName, String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public boolean isProfileOwnerApp(String);
    method public boolean isProfileOwnerApp(String);
+0 −1
Original line number Original line Diff line number Diff line
@@ -807,7 +807,6 @@ package android.app.admin {
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioned();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioned();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioningConfigApplied();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioningConfigApplied();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isManagedKiosk();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isManagedKiosk();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isOrganizationOwnedDeviceWithManagedProfile();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isUnattendedManagedKiosk();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isUnattendedManagedKiosk();
    method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long);
    method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long);
    method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long, boolean);
    method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long, boolean);
+4 −7
Original line number Original line Diff line number Diff line
@@ -6850,21 +6850,18 @@ public class DevicePolicyManager {
    }
    }
    /**
    /**
     * @hide
     * Apps can use this method to find out if the device was provisioned as
     * Privileged apps can use this method to find out if the device was provisioned as
     * organization-owend device with a managed profile.
     * organization-owend device with a managed profile.
     *
     *
     * This, together with checking whether the device has a device owner (by calling
     * This, together with checking whether the device has a device owner (by calling
     * {@link #isDeviceManaged()}), could be used to learn whether the device is owned by an
     * {@link #isDeviceOwnerApp}), could be used to learn whether the device is owned by an
     * organization or an individual:
     * organization or an individual:
     * If this method returns true OR {@link #isDeviceManaged()} returns true, then
     * If this method returns true OR {@link #isDeviceOwnerApp} returns true (for any package),
     * the device is owned by an organization. Otherwise, it's owned by an individual.
     * then the device is owned by an organization. Otherwise, it's owned by an individual.
     *
     *
     * @return {@code true} if the device was provisioned as organization-owned device,
     * @return {@code true} if the device was provisioned as organization-owned device,
     * {@code false} otherwise.
     * {@code false} otherwise.
     */
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public boolean isOrganizationOwnedDeviceWithManagedProfile() {
    public boolean isOrganizationOwnedDeviceWithManagedProfile() {
        throwIfParentInstance("isOrganizationOwnedDeviceWithManagedProfile");
        throwIfParentInstance("isOrganizationOwnedDeviceWithManagedProfile");
        if (mService != null) {
        if (mService != null) {
+0 −1
Original line number Original line Diff line number Diff line
@@ -8724,7 +8724,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        if (!mHasFeature) {
        if (!mHasFeature) {
            return false;
            return false;
        }
        }
        enforceManageUsers();
        return mInjector.binderWithCleanCallingIdentity(() -> {
        return mInjector.binderWithCleanCallingIdentity(() -> {
            for (UserInfo ui : mUserManager.getUsers()) {
            for (UserInfo ui : mUserManager.getUsers()) {
+1 −5
Original line number Original line Diff line number Diff line
@@ -3832,11 +3832,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        when(getServices().userManager.getUsers())
        when(getServices().userManager.getUsers())
                .thenReturn(Arrays.asList(managedProfileUserInfo));
                .thenReturn(Arrays.asList(managedProfileUserInfo));


        // Any caller without the MANAGE_USERS permission should get a security exception.
        // Any caller should be able to call this method.
        assertExpectException(SecurityException.class, null, () ->
                dpm.isOrganizationOwnedDeviceWithManagedProfile());
        // But when the right permission is granted, this should succeed.
        mContext.permissions.add(android.Manifest.permission.MANAGE_USERS);
        assertFalse(dpm.isOrganizationOwnedDeviceWithManagedProfile());
        assertFalse(dpm.isOrganizationOwnedDeviceWithManagedProfile());
        configureProfileOwnerOfOrgOwnedDevice(admin1, DpmMockContext.CALLER_USER_HANDLE);
        configureProfileOwnerOfOrgOwnedDevice(admin1, DpmMockContext.CALLER_USER_HANDLE);
        assertTrue(dpm.isOrganizationOwnedDeviceWithManagedProfile());
        assertTrue(dpm.isOrganizationOwnedDeviceWithManagedProfile());