/** * If we are not the active device admin, try to become so. * * <p>Also checks for any policies that we have added during the lifetime of this app. This * catches the case where the user granted an earlier (smaller) set of policies but an app upgrade * requires that new policies be granted. * * @return true if we are already active, false if we are not */ public boolean isActiveAdmin() { DevicePolicyManager dpm = getDPM(); return dpm.isAdminActive(mAdminName) && dpm.hasGrantedPolicy(mAdminName, DeviceAdminInfo.USES_POLICY_EXPIRE_PASSWORD) && dpm.hasGrantedPolicy(mAdminName, DeviceAdminInfo.USES_ENCRYPTED_STORAGE) && dpm.hasGrantedPolicy(mAdminName, DeviceAdminInfo.USES_POLICY_DISABLE_CAMERA); }