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

Commit 602bfefb authored by Pengquan Meng's avatar Pengquan Meng
Browse files

Replace 'No Service' with 'Emergency Call Only'

This replace 'No Service' with 'Emergency Call Only' if none of the
phone's service state is in service and emergency call is available.

Bug: 134412556
Test: atest FrameworksTelephonyTests & manual test
Change-Id: I2467c439cef24037f9734d054d16bf1a3e165caa
parent 751b1604
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -4008,6 +4008,29 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            String gid2, String pnn, String spn, String carrierPrivilegeRules, String apn) {
    }

    /**
     * Check if the device can only make the emergency call. The device is emergency call only if
     * none of the phone is in service, and one of them has the capability to make the emergency
     * call.
     *
     * @return {@code True} if the device is emergency call only, otherwise return {@code False}.
     */
    public static boolean isEmergencyCallOnly() {
        boolean isEmergencyCallOnly = false;
        for (Phone phone : PhoneFactory.getPhones()) {
            if (phone != null) {
                ServiceState ss = phone.getServiceStateTracker().getServiceState();
                // One of the phone is in service, hence the device is not emergency call only.
                if (ss.getState() == ServiceState.STATE_IN_SERVICE
                        || ss.getDataRegState() == ServiceState.STATE_IN_SERVICE) {
                    return false;
                }
                isEmergencyCallOnly |= ss.isEmergencyOnly();
            }
        }
        return isEmergencyCallOnly;
    }

    /**
     * Get data connection tracker based on the transport type
     *
+1 −1
Original line number Diff line number Diff line
@@ -2628,7 +2628,7 @@ public class ServiceStateTracker extends Handler {
                final boolean forceDisplayNoService = mPhone.getContext().getResources().getBoolean(
                        com.android.internal.R.bool.config_display_no_service_when_sim_unready)
                        && !mIsSimReady;
                if (mEmergencyOnly && !forceDisplayNoService) {
                if (!forceDisplayNoService && Phone.isEmergencyCallOnly()) {
                    // No service but emergency call allowed
                    plmn = Resources.getSystem().
                            getText(com.android.internal.R.string.emergency_calls_only).toString();
+3 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.util.LocalLog;
import android.util.SparseArray;

import com.android.internal.telephony.GsmCdmaPhone;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.cdnr.EfData.EFSource;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.uicc.IccRecords;
@@ -380,8 +381,8 @@ public class CarrierDisplayNameResolver {
                com.android.internal.R.bool.config_display_no_service_when_sim_unready)
                && !isSimReady;
        ServiceState ss = getServiceState();
        if (ss.getVoiceRegState() == ServiceState.STATE_POWER_OFF || !ss.isEmergencyOnly()
                || forceDisplayNoService) {
        if (ss.getVoiceRegState() == ServiceState.STATE_POWER_OFF
                || forceDisplayNoService || !Phone.isEmergencyCallOnly()) {
            plmn = mContext.getResources().getString(
                    com.android.internal.R.string.lockscreen_carrier_default);
        } else {