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

Commit e62d8d11 authored by Alex Johnston's avatar Alex Johnston
Browse files

Add factory reset protection policy Test API to DPM

* Add @TestApi isFactoryResetProtectionPolicySupported()
  to DevicePolicyManager which returns whether factory
  reset protection policy is supported on the device.

Bug: 153696811
Test: atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testFactoryResetProtectionPolicy
Change-Id: Id0bd6cdacf33f0fb2f795e1ead5127b79f42960e
parent 3c94f713
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -575,6 +575,7 @@ package android.app.admin {
    method public java.util.List<java.lang.String> getOwnerInstalledCaCerts(@NonNull android.os.UserHandle);
    method public boolean isCurrentInputMethodSetByOwner();
    method public boolean isDeviceManaged();
    method public boolean isFactoryResetProtectionPolicySupported();
    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_DATA_SHARING_RESTRICTION_APPLIED = "android.app.action.DATA_SHARING_RESTRICTION_APPLIED";
+16 −0
Original line number Diff line number Diff line
@@ -10952,6 +10952,22 @@ public class DevicePolicyManager {
        }
    }
    /**
     * Returns whether factory reset protection policy is supported on the device.
     *
     * @return {@code true} if the device support factory reset protection policy.
     *
     * @hide
     */
    @TestApi
    public boolean isFactoryResetProtectionPolicySupported() {
        try {
            return mService.isFactoryResetProtectionPolicySupported();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }
    /**
     * Called by the device owner or profile owner to clear application user data of a given
     * package. The behaviour of this is equivalent to the target application calling
+1 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ interface IDevicePolicyManager {

    void setFactoryResetProtectionPolicy(in ComponentName who, in FactoryResetProtectionPolicy policy);
    FactoryResetProtectionPolicy getFactoryResetProtectionPolicy(in ComponentName who);
    boolean isFactoryResetProtectionPolicySupported();

    ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList);
    ComponentName getGlobalProxyAdmin(int userHandle);
+13 −3
Original line number Diff line number Diff line
@@ -7252,13 +7252,23 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        return admin != null ? admin.mFactoryResetProtectionPolicy : null;
    }
    private int getFrpManagementAgentUidOrThrow() {
    private int getFrpManagementAgentUid() {
        PersistentDataBlockManagerInternal pdb = mInjector.getPersistentDataBlockManagerInternal();
        if ((pdb == null) || (pdb.getAllowedUid() == -1)) {
        return pdb != null ? pdb.getAllowedUid() : -1;
    }
    private int getFrpManagementAgentUidOrThrow() {
        int uid = getFrpManagementAgentUid();
        if (uid == -1) {
            throw new UnsupportedOperationException(
                    "The persistent data block service is not supported on this device");
        }
        return pdb.getAllowedUid();
        return uid;
    }
    @Override
    public boolean isFactoryResetProtectionPolicySupported() {
        return getFrpManagementAgentUid() != -1;
    }
    @Override