use of android.telephony.SubscriptionInfo in project NetGuard by M66B.
the class Util method getSubscriptionInfo.
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
public static String getSubscriptionInfo(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
return "Not supported";
if (!hasPhoneStatePermission(context))
return "No permission";
StringBuilder sb = new StringBuilder();
SubscriptionManager sm = SubscriptionManager.from(context);
sb.append("Slots ").append(sm.getActiveSubscriptionInfoCount()).append('/').append(sm.getActiveSubscriptionInfoCountMax()).append("\r\n");
int dataid = -1;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
dataid = sm.getDefaultDataSubscriptionId();
int voiceid = -1;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
voiceid = sm.getDefaultVoiceSubscriptionId();
List<SubscriptionInfo> subscriptions = sm.getActiveSubscriptionInfoList();
if (subscriptions != null)
for (SubscriptionInfo si : subscriptions) sb.append("SIM ").append(si.getSimSlotIndex() + 1).append('/').append(si.getSubscriptionId()).append(' ').append(si.getCountryIso()).append('/').append(si.getMcc()).append(si.getMnc()).append(' ').append(si.getCarrierName()).append(si.getSubscriptionId() == dataid ? " D" : "").append(si.getSubscriptionId() == voiceid ? " V" : "").append(si.getDataRoaming() == SubscriptionManager.DATA_ROAMING_ENABLE ? " R" : "").append("\r\n");
if (sb.length() > 2)
sb.setLength(sb.length() - 2);
return sb.toString();
}
use of android.telephony.SubscriptionInfo in project kcanotify by antest1.
the class Util method getSubscriptionInfo.
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
public static String getSubscriptionInfo(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
return "Not supported";
if (!hasPhoneStatePermission(context))
return "No permission";
StringBuilder sb = new StringBuilder();
SubscriptionManager sm = SubscriptionManager.from(context);
sb.append("Slots ").append(sm.getActiveSubscriptionInfoCount()).append('/').append(sm.getActiveSubscriptionInfoCountMax()).append("\r\n");
int dataid = -1;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
dataid = sm.getDefaultDataSubscriptionId();
int voiceid = -1;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
voiceid = sm.getDefaultVoiceSubscriptionId();
List<SubscriptionInfo> subscriptions = sm.getActiveSubscriptionInfoList();
if (subscriptions != null)
for (SubscriptionInfo si : subscriptions) sb.append("SIM ").append(si.getSimSlotIndex() + 1).append('/').append(si.getSubscriptionId()).append(' ').append(si.getCountryIso()).append('/').append(si.getMcc()).append(si.getMnc()).append(' ').append(si.getCarrierName()).append(si.getSubscriptionId() == dataid ? " D" : "").append(si.getSubscriptionId() == voiceid ? " V" : "").append(si.getDataRoaming() == SubscriptionManager.DATA_ROAMING_ENABLE ? " R" : "").append("\r\n");
if (sb.length() > 2)
sb.setLength(sb.length() - 2);
return sb.toString();
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.
the class NetworkControllerImpl method addSignalController.
private SubscriptionInfo addSignalController(int id, int simSlotIndex) {
SubscriptionInfo info = new SubscriptionInfo(id, "", simSlotIndex, "", "", 0, 0, "", 0, null, 0, 0, "", 0);
mMobileSignalControllers.put(id, new MobileSignalController(mContext, mConfig, mHasMobileDataFeature, mPhone, mCallbackHandler, this, info, mSubDefaults, mReceiverHandler.getLooper()));
return info;
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.
the class EmergencyCryptkeeperText method update.
public void update() {
boolean hasMobile = ConnectivityManager.from(mContext).isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
boolean airplaneMode = (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 1);
if (!hasMobile || airplaneMode) {
setText(null);
setVisibility(GONE);
return;
}
boolean allSimsMissing = true;
CharSequence displayText = null;
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
final int N = subs.size();
for (int i = 0; i < N; i++) {
int subId = subs.get(i).getSubscriptionId();
IccCardConstants.State simState = mKeyguardUpdateMonitor.getSimState(subId);
CharSequence carrierName = subs.get(i).getCarrierName();
if (simState.iccCardExist() && !TextUtils.isEmpty(carrierName)) {
allSimsMissing = false;
displayText = carrierName;
}
}
if (allSimsMissing) {
if (N != 0) {
// Shows "Emergency calls only" on devices that are voice-capable.
// This depends on mPlmn containing the text "Emergency calls only" when the radio
// has some connectivity. Otherwise it should show "No service"
// Grab the first subscription, because they all should contain the emergency text,
// described above.
displayText = subs.get(0).getCarrierName();
} else {
// We don't have a SubscriptionInfo to get the emergency calls only from.
// Grab it from the old sticky broadcast if possible instead. We can use it
// here because no subscriptions are active, so we don't have
// to worry about MSIM clashing.
displayText = getContext().getText(com.android.internal.R.string.emergency_calls_only);
Intent i = getContext().registerReceiver(null, new IntentFilter(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION));
if (i != null) {
displayText = i.getStringExtra(TelephonyIntents.EXTRA_PLMN);
}
}
}
setText(displayText);
setVisibility(TextUtils.isEmpty(displayText) ? GONE : VISIBLE);
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.
the class KeyguardSimPukView method showDefaultMessage.
private void showDefaultMessage() {
if (mRemainingAttempts >= 0) {
mSecurityMessageDisplay.setMessage(getPukPasswordErrorMessage(mRemainingAttempts, true), true);
return;
}
int count = TelephonyManager.getDefault().getSimCount();
Resources rez = getResources();
final String msg;
int color = Color.WHITE;
if (count < 2) {
msg = rez.getString(R.string.kg_puk_enter_puk_hint);
} else {
SubscriptionInfo info = KeyguardUpdateMonitor.getInstance(mContext).getSubscriptionInfoForSubId(mSubId);
CharSequence displayName = info != null ? info.getDisplayName() : "";
msg = rez.getString(R.string.kg_puk_enter_puk_hint_multi, displayName);
if (info != null) {
color = info.getIconTint();
}
}
mSecurityMessageDisplay.setMessage(msg, true);
mSimImageView.setImageTintList(ColorStateList.valueOf(color));
new CheckSimPuk("", "", mSubId) {
void onSimLockChangedResponse(final int result, final int attemptsRemaining) {
Log.d(LOG_TAG, "onSimCheckResponse " + " dummy One result" + result + " attemptsRemaining=" + attemptsRemaining);
if (attemptsRemaining >= 0) {
mRemainingAttempts = attemptsRemaining;
mSecurityMessageDisplay.setMessage(getPukPasswordErrorMessage(attemptsRemaining, true), true);
}
}
}.start();
}
Aggregations