use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by omnirom.
the class SimSettings method updateCellularDataValues.
private void updateCellularDataValues() {
final Preference simPref = findPreference(KEY_CELLULAR_DATA);
final SubscriptionInfo sir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
simPref.setTitle(R.string.cellular_data_title);
if (DBG)
log("[updateCellularDataValues] mSubInfoList=" + mSubInfoList);
boolean callStateIdle = isCallStateIdle();
final boolean ecbMode = SystemProperties.getBoolean(TelephonyProperties.PROPERTY_INECM_MODE, false);
if (sir != null) {
simPref.setSummary(getSubscriptionDisplayName(sir));
// Enable data preference in msim mode and call state idle
simPref.setEnabled((mSelectableSubInfos.size() > 1) && callStateIdle && !ecbMode);
} else if (sir == null) {
simPref.setSummary(R.string.sim_selection_required_pref);
// Enable data preference in msim mode and call state idle
simPref.setEnabled((mSelectableSubInfos.size() >= 1) && callStateIdle && !ecbMode);
}
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by omnirom.
the class SimSettings method updateCallValues.
private void updateCallValues() {
final Preference simPref = findPreference(KEY_CALLS);
final SubscriptionInfo sir = mSubscriptionManager.getDefaultVoiceSubscriptionInfo();
final TelecomManager telecomManager = TelecomManager.from(mContext);
final PhoneAccountHandle phoneAccount = telecomManager.getUserSelectedOutgoingPhoneAccount();
final List<PhoneAccountHandle> allPhoneAccounts = telecomManager.getCallCapablePhoneAccounts();
simPref.setTitle(R.string.calls_title);
if (sir != null) {
simPref.setSummary(phoneAccount == null ? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title) : getSubscriptionDisplayName(sir));
// Enable data preference in msim mode and call state idle
simPref.setEnabled(allPhoneAccounts.size() > 1);
} else {
simPref.setSummary(phoneAccount == null ? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title) : (String) telecomManager.getPhoneAccount(phoneAccount).getLabel());
simPref.setEnabled(allPhoneAccounts.size() > 1);
}
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by crdroidandroid.
the class DataUsageList method updateBody.
/**
* Update body content based on current tab. Loads
* {@link NetworkStatsHistory} and {@link NetworkPolicy} from system, and
* binds them to visible controls.
*/
private void updateBody() {
if (!isAdded())
return;
final Context context = getActivity();
// kick off loader for network history
// TODO: consider chaining two loaders together instead of reloading
// network history when showing app detail.
getLoaderManager().restartLoader(LOADER_CHART_DATA, ChartDataLoader.buildArgs(mTemplate, null), mChartDataCallbacks);
// detail mode can change visible menus, invalidate
getActivity().invalidateOptionsMenu();
int seriesColor = context.getColor(R.color.sim_noitification);
if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
final SubscriptionInfo sir = services.mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
if (sir != null) {
seriesColor = sir.getIconTint();
}
}
final int secondaryColor = Color.argb(127, Color.red(seriesColor), Color.green(seriesColor), Color.blue(seriesColor));
mChart.setColors(seriesColor, secondaryColor);
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by crdroidandroid.
the class DataUsageList method hasReadyMobileRadio.
/**
* Test if device has a mobile data radio with SIM in ready state.
*/
public static boolean hasReadyMobileRadio(Context context) {
if (DataUsageUtils.TEST_RADIOS) {
return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile");
}
final ConnectivityManager conn = ConnectivityManager.from(context);
final TelephonyManager tele = TelephonyManager.from(context);
final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(context).getActiveSubscriptionInfoList();
// No activated Subscriptions
if (subInfoList == null) {
if (LOGD)
Log.d(TAG, "hasReadyMobileRadio: subInfoList=null");
return false;
}
// require both supported network and ready SIM
boolean isReady = true;
for (SubscriptionInfo subInfo : subInfoList) {
isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY;
if (LOGD)
Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo);
}
boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady;
if (LOGD) {
Log.d(TAG, "hasReadyMobileRadio:" + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady);
}
return retVal;
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by crdroidandroid.
the class DataUsageSummary method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Context context = getContext();
NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
mPolicyEditor = new NetworkPolicyEditor(policyManager);
boolean hasMobileData = DataUsageUtils.hasMobileData(context);
mDataUsageController = new DataUsageController(context);
mDataInfoController = new DataUsageInfoController();
addPreferencesFromResource(R.xml.data_usage);
int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
hasMobileData = false;
}
mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
mSummaryPreference = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
if (!hasMobileData || !isAdmin()) {
removePreference(KEY_RESTRICT_BACKGROUND);
}
if (hasMobileData) {
mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
List<SubscriptionInfo> subscriptions = services.mSubscriptionManager.getActiveSubscriptionInfoList();
if (subscriptions == null || subscriptions.size() == 0) {
addMobileSection(defaultSubId);
}
for (int i = 0; subscriptions != null && i < subscriptions.size(); i++) {
SubscriptionInfo subInfo = subscriptions.get(i);
if (subscriptions.size() > 1) {
addMobileSection(subInfo.getSubscriptionId(), subInfo);
} else {
addMobileSection(subInfo.getSubscriptionId());
}
}
mSummaryPreference.setSelectable(true);
} else {
removePreference(KEY_LIMIT_SUMMARY);
mSummaryPreference.setSelectable(false);
}
boolean hasWifiRadio = DataUsageUtils.hasWifiRadio(context);
if (hasWifiRadio) {
addWifiSection();
}
if (hasEthernet(context)) {
addEthernetSection();
}
mDataUsageTemplate = hasMobileData ? R.string.cell_data_template : hasWifiRadio ? R.string.wifi_data_template : R.string.ethernet_data_template;
setHasOptionsMenu(true);
}
Aggregations