Search in sources :

Example 41 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.

the class NetworkControllerBaseTest method setSubscriptions.

protected void setSubscriptions(int... subIds) {
    List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
    for (int subId : subIds) {
        SubscriptionInfo subscription = mock(SubscriptionInfo.class);
        when(subscription.getSubscriptionId()).thenReturn(subId);
        subs.add(subscription);
    }
    when(mMockSm.getActiveSubscriptionInfoList()).thenReturn(subs);
    mNetworkController.doUpdateMobileControllers();
}
Also used : ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 42 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.

the class KeyguardUpdateMonitor method getNextSubIdForState.

/**
     * Find the next SubscriptionId for a SIM in the given state, favoring lower slot numbers first.
     * @param state
     * @return subid or {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} if none found
     */
public int getNextSubIdForState(State state) {
    List<SubscriptionInfo> list = getSubscriptionInfo(false);
    int resultId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    // Favor lowest slot first
    int bestSlotId = Integer.MAX_VALUE;
    for (int i = 0; i < list.size(); i++) {
        final SubscriptionInfo info = list.get(i);
        final int id = info.getSubscriptionId();
        int slotId = SubscriptionManager.getSlotId(id);
        if (state == getSimState(id) && bestSlotId > slotId) {
            resultId = id;
            bestSlotId = slotId;
        }
    }
    return resultId;
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 43 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.

the class GlobalActions method setupAirplaneModeListeners.

/**
     * Since there are two ways of handling airplane mode (with telephony, we depend on the internal
     * device telephony state), and MSIM devices do not report phone state for missing SIMs, we
     * need to dynamically setup listeners based on subscription changes.
     *
     * So if there is _any_ active SIM in the device, we can depend on the phone state,
     * otherwise fall back to {@link Settings.Global#AIRPLANE_MODE_ON}.
     */
private void setupAirplaneModeListeners() {
    TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    for (PhoneStateListener listener : mPhoneStateListeners) {
        telephonyManager.listen(listener, PhoneStateListener.LISTEN_NONE);
    }
    mPhoneStateListeners.clear();
    final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(mContext).getActiveSubscriptionInfoList();
    if (subInfoList != null) {
        mHasTelephony = true;
        mAirplaneModeBits = new BitSet(subInfoList.size());
        for (int i = 0; i < subInfoList.size(); i++) {
            final int finalI = i;
            PhoneStateListener subListener = new PhoneStateListener(subInfoList.get(finalI).getSubscriptionId()) {

                @Override
                public void onServiceStateChanged(ServiceState serviceState) {
                    final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
                    mAirplaneModeBits.set(finalI, inAirplaneMode);
                    // we're in airplane mode if _any_ of the subscriptions say we are
                    mAirplaneState = mAirplaneModeBits.cardinality() > 0 ? ToggleAction.State.On : ToggleAction.State.Off;
                    mAirplaneModeOn.updateState(mAirplaneState);
                    if (mAdapter != null) {
                        mAdapter.notifyDataSetChanged();
                    }
                }
            };
            mPhoneStateListeners.add(subListener);
            telephonyManager.listen(subListener, PhoneStateListener.LISTEN_SERVICE_STATE);
        }
    } else {
        mHasTelephony = false;
    }
    // Set the initial status of airplane mode toggle
    mAirplaneState = getUpdatedAirplaneToggleState();
}
Also used : ServiceState(android.telephony.ServiceState) TelephonyManager(android.telephony.TelephonyManager) PhoneStateListener(android.telephony.PhoneStateListener) BitSet(java.util.BitSet) SubscriptionInfo(android.telephony.SubscriptionInfo) Paint(android.graphics.Paint)

Example 44 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.

the class EmergencyAffordanceService method handleUpdateSimSubscriptionInfo.

private boolean handleUpdateSimSubscriptionInfo() {
    boolean neededBefore = simNeededAffordanceBefore();
    boolean neededNow = neededBefore;
    List<SubscriptionInfo> activeSubscriptionInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
    if (activeSubscriptionInfoList == null) {
        return neededNow;
    }
    for (SubscriptionInfo info : activeSubscriptionInfoList) {
        int mcc = info.getMcc();
        if (mccRequiresEmergencyAffordance(mcc)) {
            neededNow = true;
            break;
        } else if (mcc != 0 && mcc != Integer.MAX_VALUE) {
            // a Sim with a different mcc code was found
            neededNow = false;
        }
        String simOperator = mTelephonyManager.getSimOperator(info.getSubscriptionId());
        mcc = 0;
        if (simOperator != null && simOperator.length() >= 3) {
            mcc = Integer.parseInt(simOperator.substring(0, 3));
        }
        if (mcc != 0) {
            if (mccRequiresEmergencyAffordance(mcc)) {
                neededNow = true;
                break;
            } else {
                // a Sim with a different mcc code was found
                neededNow = false;
            }
        }
    }
    setSimNeedsEmergencyAffordance(neededNow);
    return neededNow;
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 45 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_frameworks_base by AOSPA.

the class KeyguardSimPinView method showDefaultMessage.

private void showDefaultMessage() {
    if (mRemainingAttempts >= 0) {
        if (mResult != PhoneConstants.PIN_RESULT_SUCCESS)
            mSecurityMessageDisplay.setMessage(getPinPasswordErrorMessage(mRemainingAttempts, true), true);
        return;
    }
    mSlotId = SubscriptionManager.getSlotId(mSubId) + 1;
    int count = TelephonyManager.getDefault().getSimCount();
    Resources rez = getResources();
    final String msg;
    int color = Color.WHITE;
    if (count < 2) {
        msg = rez.getString(R.string.kg_sim_pin_instructions);
    } else {
        SubscriptionInfo info = KeyguardUpdateMonitor.getInstance(mContext).getSubscriptionInfoForSubId(mSubId);
        // don't crash
        CharSequence displayName = info != null ? info.getDisplayName() : "";
        msg = rez.getString(R.string.kg_sim_pin_instructions_multi, displayName);
        if (info != null) {
            color = info.getIconTint();
        }
    }
    mSecurityMessageDisplay.setMessage(msg, true);
    mSimImageView.setImageTintList(ColorStateList.valueOf(color));
    new CheckSimPin("", mSubId) {

        void onSimCheckResponse(final int result, final int attemptsRemaining) {
            Log.d(LOG_TAG, "onSimCheckResponse " + " dummy One result" + result + " attemptsRemaining=" + attemptsRemaining);
            if (attemptsRemaining >= 0) {
                mRemainingAttempts = attemptsRemaining;
                mResult = result;
                mSecurityMessageDisplay.setMessage(getPinPasswordErrorMessage(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