Search in sources :

Example 71 with PersistableBundle

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

the class SimStatus method updatePreference.

private void updatePreference() {
    if (mPhone.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
        mShowLatestAreaInfo = Resources.getSystem().getBoolean(com.android.internal.R.bool.config_showAreaUpdateInfoSettings);
    }
    PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSir.getSubscriptionId());
    mShowICCID = carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
    // If formattedNumber is null or empty, it'll display as "Unknown".
    setSummaryText(KEY_PHONE_NUMBER, DeviceInfoUtils.getFormattedPhoneNumber(getContext(), mSir));
    setSummaryText(KEY_IMEI, mPhone.getImei());
    setSummaryText(KEY_IMEI_SV, mPhone.getDeviceSvn());
    if (!mShowICCID) {
        removePreferenceFromScreen(KEY_ICCID);
    } else {
        // Get ICCID, which is SIM serial number
        String iccid = mTelephonyManager.getSimSerialNumber(mSir.getSubscriptionId());
        setSummaryText(KEY_ICCID, iccid);
    }
    if (!mShowLatestAreaInfo) {
        removePreferenceFromScreen(KEY_LATEST_AREA_INFO);
    }
}
Also used : PersistableBundle(android.os.PersistableBundle)

Example 72 with PersistableBundle

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

the class ConfigOverrideFragment method loadCurrentConfig.

/**
 * Loads the config for the currently carrier into the override values, from the dialer or the
 * carrier config app. This is a "reset" button to load the defaults.
 */
private void loadCurrentConfig() {
    Context context = getActivity();
    PhoneAccountHandle phoneAccountHandle = context.getSystemService(TelecomManager.class).getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_VOICEMAIL);
    PersistableBundle config = VoicemailComponent.get(context).getVoicemailClient().getConfig(context, phoneAccountHandle);
    for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
        Preference preference = getPreferenceScreen().getPreference(i);
        String key = preference.getKey();
        if (!key.startsWith(CONFIG_OVERRIDE_KEY_PREFIX)) {
            continue;
        }
        String configKey = key.substring(CONFIG_OVERRIDE_KEY_PREFIX.length());
        if (configKey.endsWith("bool")) {
            ((SwitchPreference) preference).setChecked(config.getBoolean(configKey));
        } else if (configKey.endsWith("int")) {
            ((EditTextPreference) preference).setText(String.valueOf(config.getInt(configKey)));
        } else if (configKey.endsWith("string")) {
            ((EditTextPreference) preference).setText(config.getString(configKey));
        } else if (configKey.endsWith("string_array")) {
            ((EditTextPreference) preference).setText(toCsv(config.getStringArray(configKey)));
        } else {
            throw Assert.createAssertionFailException("unknown type for key " + configKey);
        }
        updatePreference(preference);
    }
}
Also used : Context(android.content.Context) PersistableBundle(android.os.PersistableBundle) PhoneAccountHandle(android.telecom.PhoneAccountHandle) EditTextPreference(android.preference.EditTextPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) SwitchPreference(android.preference.SwitchPreference) EditTextPreference(android.preference.EditTextPreference) TelecomManager(android.telecom.TelecomManager)

Example 73 with PersistableBundle

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

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 74 with PersistableBundle

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

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 75 with PersistableBundle

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

the class WifiCallingSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.wifi_calling_settings);
    mButtonWfcMode = (ListPreference) findPreference(BUTTON_WFC_MODE);
    mButtonWfcMode.setOnPreferenceChangeListener(this);
    mButtonWfcRoamingMode = (ListPreference) findPreference(BUTTON_WFC_ROAMING_MODE);
    mButtonWfcRoamingMode.setOnPreferenceChangeListener(this);
    mUpdateAddress = (Preference) findPreference(PREFERENCE_EMERGENCY_ADDRESS);
    mUpdateAddress.setOnPreferenceClickListener(mUpdateAddressListener);
    mIntentFilter = new IntentFilter();
    mIntentFilter.addAction(ImsManager.ACTION_IMS_REGISTRATION_ERROR);
    CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
    boolean isWifiOnlySupported = true;
    if (configManager != null) {
        PersistableBundle b = configManager.getConfig();
        if (b != null) {
            mEditableWfcMode = b.getBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL);
            mEditableWfcRoamingMode = b.getBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL);
            isWifiOnlySupported = b.getBoolean(CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, true);
        }
    }
    if (!isWifiOnlySupported) {
        mButtonWfcMode.setEntries(R.array.wifi_calling_mode_choices_without_wifi_only);
        mButtonWfcMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only);
        mButtonWfcRoamingMode.setEntries(R.array.wifi_calling_mode_choices_v2_without_wifi_only);
        mButtonWfcRoamingMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only);
    }
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) IntentFilter(android.content.IntentFilter) PersistableBundle(android.os.PersistableBundle)

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