public void checkManagedConfiguration() { Log.d(TAG, "Checking managed configuration"); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { // Check for managed configuration RestrictionsManager restrictionsManager = (RestrictionsManager) getSystemService(Context.RESTRICTIONS_SERVICE); Bundle appRestrictions = restrictionsManager.getApplicationRestrictions(); if (appRestrictions != null && appRestrictions.containsKey("profileUrl")) { Log.d(TAG, "Found managed configuration install URL " + appRestrictions.getString("profileUrl")); incomingRef = appRestrictions.getString("profileUrl"); lastInstallMode = INSTALL_MODE_MANAGED_CONFIGURATION; uiState = UiState.READY_TO_INSTALL; uiStateScreenTransition(); startResourceInstall(); } } }
private void checkManagedConfiguration() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { // Check for managed configuration RestrictionsManager restrictionsManager = (RestrictionsManager) getSystemService(Context.RESTRICTIONS_SERVICE); if (restrictionsManager == null) { return; } Bundle appRestrictions = restrictionsManager.getApplicationRestrictions(); if (appRestrictions.containsKey("username") && appRestrictions.containsKey("password")) { uiController.setUsername(appRestrictions.getString("username")); uiController.setPasswordOrPin(appRestrictions.getString("password")); initiateLoginAttempt(false); } } }
private void getAppRestrictions(){ RestrictionsManager restrictionsManager = (RestrictionsManager) this .getSystemService(Context.RESTRICTIONS_SERVICE); Bundle appRestrictions = restrictionsManager.getApplicationRestrictions(); // Block user if KEY_RESTRICTIONS_PENDING is true, and save login hint if available if(!appRestrictions.isEmpty()){ if(appRestrictions.getBoolean(UserManager. KEY_RESTRICTIONS_PENDING)!=true){ mLoginHint = appRestrictions.getString(LOGIN_HINT); } else { Toast.makeText(this,R.string.restrictions_pending_block_user, Toast.LENGTH_LONG).show(); finish(); } } }
@TargetApi(21) public static Intent getIntentForChallengeUIIfRequired(Activity paramActivity) { if (sUserPinValid) { return null; } Intent localIntent = ((RestrictionsManager)paramActivity.getSystemService("restrictions")).createLocalApprovalIntent(); PersistableBundle localPersistableBundle = new PersistableBundle(); localPersistableBundle.putString("android.request.mesg", paramActivity.getString(2131362662)); localIntent.putExtra("android.content.extra.REQUEST_BUNDLE", localPersistableBundle); return localIntent; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); mDevicePolicyManager = (DevicePolicyManager) getActivity().getSystemService( Context.DEVICE_POLICY_SERVICE); mRestrictionsManager = (RestrictionsManager) getActivity().getSystemService( Context.RESTRICTIONS_SERVICE); }
/** * 返回 {@link RestrictionsManager} */ public static RestrictionsManager getRestrictionsManager() { return (RestrictionsManager) get(RESTRICTIONS_SERVICE); }
@TargetApi(21) public static RestrictionsManager getRestrictionsManager() { return (RestrictionsManager) getSystemService(Context.RESTRICTIONS_SERVICE); }
/** * @since 4.0.0 */ public static RestrictionsManager restrictions(Context context) { return (RestrictionsManager) context.getSystemService(RESTRICTIONS_SERVICE); }
@TargetApi(AndroidHelper.API_21) public static RestrictionsManager restrictionsManager() { return (RestrictionsManager) get(Context.RESTRICTIONS_SERVICE); }
/** * Obtain a {@link RestrictionsManager} instance associated with specified {@link Context} * * @param context Context * @return {@link RestrictionsManager} associated with specified {@link Context} * @throws InvalidContextException if {@link RestrictionsManager} can't be obtained * from specified {@link Context} */ @NonNull @RequiresApi(Build.VERSION_CODES.LOLLIPOP) public static RestrictionsManager getRestrictionsManager(@NonNull Context context) { return validate(context.getSystemService(Context.RESTRICTIONS_SERVICE)); }