Search in sources :

Example 76 with PreferenceGroup

use of android.support.v7.preference.PreferenceGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DevelopmentSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
    mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    mWebViewUpdateService = IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
    mOemUnlockManager = (PersistentDataBlockManager) getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
    mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    mDpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
    mUm = (UserManager) getSystemService(Context.USER_SERVICE);
    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    setIfOnlyAvailableForAdmins(true);
    if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) {
        // Block access to developer options if the user is not the owner, if user policy
        // restricts it, or if the device has not been provisioned
        mUnavailable = true;
        setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
        return;
    }
    addPreferencesFromResource(R.xml.development_prefs);
    final PreferenceGroup debugDebuggingCategory = (PreferenceGroup) findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
    mEnableAdb = findAndInitSwitchPref(ENABLE_ADB);
    mAdbAlwaysNotify = findAndInitSwitchPref(ADB_ALWAYS_NOTIFY);
    mAdbOverNetwork = findAndInitSwitchPref(ADB_TCPIP);
    mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);
    if (!SystemProperties.getBoolean("ro.adb.secure", false)) {
        if (debugDebuggingCategory != null) {
            debugDebuggingCategory.removePreference(mClearAdbKeys);
        }
    }
    mAllPrefs.add(mClearAdbKeys);
    mEnableTerminal = findAndInitSwitchPref(ENABLE_TERMINAL);
    if (!isPackageInstalled(getActivity(), TERMINAL_APP_PACKAGE)) {
        debugDebuggingCategory.removePreference(mEnableTerminal);
        mEnableTerminal = null;
    }
    mBugreport = findPreference(BUGREPORT);
    mBugreportInPower = findAndInitSwitchPref(BUGREPORT_IN_POWER_KEY);
    mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
    mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
    mEnableOemUnlock = (RestrictedSwitchPreference) findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
    if (!showEnableOemUnlockPreference()) {
        removePreference(mEnableOemUnlock);
        mEnableOemUnlock = null;
    }
    mDebugViewAttributes = findAndInitSwitchPref(DEBUG_VIEW_ATTRIBUTES);
    mForceAllowOnExternal = findAndInitSwitchPref(FORCE_ALLOW_ON_EXTERNAL_KEY);
    mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
    mAllPrefs.add(mPassword);
    mForceAuthorizeSubstratumPackages = findAndInitSwitchPref(FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES);
    if (!mUm.isAdminUser()) {
        disableForUser(mEnableAdb);
        disableForUser(mClearAdbKeys);
        disableForUser(mEnableTerminal);
        disableForUser(mPassword);
        disableForUser(mForceAuthorizeSubstratumPackages);
    }
    mDebugAppPref = findPreference(DEBUG_APP_KEY);
    mAllPrefs.add(mDebugAppPref);
    mWaitForDebugger = findAndInitSwitchPref(WAIT_FOR_DEBUGGER_KEY);
    mMockLocationAppPref = findPreference(MOCK_LOCATION_APP_KEY);
    mAllPrefs.add(mMockLocationAppPref);
    mVerifyAppsOverUsb = findAndInitSwitchPref(VERIFY_APPS_OVER_USB_KEY);
    if (!showVerifierSetting()) {
        if (debugDebuggingCategory != null) {
            debugDebuggingCategory.removePreference(mVerifyAppsOverUsb);
        } else {
            mVerifyAppsOverUsb.setEnabled(false);
        }
    }
    mStrictMode = findAndInitSwitchPref(STRICT_MODE_KEY);
    mPointerLocation = findAndInitSwitchPref(POINTER_LOCATION_KEY);
    mShowTouches = findAndInitSwitchPref(SHOW_TOUCHES_KEY);
    mShowScreenUpdates = findAndInitSwitchPref(SHOW_SCREEN_UPDATES_KEY);
    mDisableOverlays = findAndInitSwitchPref(DISABLE_OVERLAYS_KEY);
    mShowCpuInfo = findAndInitSwitchPref(SHOW_CPU_INFO_KEY);
    mForceHardwareUi = findAndInitSwitchPref(FORCE_HARDWARE_UI_KEY);
    mForceMsaa = findAndInitSwitchPref(FORCE_MSAA_KEY);
    mTrackFrameTime = addListPreference(TRACK_FRAME_TIME_KEY);
    mShowNonRectClip = addListPreference(SHOW_NON_RECTANGULAR_CLIP_KEY);
    mShowHwScreenUpdates = findAndInitSwitchPref(SHOW_HW_SCREEN_UPDATES_KEY);
    mShowHwLayersUpdates = findAndInitSwitchPref(SHOW_HW_LAYERS_UPDATES_KEY);
    mDebugLayout = findAndInitSwitchPref(DEBUG_LAYOUT_KEY);
    mForceRtlLayout = findAndInitSwitchPref(FORCE_RTL_LAYOUT_KEY);
    mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
    mWifiDisplayCertification = findAndInitSwitchPref(WIFI_DISPLAY_CERTIFICATION_KEY);
    mWifiVerboseLogging = findAndInitSwitchPref(WIFI_VERBOSE_LOGGING_KEY);
    mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
    mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
    mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
    mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
    if ("1".equals(SystemProperties.get("ro.debuggable", "0"))) {
        mLogpersist = addListPreference(SELECT_LOGPERSIST_KEY);
    } else {
        mLogpersist = (ListPreference) findPreference(SELECT_LOGPERSIST_KEY);
        if (mLogpersist != null) {
            mLogpersist.setEnabled(false);
            if (debugDebuggingCategory != null) {
                debugDebuggingCategory.removePreference(mLogpersist);
            }
        }
        mLogpersist = null;
    }
    mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
    mWebViewProvider = addListPreference(WEBVIEW_PROVIDER_KEY);
    mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY);
    mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
    mOverlayDisplayDevices = addListPreference(OVERLAY_DISPLAY_DEVICES_KEY);
    mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
    mUSBAudio = findAndInitSwitchPref(USB_AUDIO_KEY);
    mForceResizable = findAndInitSwitchPref(FORCE_RESIZABLE_KEY);
    mWindowAnimationScale = findAndInitAnimationScalePreference(WINDOW_ANIMATION_SCALE_KEY);
    mTransitionAnimationScale = findAndInitAnimationScalePreference(TRANSITION_ANIMATION_SCALE_KEY);
    mAnimatorDurationScale = findAndInitAnimationScalePreference(ANIMATOR_DURATION_SCALE_KEY);
    mImmediatelyDestroyActivities = (SwitchPreference) findPreference(IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
    mAllPrefs.add(mImmediatelyDestroyActivities);
    mResetSwitchPrefs.add(mImmediatelyDestroyActivities);
    mAppProcessLimit = addListPreference(APP_PROCESS_LIMIT_KEY);
    mShowAllANRs = (SwitchPreference) findPreference(SHOW_ALL_ANRS_KEY);
    mAllPrefs.add(mShowAllANRs);
    mResetSwitchPrefs.add(mShowAllANRs);
    Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
    if (hdcpChecking != null) {
        mAllPrefs.add(hdcpChecking);
        removePreferenceForProduction(hdcpChecking);
    }
    PreferenceScreen convertFbePreference = (PreferenceScreen) findPreference(KEY_CONVERT_FBE);
    try {
        IBinder service = ServiceManager.getService("mount");
        IMountService mountService = IMountService.Stub.asInterface(service);
        if (!mountService.isConvertibleToFBE()) {
            removePreference(KEY_CONVERT_FBE);
        } else if ("file".equals(SystemProperties.get("ro.crypto.type", "none"))) {
            convertFbePreference.setEnabled(false);
            convertFbePreference.setSummary(getResources().getString(R.string.convert_to_file_encryption_done));
        }
    } catch (RemoteException e) {
        removePreference(KEY_CONVERT_FBE);
    }
    mOtaDisableAutomaticUpdate = findAndInitSwitchPref(OTA_DISABLE_AUTOMATIC_UPDATE_KEY);
    if (!SystemProperties.getBoolean("ro.build.ab_update", false)) {
        removePreference(mOtaDisableAutomaticUpdate);
        mOtaDisableAutomaticUpdate = null;
    }
    mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE);
    mColorModePreference.updateCurrentAndSupported();
    if (mColorModePreference.getColorModeCount() < 2) {
        removePreference(KEY_COLOR_MODE);
        mColorModePreference = null;
    }
    updateWebViewProviderOptions();
    mColorTemperaturePreference = (SwitchPreference) findPreference(COLOR_TEMPERATURE_KEY);
    if (getResources().getBoolean(R.bool.config_enableColorTemperature)) {
        mAllPrefs.add(mColorTemperaturePreference);
        mResetSwitchPrefs.add(mColorTemperaturePreference);
    } else {
        removePreference(COLOR_TEMPERATURE_KEY);
        mColorTemperaturePreference = null;
    }
    mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY);
    mRootAccess.setOnPreferenceChangeListener(this);
    mRootAppops = (Preference) findPreference(ROOT_APPOPS_KEY);
    mRootAppops.setOnPreferenceClickListener(this);
    if (!removeRootOptionsIfRequired()) {
        if (FileUtils.fileExists("/system/xbin/su")) {
            mRootAccess.setEntries(R.array.root_access_entries);
            mRootAccess.setEntryValues(R.array.root_access_values);
        } else {
            mRootAccess.setEntries(R.array.root_access_entries_adb);
            mRootAccess.setEntryValues(R.array.root_access_values_adb);
        }
        mAllPrefs.add(mRootAccess);
        mAllPrefs.add(mRootAppops);
    }
    mDevelopmentTools = (PreferenceScreen) findPreference(DEVELOPMENT_TOOLS);
    mAllPrefs.add(mDevelopmentTools);
}
Also used : IBinder(android.os.IBinder) PreferenceScreen(android.support.v7.preference.PreferenceScreen) ListPreference(android.support.v7.preference.ListPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) IMountService(android.os.storage.IMountService) PreferenceGroup(android.support.v7.preference.PreferenceGroup) RemoteException(android.os.RemoteException)

