Search in sources :

Example 86 with PersistableBundle

use of android.os.PersistableBundle in project android_packages_apps_Settings by SudaMod.

the class RestrictedSettingsFragment method ensurePin.

private void ensurePin() {
    if (!mChallengeSucceeded && !mChallengeRequested && mRestrictionsManager.hasRestrictionsProvider()) {
        Intent intent = mRestrictionsManager.createLocalApprovalIntent();
        if (intent != null) {
            mChallengeRequested = true;
            mChallengeSucceeded = false;
            PersistableBundle request = new PersistableBundle();
            request.putString(RestrictionsManager.REQUEST_KEY_MESSAGE, getResources().getString(R.string.restr_pin_enter_admin_pin));
            intent.putExtra(RestrictionsManager.EXTRA_REQUEST_BUNDLE, request);
            startActivityForResult(intent, REQUEST_PIN_CHALLENGE);
        }
    }
}
Also used : PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent)

Example 87 with PersistableBundle

use of android.os.PersistableBundle in project android_packages_apps_Settings by SudaMod.

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 category for security status
    addPreferencesFromResource(R.xml.security_settings_status);
    // 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);
    }
    mIsAdmin = mUm.isAdminUser();
    // Fingerprint and trust agents
    int numberOfTrustAgent = 0;
    PreferenceGroup securityCategory = (PreferenceGroup) root.findPreference(KEY_SECURITY_CATEGORY);
    if (securityCategory != null) {
        maybeAddFingerprintPreference(securityCategory, UserHandle.myUserId());
        numberOfTrustAgent = addTrustAgentSettings(securityCategory);
        setLockscreenPreferencesSummary(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
    TelephonyManager tm = TelephonyManager.getDefault();
    CarrierConfigManager cfgMgr = (CarrierConfigManager) getActivity().getSystemService(Context.CARRIER_CONFIG_SERVICE);
    PersistableBundle b = cfgMgr.getConfig();
    if (!mIsAdmin || !isSimIccReady() || b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) {
        root.removePreference(root.findPreference(KEY_SIM_LOCK));
    } else {
        // Disable SIM lock if there is no ready SIM card.
        root.findPreference(KEY_SIM_LOCK).setEnabled(isSimReady());
    }
    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));
    }
    // Encryption status of device
    if (LockPatternUtils.isDeviceEncryptionEnabled()) {
        root.findPreference(KEY_ENCRYPTION_AND_CREDENTIALS).setSummary(R.string.encryption_and_credential_settings_summary);
    } else {
        root.findPreference(KEY_ENCRYPTION_AND_CREDENTIALS).setSummary(R.string.summary_placeholder);
    }
    // Show password
    mShowPassword = (SwitchPreference) root.findPreference(KEY_SHOW_PASSWORD);
    // Credential storage
    final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
    // Advanced Security features
    initTrustAgentPreference(root, numberOfTrustAgent);
    // 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.
    final Activity activity = getActivity();
    FeatureFactory.getFactory(activity).getSearchFeatureProvider().getIndexingManager(activity).updateFromClassNameResource(SecuritySettings.class.getName(), true);
    PreferenceGroup securityStatusPreferenceGroup = (PreferenceGroup) root.findPreference(KEY_SECURITY_STATUS);
    final List<Preference> tilePrefs = mDashboardFeatureProvider.getPreferencesForCategory(getActivity(), getPrefContext(), getMetricsCategory(), CategoryKey.CATEGORY_SECURITY);
    int numSecurityStatusPrefs = 0;
    if (tilePrefs != null && !tilePrefs.isEmpty()) {
        for (Preference preference : tilePrefs) {
            if (!TextUtils.isEmpty(preference.getKey()) && preference.getKey().startsWith(SECURITY_STATUS_KEY_PREFIX)) {
                // Injected security status settings are placed under the Security status
                // category.
                securityStatusPreferenceGroup.addPreference(preference);
                numSecurityStatusPrefs++;
            } else {
                // Other injected settings are placed under the Security preference screen.
                root.addPreference(preference);
            }
        }
    }
    if (numSecurityStatusPrefs == 0) {
        root.removePreference(securityStatusPreferenceGroup);
    } else if (numSecurityStatusPrefs > 0) {
        // Update preference data with tile data. Security feature provider only updates the
        // data if it actually needs to be changed.
        mSecurityFeatureProvider.updatePreferences(getActivity(), root, mDashboardFeatureProvider.getTilesForCategory(CategoryKey.CATEGORY_SECURITY));
    }
    for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
        final Preference pref = findPreference(SWITCH_PREFERENCE_KEYS[i]);
        if (pref != null)
            pref.setOnPreferenceChangeListener(this);
    }
    mLocationcontroller.displayPreference(root);
    mManageDeviceAdminPreferenceController.updateState(root.findPreference(KEY_MANAGE_DEVICE_ADMIN));
    mEnterprisePrivacyPreferenceController.displayPreference(root);
    mEnterprisePrivacyPreferenceController.onResume();
    return root;
}
Also used : GearPreference(com.android.settings.widget.GearPreference) CarrierConfigManager(android.telephony.CarrierConfigManager) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Activity(android.app.Activity) PersistableBundle(android.os.PersistableBundle) RestrictedPreference(com.android.settingslib.RestrictedPreference) GearPreference(com.android.settings.widget.GearPreference) 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)

