use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by crdroidandroid.
the class SecuritySettings method isSimReady.
/* Return true if a SIM is ready for locking.
* TODO: consider adding to TelephonyManager or SubscritpionManasger.
*/
private boolean isSimReady() {
int simState = TelephonyManager.SIM_STATE_UNKNOWN;
final List<SubscriptionInfo> subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
if (subInfoList != null) {
for (SubscriptionInfo subInfo : subInfoList) {
simState = TelephonyManager.getDefault().getSimState(subInfo.getSimSlotIndex());
if ((simState != TelephonyManager.SIM_STATE_ABSENT) && (simState != TelephonyManager.SIM_STATE_UNKNOWN)) {
return true;
}
}
}
return false;
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by crdroidandroid.
the class SettingsDumpService method dumpDataUsage.
private JSONObject dumpDataUsage() throws JSONException {
JSONObject obj = new JSONObject();
DataUsageController controller = new DataUsageController(this);
ConnectivityManager connectivityManager = getSystemService(ConnectivityManager.class);
SubscriptionManager manager = SubscriptionManager.from(this);
TelephonyManager telephonyManager = TelephonyManager.from(this);
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) {
JSONArray array = new JSONArray();
for (SubscriptionInfo info : manager.getAllSubscriptionInfoList()) {
NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(telephonyManager.getSubscriberId(info.getSubscriptionId()));
final JSONObject usage = dumpDataUsage(mobileAll, controller);
usage.put("subId", info.getSubscriptionId());
array.put(usage);
}
obj.put("cell", array);
}
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_WIFI)) {
obj.put("wifi", dumpDataUsage(NetworkTemplate.buildTemplateWifiWildcard(), controller));
}
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_ETHERNET)) {
obj.put("ethernet", dumpDataUsage(NetworkTemplate.buildTemplateEthernet(), controller));
}
return obj;
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by SudaMod.
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 SudaMod.
the class CellDataPreference method performClick.
@Override
protected void performClick(View view) {
final Context context = getContext();
FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context, MetricsEvent.ACTION_CELL_DATA_TOGGLE, !mChecked);
final SubscriptionInfo currentSir = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
final SubscriptionInfo nextSir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
if (mChecked) {
// the pop-up.
if (!Utils.showSimCardTile(getContext()) || (nextSir != null && currentSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
setMobileDataEnabled(false);
if (nextSir != null && currentSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
disableDataForOtherSubscriptions(mSubId);
}
return;
}
// disabling data; show confirmation dialog which eventually
// calls setMobileDataEnabled() once user confirms.
mMultiSimDialog = false;
super.performClick(view);
} else {
// If we are showing the Sim Card tile then we are a Multi-Sim device.
if (Utils.showSimCardTile(getContext())) {
mMultiSimDialog = true;
if (nextSir != null && currentSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
setMobileDataEnabled(true);
disableDataForOtherSubscriptions(mSubId);
return;
}
super.performClick(view);
} else {
setMobileDataEnabled(true);
}
}
}
use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by SudaMod.
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);
}
Aggregations