Merge "Add hidden API to store whether provisioning config has been applied" into nyc-mr1-dev

This commit is contained in:
Benjamin Franz
2016-07-13 14:31:49 +00:00
committed by Android (Google) Code Review
3 changed files with 59 additions and 0 deletions

View File

@@ -6436,6 +6436,30 @@ public class DevicePolicyManager {
}
}
/**
* @hide
* Writes that the provisioning configuration has been applied.
*/
public void setDeviceProvisioningConfigApplied() {
try {
mService.setDeviceProvisioningConfigApplied();
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
}
/**
* @hide
* @return whether the provisioning configuration has been applied.
*/
public boolean isDeviceProvisioningConfigApplied() {
try {
return mService.isDeviceProvisioningConfigApplied();
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
}
private void throwIfParentInstance(String functionName) {
if (mParentInstance) {
throw new SecurityException(functionName + " cannot be called on the parent instance");

View File

@@ -303,4 +303,6 @@ interface IDevicePolicyManager {
void uninstallPackageWithActiveAdmins(String packageName);
boolean isDeviceProvisioned();
boolean isDeviceProvisioningConfigApplied();
void setDeviceProvisioningConfigApplied();
}

View File

@@ -218,6 +218,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
private static final String ATTR_SETUP_COMPLETE = "setup-complete";
private static final String ATTR_PROVISIONING_STATE = "provisioning-state";
private static final String ATTR_PERMISSION_POLICY = "permission-policy";
private static final String ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED =
"device-provisioning-config-applied";
private static final String ATTR_DELEGATED_CERT_INSTALLER = "delegated-cert-installer";
private static final String ATTR_APPLICATION_RESTRICTIONS_MANAGER
@@ -417,6 +419,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
int mUserProvisioningState;
int mPermissionPolicy;
boolean mDeviceProvisioningConfigApplied = false;
final ArrayMap<ComponentName, ActiveAdmin> mAdminMap = new ArrayMap<>();
final ArrayList<ActiveAdmin> mAdminList = new ArrayList<>();
final ArrayList<ComponentName> mRemovingAdmins = new ArrayList<>();
@@ -2173,6 +2177,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
out.attribute(null, ATTR_SETUP_COMPLETE,
Boolean.toString(true));
}
if (policy.mDeviceProvisioningConfigApplied) {
out.attribute(null, ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED,
Boolean.toString(true));
}
if (policy.mUserProvisioningState != DevicePolicyManager.STATE_USER_UNMANAGED) {
out.attribute(null, ATTR_PROVISIONING_STATE,
Integer.toString(policy.mUserProvisioningState));
@@ -2333,6 +2341,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
if (userSetupComplete != null && Boolean.toString(true).equals(userSetupComplete)) {
policy.mUserSetupComplete = true;
}
String deviceProvisioningConfigApplied = parser.getAttributeValue(null,
ATTR_DEVICE_PROVISIONING_CONFIG_APPLIED);
if (deviceProvisioningConfigApplied != null
&& Boolean.toString(true).equals(deviceProvisioningConfigApplied)) {
policy.mDeviceProvisioningConfigApplied = true;
}
String provisioningState = parser.getAttributeValue(null, ATTR_PROVISIONING_STATE);
if (!TextUtils.isEmpty(provisioningState)) {
policy.mUserProvisioningState = Integer.parseInt(provisioningState);
@@ -9046,4 +9060,23 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
// restrictions.
pushUserRestrictions(userHandle);
}
@Override
public void setDeviceProvisioningConfigApplied() {
enforceManageUsers();
synchronized (this) {
DevicePolicyData policy = getUserData(UserHandle.USER_SYSTEM);
policy.mDeviceProvisioningConfigApplied = true;
saveSettingsLocked(UserHandle.USER_SYSTEM);
}
}
@Override
public boolean isDeviceProvisioningConfigApplied() {
enforceManageUsers();
synchronized (this) {
final DevicePolicyData policy = getUserData(UserHandle.USER_SYSTEM);
return policy.mDeviceProvisioningConfigApplied;
}
}
}