Example 77 with PreferenceGroup

use of android.support.v7.preference.PreferenceGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class Utils method addAll.

private static void addAll(PreferenceGroup group, List<String> ret) {
    if (group == null)
        return;
    for (int i = 0; i < group.getPreferenceCount(); i++) {
        Preference pref = group.getPreference(i);
        ret.add(pref.getKey());
        if (pref instanceof PreferenceGroup) {
            addAll((PreferenceGroup) pref, ret);
        }
    }
}
Also used : Preference(android.support.v7.preference.Preference) PreferenceGroup(android.support.v7.preference.PreferenceGroup)

Example 78 with PreferenceGroup

use of android.support.v7.preference.PreferenceGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ApnSettings method fillList.

private void fillList() {
    final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    final String mccmnc = mSubscriptionInfo == null ? "" : tm.getSimOperator(mSubscriptionInfo.getSubscriptionId());
    Log.d(TAG, "mccmnc = " + mccmnc);
    StringBuilder where = new StringBuilder("numeric=\"" + mccmnc + "\" AND NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND user_visible!=0");
    if (SystemProperties.getBoolean("persist.sys.hideapn", true)) {
        Log.d(TAG, "hiden apn feature enable.");
        if (getResources().getBoolean(R.bool.config_hide_ims_apns)) {
            mHideImsApn = true;
        }
        // Filer fota and dm for specail carrier
        if (getResources().getBoolean(R.bool.config_hide_dm_enabled)) {
            for (String plmn : getResources().getStringArray(R.array.hidedm_plmn_list)) {
                if (plmn.equals(mccmnc)) {
                    where.append(" and name <>\"" + APN_NAME_DM + "\"");
                    break;
                }
            }
        }
        if (getResources().getBoolean(R.bool.config_hidesupl_enable)) {
            boolean needHideSupl = false;
            for (String plmn : getResources().getStringArray(R.array.hidesupl_plmn_list)) {
                if (plmn.equals(mccmnc)) {
                    needHideSupl = true;
                    break;
                }
            }
            if (needHideSupl) {
                where.append(" and type <>\"" + PhoneConstants.APN_TYPE_SUPL + "\"");
            }
        }
        // Hide mms if config is true
        if (getResources().getBoolean(R.bool.config_hide_mms_enable)) {
            where.append(" and type <>\"" + PhoneConstants.APN_TYPE_MMS + "\"");
        }
    }
    if (getResources().getBoolean(R.bool.config_regional_hide_ims_and_dun_apns)) {
        where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_DUN + "\"");
        where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_IMS + "\"");
    }
    if (mHideImsApn) {
        where.append(" AND NOT (type='ims')");
    }
    if (isOperatorIccId()) {
        where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_EMERGENCY + "\"");
        where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_IMS + "\"");
    }
    Log.d(TAG, "where---" + where);
    Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] { "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only", "bearer", "bearer_bitmask" }, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
    if (cursor != null) {
        IccRecords r = null;
        if (mUiccController != null && mSubscriptionInfo != null) {
            r = mUiccController.getIccRecords(SubscriptionManager.getPhoneId(mSubscriptionInfo.getSubscriptionId()), UiccController.APP_FAM_3GPP);
        }
        PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
        apnList.removeAll();
        ArrayList<ApnPreference> mnoApnList = new ArrayList<ApnPreference>();
        ArrayList<ApnPreference> mvnoApnList = new ArrayList<ApnPreference>();
        ArrayList<ApnPreference> mnoMmsApnList = new ArrayList<ApnPreference>();
        ArrayList<ApnPreference> mvnoMmsApnList = new ArrayList<ApnPreference>();
        mSelectedKey = getSelectedApnKey();
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            String name = cursor.getString(NAME_INDEX);
            String apn = cursor.getString(APN_INDEX);
            String key = cursor.getString(ID_INDEX);
            String type = cursor.getString(TYPES_INDEX);
            String mvnoType = cursor.getString(MVNO_TYPE_INDEX);
            String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
            boolean readOnly = (cursor.getInt(RO_INDEX) == 1);
            String localizedName = getLocalizedName(getActivity(), cursor, NAME_INDEX);
            if (!TextUtils.isEmpty(localizedName)) {
                name = localizedName;
            }
            int bearer = cursor.getInt(BEARER_INDEX);
            int bearerBitMask = cursor.getInt(BEARER_BITMASK_INDEX);
            int fullBearer = bearer | bearerBitMask;
            int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId() : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
            int radioTech = networkTypeToRilRidioTechnology(TelephonyManager.getDefault().getDataNetworkType(subId));
            if (!ServiceState.bitmaskHasTech(fullBearer, radioTech) && (bearer != 0 || bearerBitMask != 0)) {
                // In OOS, show APN with bearer as default
                if ((radioTech != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) || (bearer == 0 && radioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)) {
                    cursor.moveToNext();
                    continue;
                }
            }
            ApnPreference pref = new ApnPreference(getPrefContext());
            pref.setApnReadOnly(readOnly);
            pref.setKey(key);
            pref.setTitle(name);
            pref.setSummary(apn);
            pref.setPersistent(false);
            pref.setOnPreferenceChangeListener(this);
            boolean selectable = ((type == null) || !type.equals("mms"));
            pref.setSelectable(selectable);
            if (selectable) {
                if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
                    pref.setChecked();
                }
                addApnToList(pref, mnoApnList, mvnoApnList, r, mvnoType, mvnoMatchData);
            } else {
                addApnToList(pref, mnoMmsApnList, mvnoMmsApnList, r, mvnoType, mvnoMatchData);
            }
            cursor.moveToNext();
        }
        cursor.close();
        if (!mvnoApnList.isEmpty()) {
            mnoApnList = mvnoApnList;
            mnoMmsApnList = mvnoMmsApnList;
        // Also save the mvno info
        }
        for (Preference preference : mnoApnList) {
            apnList.addPreference(preference);
        }
        for (Preference preference : mnoMmsApnList) {
            apnList.addPreference(preference);
        }
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager) IccRecords(com.android.internal.telephony.uicc.IccRecords) Preference(android.support.v7.preference.Preference) ArrayList(java.util.ArrayList) PreferenceGroup(android.support.v7.preference.PreferenceGroup) Cursor(android.database.Cursor)

