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

Commit d160a075 authored by Pengquan Meng's avatar Pengquan Meng Committed by Gerrit Code Review
Browse files

Merge "Replace 'No Service' with 'Emergency Call Only'"

parents c123bcf8 39ae14d5
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -4003,6 +4003,29 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            String gid2, String pnn, String spn) {
    }

    /**
     * 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 {