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

Commit 3a3092fa authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Add DPM.getUserRestrictions()

This returns per-DO/PO restrictions.

Bug 23902097

Change-Id: I225c1b01444fe2f60e5a6674d327182cc9bb15dc
parent 41b10518
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5722,6 +5722,7 @@ package android.app.admin {
    method public int getStorageEncryptionStatus();
    method public android.app.admin.SystemUpdatePolicy getSystemUpdatePolicy();
    method public java.util.List<android.os.PersistableBundle> getTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName);
    method public android.os.Bundle getUserRestrictions(android.content.ComponentName);
    method public boolean hasCaCertInstalled(android.content.ComponentName, byte[]);
    method public boolean hasGrantedPolicy(android.content.ComponentName, int);
    method public boolean installCaCert(android.content.ComponentName, byte[]);
+1 −0
Original line number Diff line number Diff line
@@ -5851,6 +5851,7 @@ package android.app.admin {
    method public int getStorageEncryptionStatus();
    method public android.app.admin.SystemUpdatePolicy getSystemUpdatePolicy();
    method public java.util.List<android.os.PersistableBundle> getTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName);
    method public android.os.Bundle getUserRestrictions(android.content.ComponentName);
    method public boolean hasCaCertInstalled(android.content.ComponentName, byte[]);
    method public boolean hasGrantedPolicy(android.content.ComponentName, int);
    method public boolean installCaCert(android.content.ComponentName, byte[]);
+22 −0
Original line number Diff line number Diff line
@@ -3634,6 +3634,28 @@ public class DevicePolicyManager {
        }
    }

    /**
     * Called by a profile or device owner to get user restrictions set with
     * {@link #addUserRestriction(ComponentName, String)}.
     * <p>
     * The target user may have more restrictions set by the system or other device owner / profile
     * owner.  To get all the user restrictions currently set, use
     * {@link UserManager#getUserRestrictions()}.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     */
    public Bundle getUserRestrictions(@NonNull ComponentName admin) {
        Bundle ret = null;
        if (mService != null) {
            try {
                ret = mService.getUserRestrictions(admin);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed talking with device policy service", e);
            }
        }
        return ret == null ? new Bundle() : ret;
    }

    /**
     * Called by profile or device owners to hide or unhide packages. When a package is hidden it
     * is unavailable for use, but the data and actual package file remain.
+1 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ interface IDevicePolicyManager {
    ComponentName getRestrictionsProvider(int userHandle);

    void setUserRestriction(in ComponentName who, in String key, boolean enable);
    Bundle getUserRestrictions(in ComponentName who);
    void addCrossProfileIntentFilter(in ComponentName admin, in IntentFilter filter, int flags);
    void clearCrossProfileIntentFilters(in ComponentName admin);

+10 −0
Original line number Diff line number Diff line
@@ -5723,6 +5723,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
    }

    @Override
    public Bundle getUserRestrictions(ComponentName who) {
        Preconditions.checkNotNull(who, "ComponentName is null");
        synchronized (this) {
            final ActiveAdmin activeAdmin =
                    getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
            return activeAdmin.userRestrictions;
        }
    }

    @Override
    public boolean setApplicationHidden(ComponentName who, String packageName,
            boolean hidden) {
Loading