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

Commit 325af202 authored by Mahaver Chopra's avatar Mahaver Chopra Committed by android-build-merger
Browse files

Merge \"Add an api to verify if ro.device_owner was set\" into nyc-mr1-dev

am: c1182a81

Change-Id: I6fecc2edf4ba78d60f509679c0b9b5367305f310
parents bc2eea7c c1182a81
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -6416,6 +6416,19 @@ public class DevicePolicyManager {
        }
    }

    /**
     * @hide
     * @return whether {@link android.provider.Settings.Global#DEVICE_PROVISIONED} has ever been set
     * to 1.
     */
    public boolean isDeviceProvisioned() {
        try {
            return mService.isDeviceProvisioned();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    private void throwIfParentInstance(String functionName) {
        if (mParentInstance) {
            throw new SecurityException(functionName + " cannot be called on the parent instance");
+2 −0
Original line number Diff line number Diff line
@@ -301,4 +301,6 @@ interface IDevicePolicyManager {

    boolean isUninstallInQueue(String packageName);
    void uninstallPackageWithActiveAdmins(String packageName);

    boolean isDeviceProvisioned();
}
+5 −0
Original line number Diff line number Diff line
@@ -8975,6 +8975,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
    }

    @Override
    public boolean isDeviceProvisioned() {
        return !TextUtils.isEmpty(mInjector.systemPropertiesGet(PROPERTY_DEVICE_OWNER_PRESENT));
    }

    private void removePackageIfRequired(final String packageName, final int userId) {
        if (!packageHasActiveAdmins(packageName, userId)) {
            // Will not do anything if uninstall was not requested or was already started.