Search in sources :

Example 36 with SubscriptionInfo

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();
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) TargetApi(android.annotation.TargetApi)

Example 37 with SubscriptionInfo

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();
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) TargetApi(android.annotation.TargetApi)

Example 38 with SubscriptionInfo

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;
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 39 with SubscriptionInfo

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);
}
Also used : IntentFilter(android.content.IntentFilter) IccCardConstants(com.android.internal.telephony.IccCardConstants) SubscriptionInfo(android.telephony.SubscriptionInfo) Intent(android.content.Intent)

Example 40 with SubscriptionInfo

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();
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) Resources(android.content.res.Resources)

Aggregations

SubscriptionInfo (android.telephony.SubscriptionInfo)89 ArrayList (java.util.ArrayList)27 Intent (android.content.Intent)14 SubscriptionManager (android.telephony.SubscriptionManager)13 IntentFilter (android.content.IntentFilter)12 Resources (android.content.res.Resources)9 TelephonyManager (android.telephony.TelephonyManager)9 ServiceState (android.telephony.ServiceState)7 BitSet (java.util.BitSet)7 RemoteException (android.os.RemoteException)5 Preference (android.support.v7.preference.Preference)5 IccCardConstants (com.android.internal.telephony.IccCardConstants)5 State (com.android.internal.telephony.IccCardConstants.State)5 ContentResolver (android.content.ContentResolver)4 PersistentDataBlockManager (android.service.persistentdata.PersistentDataBlockManager)4 SwitchPreference (android.support.v14.preference.SwitchPreference)4 PhoneAccountHandle (android.telecom.PhoneAccountHandle)4 TelecomManager (android.telecom.TelecomManager)3 TargetApi (android.annotation.TargetApi)2 AlertDialog (android.app.AlertDialog)2