Add an api to verify if ro.device_owner was set
Currently for OobConfig app we used DEVICE_PROVISIONED Global setting to verify if device was provisioned. This setting can be modified using adb. we just need to know if it was set atleast once. Added an api in DPM to return whether system property "ro.device_owner" was set. Bug: 29935702 Change-Id: I9a2b5217c0bc2cc11d68282e05a5450ea3f6cf21
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -301,4 +301,6 @@ interface IDevicePolicyManager {
|
||||
|
||||
boolean isUninstallInQueue(String packageName);
|
||||
void uninstallPackageWithActiveAdmins(String packageName);
|
||||
|
||||
boolean isDeviceProvisioned();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user