use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by omnirom.
the class SecuritySettings method isSimIccReady.
/* Return true if a there is a Slot that has Icc.
*/
private boolean isSimIccReady() {
TelephonyManager tm = TelephonyManager.getDefault();
final List<SubscriptionInfo> subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
if (subInfoList != null) {
for (SubscriptionInfo subInfo : subInfoList) {
if (tm.hasIccCard(subInfo.getSimSlotIndex())) {
return true;
}
}
}
return false;
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by omnirom.
the class CellDataPreference method showMultiSimDialog.
private void showMultiSimDialog(AlertDialog.Builder builder, DialogInterface.OnClickListener listener) {
final SubscriptionInfo currentSir = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
final SubscriptionInfo nextSir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
final String previousName = (nextSir == null) ? getContext().getResources().getString(R.string.sim_selection_required_pref) : nextSir.getDisplayName().toString();
builder.setTitle(R.string.sim_change_data_title);
builder.setMessage(getContext().getString(R.string.sim_change_data_message, String.valueOf(currentSir != null ? currentSir.getDisplayName() : null), previousName));
builder.setPositiveButton(R.string.okay, listener);
builder.setNegativeButton(R.string.cancel, null);
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by omnirom.
the class DataPlanUsageSummary method addDataPlanSection.
private void addDataPlanSection(int defaultSubId) {
Context context = getPrefContext();
addPreferencesFromResource(R.xml.data_plan_usage);
PreferenceScreen screen = getPreferenceScreen();
screen.setTitle(context.getString(R.string.data_usage_summary_title));
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(KEY_DATA_PLAN_USAGE);
screen.addPreference(preferenceCategory);
Preference dataPlansSyncTimePreference = new Preference(context);
dataPlansSyncTimePreference.setLayoutResource(R.layout.data_plans_sync_time_preference);
dataPlansSyncTimePreference.setTitle(MockDataPlanUsage.SYNC_TIME);
preferenceCategory.addPreference(dataPlansSyncTimePreference);
mDataPlanSummaryPreferenceList = new ArrayList<>(MockDataPlanUsage.DATA_PLAN_USAGES.length);
for (int i = 0; i < MockDataPlanUsage.DATA_PLAN_USAGES.length; i++) {
DataPlanSummaryPreference dataPlanSummaryPreference = new DataPlanSummaryPreference(context);
dataPlanSummaryPreference.setKey(KEY_STATUS_HEADER + (i + 1));
mDataPlanSummaryPreferenceList.add(dataPlanSummaryPreference);
preferenceCategory.addPreference(dataPlanSummaryPreference);
}
Preference preference = new Preference(context);
preference.setLayoutResource(R.layout.manage_data_plans_preference);
preferenceCategory.addPreference(preference);
setPreferenceScreen(screen);
mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
List<SubscriptionInfo> subscriptions = services.mSubscriptionManager.getActiveSubscriptionInfoList();
if (subscriptions == null || subscriptions.isEmpty()) {
addMobileSection(defaultSubId);
}
for (int i = 0, subscriptionsSize = subscriptions != null ? subscriptions.size() : 0; i < subscriptionsSize; i++) {
SubscriptionInfo subInfo = subscriptions.get(i);
if (subscriptionsSize > 1) {
addMobileSection(subInfo.getSubscriptionId(), subInfo);
} else {
addMobileSection(subInfo.getSubscriptionId());
}
}
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by omnirom.
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 omnirom.
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