Example 79 with PreferenceGroup

use of android.support.v7.preference.PreferenceGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DeviceInfoSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mUm = UserManager.get(getActivity());
    addPreferencesFromResource(R.xml.device_info_settings);
    setStringSummary(KEY_FIRMWARE_VERSION, Build.VERSION.RELEASE);
    findPreference(KEY_FIRMWARE_VERSION).setEnabled(true);
    final String patch = DeviceInfoUtils.getSecurityPatch();
    if (!TextUtils.isEmpty(patch)) {
        setStringSummary(KEY_SECURITY_PATCH, patch);
    } else {
        getPreferenceScreen().removePreference(findPreference(KEY_SECURITY_PATCH));
    }
    setValueSummary(KEY_BASEBAND_VERSION, "gsm.version.baseband");
    setValueSummary(KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID);
    setStringSummary(KEY_DEVICE_MODEL, Build.MODEL);
    setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY);
    setValueSummary(KEY_MOD_BUILD_DATE, "ro.build.date");
    findPreference(KEY_BUILD_NUMBER).setEnabled(true);
    setValueSummary(KEY_BUILD_TYPE, "rr.build.type");
    setValueSummary(KEY_MAINTAINER, "ro.build.user");
    setValueSummary(KEY_DEVICE_NAME, "ro.rr.device");
    setValueSummary(KEY_DEVICE_CPU, "ro.product.cpu.abi");
    setValueSummary(KEY_MOD_VERSION, "ro.modversion");
    findPreference(KEY_MOD_VERSION).setEnabled(true);
    findPreference(KEY_BUILD_TYPE).setEnabled(true);
    findPreference(KEY_MAINTAINER).setEnabled(true);
    findPreference(KEY_DEVICE_NAME).setEnabled(true);
    findPreference(KEY_DEVICE_CPU).setEnabled(true);
    setStringSummary(KEY_KERNEL_VERSION, getFormattedKernelVersion());
    findPreference(KEY_KERNEL_VERSION).setEnabled(true);
    String buildtype = SystemProperties.get("rr.build.type", "unofficial");
    if (buildtype.equalsIgnoreCase("unofficial")) {
        removePreference(KEY_MAINTAINER);
    }
    setValueSummary(KEY_QGP_VERSION, PROPERTY_QGP_VERSION);
    // Remove QGP Version if property is not present
    removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_QGP_VERSION, PROPERTY_QGP_VERSION);
    setValueSummary(KEY_MBN_VERSION, PROPERTY_MBN_VERSION);
    removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_MBN_VERSION, PROPERTY_MBN_VERSION);
    if (!SELinux.isSELinuxEnabled()) {
        String status = getResources().getString(R.string.selinux_status_disabled);
        setStringSummary(KEY_SELINUX_STATUS, status);
    } else if (!SELinux.isSELinuxEnforced()) {
        String status = getResources().getString(R.string.selinux_status_permissive);
        setStringSummary(KEY_SELINUX_STATUS, status);
    }
    // Remove selinux information if property is not present
    removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_SELINUX_STATUS, PROPERTY_SELINUX_STATUS);
    String memInfo = getMemInfo();
    if (memInfo != null) {
        setStringSummary(KEY_DEVICE_MEMORY, memInfo);
    } else {
        getPreferenceScreen().removePreference(findPreference(KEY_DEVICE_MEMORY));
    }
    // Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set
    removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_SAFETY_LEGAL, PROPERTY_URL_SAFETYLEGAL);
    // Remove Equipment id preference if FCC ID is not set by RIL
    removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID);
    // Remove Baseband version if wifi-only device
    if (Utils.isWifiOnly(getActivity())) {
        getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION));
    }
    // Dont show feedback option if there is no reporter.
    if (TextUtils.isEmpty(DeviceInfoUtils.getFeedbackReporterPackage(getActivity()))) {
        getPreferenceScreen().removePreference(findPreference(KEY_DEVICE_FEEDBACK));
    }
    /*
         * Settings is a generic app and should not contain any device-specific
         * info.
         */
    final Activity act = getActivity();
    // These are contained by the root preference screen
    PreferenceGroup parentPreference = getPreferenceScreen();
    if (mUm.isAdminUser()) {
        Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_SYSTEM_UPDATE_SETTINGS, Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
    } else {
        // Remove for secondary users
        removePreference(KEY_SYSTEM_UPDATE_SETTINGS);
    }
    // Read platform settings for additional system update setting
    removePreferenceIfBoolFalse(KEY_UPDATE_SETTING, R.bool.config_additional_system_update_setting_enable);
    // Remove manual entry if none present.
    removePreferenceIfBoolFalse(KEY_MANUAL, R.bool.config_show_manual);
    setStringSummary(KEY_BUILD_NUMBER, "Resurrection Remix Nougat 7.1.2_r8 - N2G47O");
    // Remove regulatory labels if no activity present to handle intent.
    removePreferenceIfActivityMissing(KEY_REGULATORY_INFO, Settings.ACTION_SHOW_REGULATORY_INFO);
    removePreferenceIfActivityMissing("safety_info", "android.settings.SHOW_SAFETY_AND_REGULATORY_INFO");
}
Also used : Activity(android.app.Activity) PreferenceGroup(android.support.v7.preference.PreferenceGroup)

