List of usage examples for android.content Context RESTRICTIONS_SERVICE
String RESTRICTIONS_SERVICE
To view the source code for android.content Context RESTRICTIONS_SERVICE.
Click Source Link
From source file:be.blinkt.openvpn.activities.MainActivity.java
private AppConfiguration getManagedConfiguration() { AppConfiguration appConf = new AppConfiguration(); RestrictionsManager myRestrictionsMgr = (RestrictionsManager) this .getSystemService(Context.RESTRICTIONS_SERVICE); Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions(); String commonVPNConfiguration = null, userVPNConfiguration = null, allowedApps = null; if (appRestrictions.containsKey("CommonVPNConfiguration")) { commonVPNConfiguration = appRestrictions.getString("CommonVPNConfiguration"); System.out.println("CommonVPNConfiguration: " + commonVPNConfiguration); }//from ww w .j a va 2s . c o m if (appRestrictions.containsKey("UserVPNConfiguration")) { userVPNConfiguration = appRestrictions.getString("UserVPNConfiguration"); System.out.println("UserVPNConfiguration: " + userVPNConfiguration); } if (appRestrictions.containsKey("AllowedApps")) { allowedApps = appRestrictions.getString("AllowedApps"); System.out.println("AllowedApps: " + allowedApps); } if (commonVPNConfiguration != null && userVPNConfiguration != null && allowedApps != null) { appConf.setAllowedApps(allowedApps); appConf.setCommonConfiguration(commonVPNConfiguration); appConf.setUserConfiguration(userVPNConfiguration); return appConf; } else return null; }
From source file:org.alfresco.mobile.android.platform.mdm.MDMManager.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void requestConfig(FragmentActivity activity, String applicationId) { // Which Provider ? if (MobileIronManager.getInstance(activity) != null) { // MobileIron Build mobileIronManager = MobileIronManager.getInstance(activity); mobileIronManager.requestConfig(activity, applicationId); } else if (AndroidVersion.isLollipopOrAbove()) { // Android For Work restrictionsManager = (RestrictionsManager) activity.getSystemService(Context.RESTRICTIONS_SERVICE); restrictions = restrictionsManager.getApplicationRestrictions(); if (restrictions != null && !restrictions.isEmpty()) { EventBusManager.getInstance().post(new MDMEvent()); }/* w w w . ja v a 2 s . co m*/ } }
From source file:com.example.android.apprestrictionschema.AppRestrictionSchemaFragment.java
private void resolveRestrictions() { RestrictionsManager manager = (RestrictionsManager) getActivity() .getSystemService(Context.RESTRICTIONS_SERVICE); Bundle restrictions = manager.getApplicationRestrictions(); List<RestrictionEntry> entries = manager .getManifestRestrictions(getActivity().getApplicationContext().getPackageName()); for (RestrictionEntry entry : entries) { String key = entry.getKey(); Log.d(TAG, "key: " + key); if (key.equals(KEY_CAN_SAY_HELLO)) { updateCanSayHello(entry, restrictions); } else if (key.equals(KEY_MESSAGE)) { updateMessage(entry, restrictions); } else if (key.equals(KEY_NUMBER)) { updateNumber(entry, restrictions); } else if (key.equals(KEY_RANK)) { updateRank(entry, restrictions); } else if (key.equals(KEY_APPROVALS)) { updateApprovals(entry, restrictions); } else if (key.equals(KEY_ITEMS)) { updateItems(restrictions);// www. j av a2s . c o m } } }
From source file:com.example.android.apprestrictionenforcer.AppRestrictionEnforcerFragment.java
/** * Loads the restrictions for the AppRestrictionSchema sample. * * @param activity The activity/* w ww . ja va2 s . co m*/ */ private void loadRestrictions(Activity activity) { RestrictionsManager manager = (RestrictionsManager) activity.getSystemService(Context.RESTRICTIONS_SERVICE); List<RestrictionEntry> restrictions = manager .getManifestRestrictions(Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA); SharedPreferences prefs = activity.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE); for (RestrictionEntry restriction : restrictions) { String key = restriction.getKey(); if (RESTRICTION_KEY_SAY_HELLO.equals(key)) { updateCanSayHello(prefs.getBoolean(RESTRICTION_KEY_SAY_HELLO, restriction.getSelectedState())); } else if (RESTRICTION_KEY_MESSAGE.equals(key)) { updateMessage(prefs.getString(RESTRICTION_KEY_MESSAGE, restriction.getSelectedString())); } else if (RESTRICTION_KEY_NUMBER.equals(key)) { updateNumber(prefs.getInt(RESTRICTION_KEY_NUMBER, restriction.getIntValue())); } else if (RESTRICTION_KEY_RANK.equals(key)) { updateRank(activity, restriction.getChoiceValues(), prefs.getString(RESTRICTION_KEY_RANK, restriction.getSelectedString())); } else if (RESTRICTION_KEY_APPROVALS.equals(key)) { updateApprovals(activity, restriction.getChoiceValues(), TextUtils.split( prefs.getString(RESTRICTION_KEY_APPROVALS, TextUtils.join(DELIMETER, restriction.getAllSelectedStrings())), DELIMETER)); } else if (BUNDLE_SUPPORTED && RESTRICTION_KEY_ITEMS.equals(key)) { String itemsString = prefs.getString(RESTRICTION_KEY_ITEMS, ""); HashMap<String, String> items = new HashMap<>(); for (String itemString : TextUtils.split(itemsString, DELIMETER)) { String[] strings = itemString.split(SEPARATOR, 2); items.put(strings[0], strings[1]); } updateItems(activity, items); } } }
From source file:com.google.codelabs.appauth.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 {/*from ww w .java 2 s.com*/ Toast.makeText(this, R.string.restrictions_pending_block_user, Toast.LENGTH_LONG).show(); finish(); } } }