Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efc06fdc authored by Wileen Chiu's avatar Wileen Chiu Committed by Linux Build Service Account
Browse files

Add absent sim info to locked screen text

- For a multisim device, when only one sim is inserted
 that is pin locked, the carrier text only shows
'SIM CARD IS LOCKED - NO SERVICE' even though the
voice registration state for one of the phones is 12,
where emergency calls are allowed
- This occurs when the state above is reported for the
slot where a sim card is not inserted. We only check for
active subscriptions when creating the display text
- Add a check for when only one sim card is inserted. If
the voice registration state is out of service for both
slots, with at least one as 12 (emergency allowed)
show 'Emergency calls only' instead of 'No service'

Change-Id: Ib58b6b7431d7b29c770287037cbf07c8df101ae3
CRs-Fixed: 985955
parent 9b5aa647
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -233,6 +233,25 @@ public class CarrierText extends TextView {
                }
            }
        }
        /*
         * In the case where there is only one sim inserted in a multisim device, if
         * the voice registration service state is reported as 12 (no service with emergency)
         * for at least one of the sim concatenate the sim state with Emergency calls only"
         */
        if (N < TelephonyManager.getDefault().getPhoneCount() &&
                 mKeyguardUpdateMonitor.isEmergencyOnly()) {
            int presentSubId = mKeyguardUpdateMonitor.getPresentSubId();

            if (DEBUG) {
                Log.d(TAG, " Present sim - sub id: " + presentSubId);
            }
            if (presentSubId != -1) {
                CharSequence emergencyOnlyText =
                        getContext().getText(com.android.internal.R.string.emergency_calls_only);
                displayText = getCarrierTextForSimState(
                        mKeyguardUpdateMonitor.getSimState(presentSubId), emergencyOnlyText);
            }
        }
        if (allSimsMissing) {
            if (N != 0) {
                // Shows "No SIM card | Emergency calls only" on devices that are voice-capable.
+30 −0
Original line number Diff line number Diff line
@@ -387,6 +387,36 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        return mSubscriptionInfo;
    }

    public boolean isEmergencyOnly() {
        boolean isEmerg = false;
        ServiceState state;
        for (int slotId = 0; slotId < TelephonyManager.getDefault().getPhoneCount(); slotId++) {
            state = null;
            int[] subId = mSubscriptionManager.getSubId(slotId);
            if (subId != null && subId.length > 0) {
                state = mServiceStates.get(subId[0]);
            }
            if (state != null) {
                if (state.getVoiceRegState() == ServiceState.STATE_IN_SERVICE)
                    return false;
                else if (state.isEmergencyOnly()) {
                    isEmerg = true;
                }
            }
        }
        return isEmerg;
    }

    public int getPresentSubId() {
        for (int slotId = 0; slotId < TelephonyManager.getDefault().getPhoneCount(); slotId++) {
            int[] subId = mSubscriptionManager.getSubId(slotId);
            if (subId != null && subId.length > 0 && getSimState(subId[0]) != State.ABSENT) {
                return subId[0];
            }
        }
        return -1;
    }

    @Override
    public void onTrustManagedChanged(boolean managed, int userId) {
        mUserTrustIsManaged.put(userId, managed);