Java 类android.content.RestrictionsManager 实例源码

项目:commcare-android    文件:CommCareSetupActivity.java   
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();
        }
    }
}
项目:commcare-android    文件:LoginActivity.java   
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);
        }
    }
}
项目:appauth-android-codelab    文件:MainActivity.java   
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();
    }
  }
}
项目:FMTech    文件:RestrictedDeviceHelper.java   
@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;
}
项目:android-testdpc    文件:ManageAppRestrictionsFragment.java   
@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);
}
项目:EasyAndroid    文件:Managers.java   
/**
 * 返回 {@link RestrictionsManager}
 */
public static RestrictionsManager getRestrictionsManager()
{
    return (RestrictionsManager) get(RESTRICTIONS_SERVICE);
}
项目:Android-App-Template    文件:ServiceUtil.java   
@TargetApi(21)
public static RestrictionsManager getRestrictionsManager() {
    return (RestrictionsManager) getSystemService(Context.RESTRICTIONS_SERVICE);
}
项目:sprockets-android    文件:Managers.java   
/**
 * @since 4.0.0
 */
public static RestrictionsManager restrictions(Context context) {
    return (RestrictionsManager) context.getSystemService(RESTRICTIONS_SERVICE);
}
项目:android_Skeleton    文件:SystemServices.java   
@TargetApi(AndroidHelper.API_21)
public static RestrictionsManager restrictionsManager() {
    return (RestrictionsManager) get(Context.RESTRICTIONS_SERVICE);
}
项目:android-wheels    文件:ContextUtils.java   
/**
 * 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));
}