Example 88 with PersistableBundle

use of android.os.PersistableBundle in project android_packages_apps_Settings by SudaMod.

the class ApnEditor method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.apn_editor);
    sNotSet = getResources().getString(R.string.apn_not_set);
    mName = (EditTextPreference) findPreference("apn_name");
    mApn = (EditTextPreference) findPreference("apn_apn");
    mProxy = (EditTextPreference) findPreference("apn_http_proxy");
    mPort = (EditTextPreference) findPreference("apn_http_port");
    mUser = (EditTextPreference) findPreference("apn_user");
    mServer = (EditTextPreference) findPreference("apn_server");
    mPassword = (EditTextPreference) findPreference(KEY_PASSWORD);
    mMmsProxy = (EditTextPreference) findPreference("apn_mms_proxy");
    mMmsPort = (EditTextPreference) findPreference("apn_mms_port");
    mMmsc = (EditTextPreference) findPreference("apn_mmsc");
    mMcc = (EditTextPreference) findPreference("apn_mcc");
    mMnc = (EditTextPreference) findPreference("apn_mnc");
    mApnType = (EditTextPreference) findPreference("apn_type");
    mAuthType = (ListPreference) findPreference(KEY_AUTH_TYPE);
    mProtocol = (ListPreference) findPreference(KEY_PROTOCOL);
    mRoamingProtocol = (ListPreference) findPreference(KEY_ROAMING_PROTOCOL);
    mCarrierEnabled = (SwitchPreference) findPreference(KEY_CARRIER_ENABLED);
    mBearerMulti = (MultiSelectListPreference) findPreference(KEY_BEARER_MULTI);
    mMvnoType = (ListPreference) findPreference(KEY_MVNO_TYPE);
    mMvnoMatchData = (EditTextPreference) findPreference("mvno_match_data");
    mRes = getResources();
    final Intent intent = getIntent();
    final String action = intent.getAction();
    mSubId = intent.getIntExtra(ApnSettings.SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    mFirstTime = icicle == null;
    mReadOnlyApn = false;
    mReadOnlyApnTypes = null;
    mReadOnlyApnFields = null;
    CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
    if (configManager != null) {
        PersistableBundle b = configManager.getConfig();
        if (b != null) {
            mReadOnlyApnTypes = b.getStringArray(CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY);
            if (!ArrayUtils.isEmpty(mReadOnlyApnTypes)) {
                for (String apnType : mReadOnlyApnTypes) {
                    Log.d(TAG, "onCreate: read only APN type: " + apnType);
                }
            }
            mReadOnlyApnFields = b.getStringArray(CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY);
        }
    }
    if (action.equals(Intent.ACTION_EDIT)) {
        Uri uri = intent.getData();
        if (!uri.isPathPrefixMatch(Telephony.Carriers.CONTENT_URI)) {
            Log.e(TAG, "Edit request not for carrier table. Uri: " + uri);
            finish();
            return;
        }
        mUri = uri;
    } else if (action.equals(Intent.ACTION_INSERT)) {
        if (mFirstTime || icicle.getInt(SAVED_POS) == 0) {
            Uri uri = intent.getData();
            if (!uri.isPathPrefixMatch(Telephony.Carriers.CONTENT_URI)) {
                Log.e(TAG, "Insert request not for carrier table. Uri: " + uri);
                finish();
                return;
            }
            mUri = getContentResolver().insert(uri, new ContentValues());
        } else {
            mUri = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, icicle.getInt(SAVED_POS));
        }
        mNewApn = true;
        mMvnoTypeStr = intent.getStringExtra(ApnSettings.MVNO_TYPE);
        mMvnoMatchDataStr = intent.getStringExtra(ApnSettings.MVNO_MATCH_DATA);
        // original activity if they requested a result.
        if (mUri == null) {
            Log.w(TAG, "Failed to insert new telephony provider into " + getIntent().getData());
            finish();
            return;
        }
        // The new entry was created, so assume all will end well and
        // set the result to be returned.
        setResult(RESULT_OK, (new Intent()).setAction(mUri.toString()));
    } else {
        finish();
        return;
    }
    mCursor = getActivity().managedQuery(mUri, sProjection, null, null);
    mCursor.moveToFirst();
    mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    Log.d(TAG, "onCreate: EDITED " + mCursor.getInt(EDITED_INDEX));
    // if it's not a USER_EDITED apn, check if it's read-only
    if (mCursor.getInt(EDITED_INDEX) != Telephony.Carriers.USER_EDITED && (mCursor.getInt(USER_EDITABLE_INDEX) == 0 || apnTypesMatch(mReadOnlyApnTypes, mCursor.getString(TYPE_INDEX)))) {
        Log.d(TAG, "onCreate: apnTypesMatch; read-only APN");
        mReadOnlyApn = true;
        disableAllFields();
    } else if (!ArrayUtils.isEmpty(mReadOnlyApnFields)) {
        disableFields(mReadOnlyApnFields);
    }
    for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
        getPreferenceScreen().getPreference(i).setOnPreferenceChangeListener(this);
    }
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) ContentValues(android.content.ContentValues) PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent) Uri(android.net.Uri)

