use of android.telephony.CarrierConfigManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiCallingSettings method getCarrierActivityIntent.
/*
* Get the Intent to launch carrier emergency address management activity.
* Return null when no activity found.
*/
private static Intent getCarrierActivityIntent(Context context) {
// Retrive component name from carrirt config
CarrierConfigManager configManager = context.getSystemService(CarrierConfigManager.class);
if (configManager == null)
return null;
PersistableBundle bundle = configManager.getConfig();
if (bundle == null)
return null;
String carrierApp = bundle.getString(CarrierConfigManager.KEY_WFC_EMERGENCY_ADDRESS_CARRIER_APP_STRING);
if (TextUtils.isEmpty(carrierApp))
return null;
ComponentName componentName = ComponentName.unflattenFromString(carrierApp);
if (componentName == null)
return null;
// Build and return intent
Intent intent = new Intent();
intent.setComponent(componentName);
return intent;
}
use of android.telephony.CarrierConfigManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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);
fillOperatorIccidset();
Log.d(TAG, "onCreate: subId = " + subId);
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);
mUserManager = UserManager.get(activity);
}
use of android.telephony.CarrierConfigManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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("apn_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);
mAuthType.setOnPreferenceChangeListener(this);
mProtocol = (ListPreference) findPreference(KEY_PROTOCOL);
mProtocol.setOnPreferenceChangeListener(this);
mRoamingProtocol = (ListPreference) findPreference(KEY_ROAMING_PROTOCOL);
mRoamingProtocol.setOnPreferenceChangeListener(this);
mCarrierEnabled = (SwitchPreference) findPreference(KEY_CARRIER_ENABLED);
mBearerMulti = (MultiSelectListPreference) findPreference(KEY_BEARER_MULTI);
mBearerMulti.setOnPreferenceChangeListener(this);
mMvnoType = (ListPreference) findPreference(KEY_MVNO_TYPE);
mMvnoType.setOnPreferenceChangeListener(this);
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);
mDisableEditor = intent.getBooleanExtra("DISABLE_EDITOR", false);
mFirstTime = icicle == null;
mReadOnlyApn = false;
mReadOnlyApnTypes = null;
mReadOnlyApnFields = null;
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;
}
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);
mReadOnlyApnFields = b.getStringArray(CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY);
}
}
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 && 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);
}
fillUi();
}
use of android.telephony.CarrierConfigManager in project platform_frameworks_base by android.
the class Tethering method isTetherProvisioningRequired.
/**
* Check if the device requires a provisioning check in order to enable tethering.
*
* @return a boolean - {@code true} indicating tether provisioning is required by the carrier.
*/
@VisibleForTesting
protected boolean isTetherProvisioningRequired() {
String[] provisionApp = mContext.getResources().getStringArray(com.android.internal.R.array.config_mobile_hotspot_provision_app);
if (mSystemProperties.getBoolean(DISABLE_PROVISIONING_SYSPROP_KEY, false) || provisionApp == null) {
return false;
}
// Check carrier config for entitlement checks
final CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
if (configManager != null && configManager.getConfig() != null) {
// we do have a CarrierConfigManager and it has a config.
boolean isEntitlementCheckRequired = configManager.getConfig().getBoolean(CarrierConfigManager.KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL);
if (!isEntitlementCheckRequired) {
return false;
}
}
return (provisionApp.length == 2);
}
use of android.telephony.CarrierConfigManager in project platform_frameworks_base by android.
the class CustomConfigLoader method loadCarrierActionList.
/**
* loads and parses the carrier config, return a list of carrier action for the given signal
* @param context
* @param intent passing signal for config match
* @return a list of carrier action for the given signal based on the carrier config.
*
* Example: input intent TelephonyIntent.ACTION_CARRIER_SIGNAL_REQUEST_NETWORK_FAILED
* This intent allows fined-grained matching based on both intent type & extra values:
* apnType and errorCode.
* apnType read from passing intent is "default" and errorCode is 0x26 for example and
* returned carrier config from carrier_default_actions_on_redirection_string_array is
* {
* "default, 0x26:1,4", // 0x26(NETWORK_FAILURE)
* "default, 0x70:2,3" // 0x70(APN_TYPE_CONFLICT)
* }
* [1, 4] // 1(CARRIER_ACTION_DISABLE_METERED_APNS), 4(CARRIER_ACTION_SHOW_PORTAL_NOTIFICATION)
* returns as the action index list based on the matching rule.
*/
public static List<Integer> loadCarrierActionList(Context context, Intent intent) {
CarrierConfigManager carrierConfigManager = (CarrierConfigManager) context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
// return an empty list if no match found
List<Integer> actionList = new ArrayList<>();
if (carrierConfigManager == null) {
Rlog.e(TAG, "load carrier config failure with carrier config manager uninitialized");
return actionList;
}
PersistableBundle b = carrierConfigManager.getConfig();
if (b != null) {
String[] configs = null;
// used for intents which allow fine-grained interpretation based on intent extras
String arg1 = null;
String arg2 = null;
switch(intent.getAction()) {
case TelephonyIntents.ACTION_CARRIER_SIGNAL_REDIRECTED:
configs = b.getStringArray(CarrierConfigManager.KEY_CARRIER_DEFAULT_ACTIONS_ON_REDIRECTION_STRING_ARRAY);
break;
case TelephonyIntents.ACTION_CARRIER_SIGNAL_REQUEST_NETWORK_FAILED:
configs = b.getStringArray(CarrierConfigManager.KEY_CARRIER_DEFAULT_ACTIONS_ON_DCFAILURE_STRING_ARRAY);
arg1 = intent.getStringExtra(TelephonyIntents.EXTRA_APN_TYPE_KEY);
arg2 = intent.getStringExtra(TelephonyIntents.EXTRA_ERROR_CODE_KEY);
break;
default:
Rlog.e(TAG, "load carrier config failure with un-configured key: " + intent.getAction());
break;
}
if (!ArrayUtils.isEmpty(configs)) {
for (String config : configs) {
// parse each config until find the matching one
matchConfig(config, arg1, arg2, actionList);
if (!actionList.isEmpty()) {
// return the first match
if (VDBG)
Rlog.d(TAG, "found match action list: " + actionList.toString());
return actionList;
}
}
}
Rlog.d(TAG, "no matching entry for signal: " + intent.getAction() + "arg1: " + arg1 + "arg2: " + arg2);
}
return actionList;
}
Aggregations