List of usage examples for android.app.admin DevicePolicyManager isProvisioningAllowed
public boolean isProvisioningAllowed(@NonNull String action)
From source file:com.afwsamples.testdpc.common.ProvisioningStateUtil.java
/** * @param action Action to be checked//from w w w .ja va 2 s . c om * @param context Calling activity's context * @return true, if provisioning is allowed for corresponding action */ @TargetApi(Build.VERSION_CODES.N) public static boolean isProvisioningAllowed(Context context, String action) { if (BuildCompat.isAtLeastN()) { DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); return dpm.isProvisioningAllowed(action); } else { if (ACTION_PROVISION_MANAGED_DEVICE.equals(action)) { return (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) ? isDeviceUnprovisionedAndNoDeviceOwner(context) : false; } if (ACTION_PROVISION_MANAGED_PROFILE.equals(action)) { return true; } return false; } }