Example 89 with PersistableBundle

use of android.os.PersistableBundle in project android_packages_apps_Settings by SudaMod.

the class ApnSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final Activity activity = getActivity();
    final int subId = activity.getIntent().getIntExtra(SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    mMobileStateFilter = new IntentFilter(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
    setIfOnlyAvailableForAdmins(true);
    mSubscriptionInfo = SubscriptionManager.from(activity).getActiveSubscriptionInfo(subId);
    mUiccController = UiccController.getInstance();
    CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
    PersistableBundle b = configManager.getConfig();
    mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL);
    mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL);
    if (mAllowAddingApns) {
        String[] readOnlyApnTypes = b.getStringArray(CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY);
        // if no apn type can be edited, do not allow adding APNs
        if (ApnEditor.hasAllApns(readOnlyApnTypes)) {
            Log.d(TAG, "not allowing adding APN because all APN types are read only");
            mAllowAddingApns = false;
        }
    }
    mUserManager = UserManager.get(activity);
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) IntentFilter(android.content.IntentFilter) PersistableBundle(android.os.PersistableBundle) Activity(android.app.Activity)

Example 90 with PersistableBundle

use of android.os.PersistableBundle in project android_packages_apps_CMParts by LineageOS.

the class ReportingService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    JobScheduler js = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
    String deviceId = Utilities.getUniqueID(getApplicationContext());
    String deviceName = Utilities.getDevice();
    String deviceVersion = Utilities.getModVersion();
    String deviceCountry = Utilities.getCountryCode(getApplicationContext());
    String deviceCarrier = Utilities.getCarrier(getApplicationContext());
    String deviceCarrierId = Utilities.getCarrierId(getApplicationContext());
    final int cmOrgJobId = AnonymousStats.getNextJobId(getApplicationContext());
    if (DEBUG)
        Log.d(TAG, "scheduling job id: " + cmOrgJobId);
    PersistableBundle cmBundle = new PersistableBundle();
    cmBundle.putString(StatsUploadJobService.KEY_DEVICE_NAME, deviceName);
    cmBundle.putString(StatsUploadJobService.KEY_UNIQUE_ID, deviceId);
    cmBundle.putString(StatsUploadJobService.KEY_VERSION, deviceVersion);
    cmBundle.putString(StatsUploadJobService.KEY_COUNTRY, deviceCountry);
    cmBundle.putString(StatsUploadJobService.KEY_CARRIER, deviceCarrier);
    cmBundle.putString(StatsUploadJobService.KEY_CARRIER_ID, deviceCarrierId);
    cmBundle.putLong(StatsUploadJobService.KEY_TIMESTAMP, System.currentTimeMillis());
    // set job types
    cmBundle.putInt(StatsUploadJobService.KEY_JOB_TYPE, StatsUploadJobService.JOB_TYPE_CMORG);
    // schedule cmorg stats upload
    js.schedule(new JobInfo.Builder(cmOrgJobId, new ComponentName(getPackageName(), StatsUploadJobService.class.getName())).setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).setMinimumLatency(1000).setExtras(cmBundle).setPersisted(true).build());
    // reschedule
    AnonymousStats.updateLastSynced(this);
    ReportingServiceManager.setAlarm(this);
}
Also used : JobScheduler(android.app.job.JobScheduler) PersistableBundle(android.os.PersistableBundle) ComponentName(android.content.ComponentName)

Aggregations

PersistableBundle (android.os.PersistableBundle)321 CarrierConfigManager (android.telephony.CarrierConfigManager)87 ComponentName (android.content.ComponentName)67 Intent (android.content.Intent)63 ShortcutInfo (android.content.pm.ShortcutInfo)48 Test (org.junit.Test)35 Bundle (android.os.Bundle)28 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)25 IOException (java.io.IOException)21 Icon (android.graphics.drawable.Icon)17 JobInfo (android.app.job.JobInfo)15 IntentFilter (android.content.IntentFilter)15 Account (android.accounts.Account)14 Activity (android.app.Activity)12 TelephonyManager (android.telephony.TelephonyManager)12 SmallTest (android.test.suitebuilder.annotation.SmallTest)12 XmlPullParser (org.xmlpull.v1.XmlPullParser)12 Before (org.junit.Before)11 PendingIntent (android.app.PendingIntent)9 PackageManager (android.content.pm.PackageManager)9