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

Commit 07387fed authored by Nicolas Prevot's avatar Nicolas Prevot
Browse files

Add method to tell the dpc if provisioning is allowed.

The DPC can use it to tell if provisioning a managed profile or for
device owner would work or not.

BUG:25338478
Change-Id: I09ea6a9f23a8e88e4ed37c048170b2a68213086e
parent 3034538c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5741,6 +5741,7 @@ package android.app.admin {
    method public boolean isLockTaskPermitted(java.lang.String);
    method public boolean isMasterVolumeMuted(android.content.ComponentName);
    method public boolean isProfileOwnerApp(java.lang.String);
    method public boolean isProvisioningAllowed(java.lang.String);
    method public boolean isUninstallBlocked(android.content.ComponentName, java.lang.String);
    method public void lockNow();
    method public void removeActiveAdmin(android.content.ComponentName);
+1 −0
Original line number Diff line number Diff line
@@ -5870,6 +5870,7 @@ package android.app.admin {
    method public boolean isLockTaskPermitted(java.lang.String);
    method public boolean isMasterVolumeMuted(android.content.ComponentName);
    method public boolean isProfileOwnerApp(java.lang.String);
    method public boolean isProvisioningAllowed(java.lang.String);
    method public boolean isUninstallBlocked(android.content.ComponentName, java.lang.String);
    method public void lockNow();
    method public void notifyPendingSystemUpdate(long);
+19 −0
Original line number Diff line number Diff line
@@ -4299,4 +4299,23 @@ public class DevicePolicyManager {
            return PERMISSION_GRANT_STATE_DEFAULT;
        }
    }

    /**
     * Returns if provisioning a managed profile or device is possible or not.
     * @param action One of {@link #ACTION_PROVISION_MANAGED_DEVICE},
     * {@link #ACTION_PROVISION_MANAGED_PROFILE}.
     * Note that even if this method returns true, there is a slight possibility that the
     * provisioning will not be allowed when it is actually initiated because some event has
     * happened in between.
     * @return if provisioning a managed profile or device is possible or not.
     * @throws IllegalArgumentException if the supplied action is not valid.
     */
    public boolean isProvisioningAllowed(String action) {
        try {
            return mService.isProvisioningAllowed(action);
        } catch (RemoteException re) {
            Log.w(TAG, "Failed talking with device policy service", re);
            return false;
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -227,4 +227,5 @@ interface IDevicePolicyManager {
    boolean setPermissionGrantState(in ComponentName admin, String packageName,
            String permission, int grantState);
    int getPermissionGrantState(in ComponentName admin, String packageName, String permission);
    boolean isProvisioningAllowed(String action);
}
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ interface IUserManager {
    UserInfo getPrimaryUser();
    List<UserInfo> getUsers(boolean excludeDying);
    List<UserInfo> getProfiles(int userHandle, boolean enabledOnly);
    boolean canAddMoreManagedProfiles(int userId);
    boolean canAddMoreManagedProfiles(int userId, boolean allowedToRemoveOne);
    UserInfo getProfileParent(int userHandle);
    boolean isSameProfileGroup(int userId, int otherUserId);
    UserInfo getUserInfo(int userHandle);
Loading