Example usage for android.content RestrictionsManager getApplicationRestrictions

List of usage examples for android.content RestrictionsManager getApplicationRestrictions

Introduction

In this page you can find the example usage for android.content RestrictionsManager getApplicationRestrictions.

Prototype

public Bundle getApplicationRestrictions() 

Source Link

Document

Returns any available set of application-specific restrictions applicable to this application.

Usage

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);//from  w w  w.j  a v  a  2 s .  c o  m
        }
    }
}

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   w  w w .j a  va2  s.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: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 {/*w  ww  .  j av a2s .co m*/
            Toast.makeText(this, R.string.restrictions_pending_block_user, Toast.LENGTH_LONG).show();
            finish();
        }
    }
}