Example 80 with PreferenceGroup

use of android.support.v7.preference.PreferenceGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecuritySettings method createPreferenceHierarchy.

/**
     * Important!
     *
     * Don't forget to update the SecuritySearchIndexProvider if you are doing any change in the
     * logic or adding/removing preferences here.
     */
private PreferenceScreen createPreferenceHierarchy() {
    PreferenceScreen root = getPreferenceScreen();
    if (root != null) {
        root.removeAll();
    }
    addPreferencesFromResource(R.xml.security_settings);
    root = getPreferenceScreen();
    // Add options for lock/unlock screen
    final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils, mManagedPasswordProvider, MY_USER_ID);
    addPreferencesFromResource(resid);
    // DO or PO installed in the user may disallow to change password.
    disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE, MY_USER_ID);
    mProfileChallengeUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
    if (mProfileChallengeUserId != UserHandle.USER_NULL && mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
        addPreferencesFromResource(R.xml.security_settings_profile);
        addPreferencesFromResource(R.xml.security_settings_unification);
        final int profileResid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils, mManagedPasswordProvider, mProfileChallengeUserId);
        addPreferencesFromResource(profileResid);
        maybeAddFingerprintPreference(root, mProfileChallengeUserId);
        if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
            final Preference lockPreference = root.findPreference(KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
            final String summary = getContext().getString(R.string.lock_settings_profile_unified_summary);
            lockPreference.setSummary(summary);
            lockPreference.setEnabled(false);
            // PO may disallow to change password for the profile, but screen lock and managed
            // profile's lock is the same. Disable main "Screen lock" menu.
            disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE, mProfileChallengeUserId);
        } else {
            // PO may disallow to change profile password, and the profile's password is
            // separated from screen lock password. Disable profile specific "Screen lock" menu.
            disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE_PROFILE, mProfileChallengeUserId);
        }
    }
    Preference unlockSetOrChange = findPreference(KEY_UNLOCK_SET_OR_CHANGE);
    if (unlockSetOrChange instanceof GearPreference) {
        ((GearPreference) unlockSetOrChange).setOnGearClickListener(this);
    }
    // Add options for device encryption
    mIsAdmin = mUm.isAdminUser();
    if (mIsAdmin) {
        if (LockPatternUtils.isDeviceEncryptionEnabled()) {
            // The device is currently encrypted.
            addPreferencesFromResource(R.xml.security_settings_encrypted);
        } else {
            // This device supports encryption but isn't encrypted.
            addPreferencesFromResource(R.xml.security_settings_unencrypted);
        }
    }
    // Fingerprint and trust agents
    PreferenceGroup securityCategory = (PreferenceGroup) root.findPreference(KEY_SECURITY_CATEGORY);
    if (securityCategory != null) {
        maybeAddFingerprintPreference(securityCategory, UserHandle.myUserId());
        addTrustAgentSettings(securityCategory);
    }
    mVisiblePatternProfile = (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN_PROFILE);
    mUnifyProfile = (SwitchPreference) root.findPreference(KEY_UNIFICATION);
    // Append the rest of the settings
    addPreferencesFromResource(R.xml.security_settings_misc);
    // Do not display SIM lock for devices without an Icc card
    CarrierConfigManager cfgMgr = (CarrierConfigManager) getActivity().getSystemService(Context.CARRIER_CONFIG_SERVICE);
    PersistableBundle b = cfgMgr.getConfig();
    PreferenceGroup iccLockGroup = (PreferenceGroup) root.findPreference(KEY_SIM_LOCK);
    Preference iccLock = root.findPreference(KEY_SIM_LOCK_SETTINGS);
    if (!mIsAdmin || b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) {
        root.removePreference(iccLockGroup);
    } else {
        SubscriptionManager subMgr = SubscriptionManager.from(getActivity());
        TelephonyManager tm = TelephonyManager.getDefault();
        int numPhones = tm.getPhoneCount();
        boolean hasAnySim = false;
        for (int i = 0; i < numPhones; i++) {
            final Preference pref;
            if (numPhones > 1) {
                SubscriptionInfo sir = subMgr.getActiveSubscriptionInfoForSimSlotIndex(i);
                if (sir == null) {
                    continue;
                }
                pref = new Preference(getActivity());
                pref.setOrder(iccLock.getOrder());
                pref.setTitle(getString(R.string.sim_card_lock_settings_title, i + 1));
                pref.setSummary(sir.getDisplayName());
                Intent intent = new Intent(getActivity(), com.android.settings.Settings.IccLockSettingsActivity.class);
                intent.putExtra(IccLockSettings.EXTRA_SUB_ID, sir.getSubscriptionId());
                intent.putExtra(IccLockSettings.EXTRA_SUB_DISPLAY_NAME, sir.getDisplayName());
                intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
                pref.setIntent(intent);
                iccLockGroup.addPreference(pref);
            } else {
                pref = iccLock;
            }
            // Do not display SIM lock for devices without an Icc card
            hasAnySim |= tm.hasIccCard(i);
            int simState = tm.getSimState(i);
            boolean simPresent = simState != TelephonyManager.SIM_STATE_ABSENT && simState != TelephonyManager.SIM_STATE_UNKNOWN && simState != TelephonyManager.SIM_STATE_CARD_IO_ERROR;
            if (!simPresent) {
                pref.setEnabled(false);
            }
        }
        if (!hasAnySim) {
            root.removePreference(iccLockGroup);
        } else if (numPhones > 1) {
            iccLockGroup.removePreference(iccLock);
        }
    }
    if (Settings.System.getInt(getContentResolver(), Settings.System.LOCK_TO_APP_ENABLED, 0) != 0) {
        root.findPreference(KEY_SCREEN_PINNING).setSummary(getResources().getString(R.string.switch_on_text));
    }
    // Show password
    mShowPassword = (SwitchPreference) root.findPreference(KEY_SHOW_PASSWORD);
    mResetCredentials = (RestrictedPreference) root.findPreference(KEY_RESET_CREDENTIALS);
    // Credential storage
    final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
    // needs to be initialized for onResume()
    mKeyStore = KeyStore.getInstance();
    if (!RestrictedLockUtils.hasBaseUserRestriction(getActivity(), UserManager.DISALLOW_CONFIG_CREDENTIALS, MY_USER_ID)) {
        RestrictedPreference userCredentials = (RestrictedPreference) root.findPreference(KEY_USER_CREDENTIALS);
        userCredentials.checkRestrictionAndSetDisabled(UserManager.DISALLOW_CONFIG_CREDENTIALS);
        RestrictedPreference credentialStorageType = (RestrictedPreference) root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE);
        credentialStorageType.checkRestrictionAndSetDisabled(UserManager.DISALLOW_CONFIG_CREDENTIALS);
        RestrictedPreference installCredentials = (RestrictedPreference) root.findPreference(KEY_CREDENTIALS_INSTALL);
        installCredentials.checkRestrictionAndSetDisabled(UserManager.DISALLOW_CONFIG_CREDENTIALS);
        mResetCredentials.checkRestrictionAndSetDisabled(UserManager.DISALLOW_CONFIG_CREDENTIALS);
        final int storageSummaryRes = mKeyStore.isHardwareBacked() ? R.string.credential_storage_type_hardware : R.string.credential_storage_type_software;
        credentialStorageType.setSummary(storageSummaryRes);
    } else {
        PreferenceGroup credentialsManager = (PreferenceGroup) root.findPreference(KEY_CREDENTIALS_MANAGER);
        credentialsManager.removePreference(root.findPreference(KEY_RESET_CREDENTIALS));
        credentialsManager.removePreference(root.findPreference(KEY_CREDENTIALS_INSTALL));
        credentialsManager.removePreference(root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE));
        credentialsManager.removePreference(root.findPreference(KEY_USER_CREDENTIALS));
    }
    // Application install
    PreferenceGroup deviceAdminCategory = (PreferenceGroup) root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
    mToggleAppInstallation = (RestrictedSwitchPreference) findPreference(KEY_TOGGLE_INSTALL_APPLICATIONS);
    mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
    // Side loading of apps.
    // Disable for restricted profiles. For others, check if policy disallows it.
    mToggleAppInstallation.setEnabled(!um.getUserInfo(MY_USER_ID).isRestricted());
    if (RestrictedLockUtils.hasBaseUserRestriction(getActivity(), UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, MY_USER_ID) || RestrictedLockUtils.hasBaseUserRestriction(getActivity(), UserManager.DISALLOW_INSTALL_APPS, MY_USER_ID)) {
        mToggleAppInstallation.setEnabled(false);
    }
    if (mToggleAppInstallation.isEnabled()) {
        mToggleAppInstallation.checkRestrictionAndSetDisabled(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES);
        if (!mToggleAppInstallation.isDisabledByAdmin()) {
            mToggleAppInstallation.checkRestrictionAndSetDisabled(UserManager.DISALLOW_INSTALL_APPS);
        }
    }
    // Advanced Security features
    PreferenceGroup advancedCategory = (PreferenceGroup) root.findPreference(KEY_ADVANCED_SECURITY);
    if (advancedCategory != null) {
        Preference manageAgents = advancedCategory.findPreference(KEY_MANAGE_TRUST_AGENTS);
        if (manageAgents != null && !mLockPatternUtils.isSecure(MY_USER_ID)) {
            manageAgents.setEnabled(false);
            manageAgents.setSummary(R.string.disabled_because_no_backup_security);
        }
    }
    // The above preferences come and go based on security state, so we need to update
    // the index. This call is expected to be fairly cheap, but we may want to do something
    // smarter in the future.
    Index.getInstance(getActivity()).updateFromClassNameResource(SecuritySettings.class.getName(), true, true);
    for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
        final Preference pref = findPreference(SWITCH_PREFERENCE_KEYS[i]);
        if (pref != null)
            pref.setOnPreferenceChangeListener(this);
    }
    return root;
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) PreferenceScreen(android.support.v7.preference.PreferenceScreen) SubscriptionInfo(android.telephony.SubscriptionInfo) Intent(android.content.Intent) SubscriptionManager(android.telephony.SubscriptionManager) PersistableBundle(android.os.PersistableBundle) RestrictedPreference(com.android.settingslib.RestrictedPreference) RestrictedPreference(com.android.settingslib.RestrictedPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) TelephonyManager(android.telephony.TelephonyManager) UserManager(android.os.UserManager) PreferenceGroup(android.support.v7.preference.PreferenceGroup) FingerprintSettings(com.android.settings.fingerprint.FingerprintSettings) CMSettings(cyanogenmod.providers.CMSettings) Settings(android.provider.Settings)

Aggregations

PreferenceGroup (android.support.v7.preference.PreferenceGroup)104 Preference (android.support.v7.preference.Preference)70 Context (android.content.Context)28 PreferenceScreen (android.support.v7.preference.PreferenceScreen)28 Test (org.junit.Test)26 PreferenceManager (android.support.v7.preference.PreferenceManager)22 SwitchPreference (android.support.v14.preference.SwitchPreference)19 ArrayList (java.util.ArrayList)19 PreferenceCategory (android.support.v7.preference.PreferenceCategory)17 UserInfo (android.content.pm.UserInfo)16 Intent (android.content.Intent)14 AccessiblePreferenceCategory (com.android.settings.AccessiblePreferenceCategory)14 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)14 Account (android.accounts.Account)12 AuthenticatorDescription (android.accounts.AuthenticatorDescription)12 UserHandle (android.os.UserHandle)12 TelephonyManager (android.telephony.TelephonyManager)12 Activity (android.app.Activity)11 RestrictedPreference (com.android.settingslib.RestrictedPreference)11 RemoteException (android.os.RemoteException)8