Search in sources :

Example 6 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationSettingsBase method setRestrictedIfNotificationFeaturesDisabled.

private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry, CharSequence entryValue, int keyguardNotificationFeatures) {
    EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(mContext, keyguardNotificationFeatures, mUserId);
    if (admin != null) {
        RestrictedItem item = new RestrictedItem(entry, entryValue, admin);
        mVisibilityOverride.addRestrictedItem(item);
    }
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) RestrictedItem(com.android.settings.notification.RestrictedDropDownPreference.RestrictedItem)

Example 7 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiEnabler method handleWifiStateChanged.

private void handleWifiStateChanged(int state) {
    // Clear any previous state
    mSwitchBar.setDisabledByAdmin(null);
    switch(state) {
        case WifiManager.WIFI_STATE_ENABLING:
            mSwitchBar.setEnabled(false);
            break;
        case WifiManager.WIFI_STATE_ENABLED:
            setSwitchBarChecked(true);
            mSwitchBar.setEnabled(true);
            updateSearchIndex(true);
            break;
        case WifiManager.WIFI_STATE_DISABLING:
            mSwitchBar.setEnabled(false);
            break;
        case WifiManager.WIFI_STATE_DISABLED:
            setSwitchBarChecked(false);
            mSwitchBar.setEnabled(true);
            updateSearchIndex(false);
            break;
        default:
            setSwitchBarChecked(false);
            mSwitchBar.setEnabled(true);
            updateSearchIndex(false);
    }
    if (mayDisableTethering(!mSwitchBar.isChecked())) {
        if (RestrictedLockUtils.hasBaseUserRestriction(mContext, UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId())) {
            mSwitchBar.setEnabled(false);
        } else {
            final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(mContext, UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId());
            mSwitchBar.setDisabledByAdmin(admin);
        }
    }
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 8 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MasterClearConfirm method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(getActivity(), UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId());
    if (RestrictedLockUtils.hasBaseUserRestriction(getActivity(), UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
        return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
    } else if (admin != null) {
        View view = inflater.inflate(R.layout.admin_support_details_empty_view, null);
        ShowAdminSupportDetailsDialog.setAdminSupportDetails(getActivity(), view, admin, false);
        view.setVisibility(View.VISIBLE);
        return view;
    }
    mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
    establishFinalConfirmationState();
    setAccessibilityTitle();
    return mContentView;
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) TextView(android.widget.TextView) View(android.view.View)

Example 9 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MasterClear method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getContext();
    final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(context, UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId());
    final UserManager um = UserManager.get(context);
    final boolean disallow = !um.isAdminUser() || RestrictedLockUtils.hasBaseUserRestriction(context, UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId());
    if (disallow && !Utils.isCarrierDemoUser(context)) {
        return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
    } else if (admin != null) {
        View view = inflater.inflate(R.layout.admin_support_details_empty_view, null);
        ShowAdminSupportDetailsDialog.setAdminSupportDetails(getActivity(), view, admin, false);
        view.setVisibility(View.VISIBLE);
        return view;
    }
    mContentView = inflater.inflate(R.layout.master_clear, null);
    establishInitialState();
    return mContentView;
}
Also used : Context(android.content.Context) UserManager(android.os.UserManager) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) View(android.view.View) TextView(android.widget.TextView)

Example 10 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ChooseAccountActivity method onAuthDescriptionsUpdated.

private void onAuthDescriptionsUpdated() {
    // Create list of providers to show on preference screen
    for (int i = 0; i < mAuthDescs.length; i++) {
        String accountType = mAuthDescs[i].type;
        if (!Utils.showAccount(getPreferenceScreen().getContext(), accountType)) {
            // If needn't to show the account, skip this account.
            continue;
        }
        CharSequence providerName = getLabelForType(accountType);
        // Skip preferences for authorities not specified. If no authorities specified,
        // then include them all.
        ArrayList<String> accountAuths = getAuthoritiesForAccountType(accountType);
        boolean addAccountPref = true;
        if (mAuthorities != null && mAuthorities.length > 0 && accountAuths != null) {
            addAccountPref = false;
            for (int k = 0; k < mAuthorities.length; k++) {
                if (accountAuths.contains(mAuthorities[k])) {
                    addAccountPref = true;
                    break;
                }
            }
        }
        if (addAccountPref && mAccountTypesFilter != null && !mAccountTypesFilter.contains(accountType)) {
            addAccountPref = false;
        }
        if (addAccountPref) {
            mProviderList.add(new ProviderEntry(providerName, accountType));
        } else {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Skipped pref " + providerName + ": has no authority we need");
            }
        }
    }
    final Context context = getPreferenceScreen().getContext();
    if (mProviderList.size() == 1 && getResources().getBoolean(R.bool.config_show_email)) {
        // There's only one provider that matches. If it is disabled by admin show the
        // support dialog otherwise run it.
        EnforcedAdmin admin = RestrictedLockUtils.checkIfAccountManagementDisabled(context, mProviderList.get(0).type, mUserHandle.getIdentifier());
        if (admin != null) {
            setResult(RESULT_CANCELED, RestrictedLockUtils.getShowAdminSupportDetailsIntent(context, admin));
            finishAccountActivity();
        } else {
            finishWithAccountType(mProviderList.get(0).type);
        }
    } else if (mProviderList.size() > 0) {
        Collections.sort(mProviderList);
        mAddAccountGroup.removeAll();
        for (ProviderEntry pref : mProviderList) {
            Drawable drawable = getDrawableForType(pref.type);
            ProviderPreference p = new ProviderPreference(getPreferenceScreen().getContext(), pref.type, drawable, pref.name);
            p.checkAccountManagementAndSetDisabled(mUserHandle.getIdentifier());
            mAddAccountGroup.addPreference(p);
        }
    } else {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            final StringBuilder auths = new StringBuilder();
            for (String a : mAuthorities) {
                auths.append(a);
                auths.append(' ');
            }
            Log.v(TAG, "No providers found for authorities: " + auths);
        }
        setResult(RESULT_CANCELED);
        finishAccountActivity();
    }
}
Also used : Context(android.content.Context) Drawable(android.graphics.drawable.Drawable) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Aggregations

EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)42 View (android.view.View)5 Context (android.content.Context)4 UserManager (android.os.UserManager)3 RestrictedPreference (com.android.settingslib.RestrictedPreference)3 ComponentName (android.content.ComponentName)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Preference (android.support.v7.preference.Preference)2 TextView (android.widget.TextView)2 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)1 Activity (android.app.Activity)1 DevicePolicyManager (android.app.admin.DevicePolicyManager)1 ContentResolver (android.content.ContentResolver)1 ActivityInfo (android.content.pm.ActivityInfo)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 ServiceInfo (android.content.pm.ServiceInfo)1 ConnectivityManager (android.net.ConnectivityManager)1 Bundle (android.os.Bundle)1