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

Commit c6708e31 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6800518 from 75531aea to rvc-qpr1-release

Change-Id: Iaca27517a10fcc1da23dea5959e55dc655b6e08f
parents 2f52c0fc 75531aea
Loading
Loading
Loading
Loading
+7 −17
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import android.telephony.CellIdentity;
import android.telephony.CellIdentityCdma;
import android.telephony.CellIdentityGsm;
import android.telephony.CellIdentityLte;
import android.telephony.CellIdentityNr;
import android.telephony.CellIdentityTdscdma;
import android.telephony.CellIdentityWcdma;
import android.telephony.CellInfo;
@@ -2388,14 +2389,15 @@ public class ServiceStateTracker extends Handler {
     *
     * @returns the cell ID (unique within a PLMN for a given tech) or -1 if invalid
     */
    private static int getCidFromCellIdentity(CellIdentity id) {
    private static long getCidFromCellIdentity(CellIdentity id) {
        if (id == null) return -1;
        int cid = -1;
        long cid = -1;
        switch(id.getType()) {
            case CellInfo.TYPE_GSM: cid = ((CellIdentityGsm) id).getCid(); break;
            case CellInfo.TYPE_WCDMA: cid = ((CellIdentityWcdma) id).getCid(); break;
            case CellInfo.TYPE_TDSCDMA: cid = ((CellIdentityTdscdma) id).getCid(); break;
            case CellInfo.TYPE_LTE: cid = ((CellIdentityLte) id).getCi(); break;
            case CellInfo.TYPE_NR: cid = ((CellIdentityNr) id).getNci(); break;
            default: break;
        }
        // If the CID is unreported
@@ -2742,10 +2744,6 @@ public class ServiceStateTracker extends Handler {
            //    EXTRA_SHOW_PLMN = true
            //    EXTRA_PLMN = null

            // 5) Airplane mode but connected to WiFi with WFC disabled
            //    EXTRA_SHOW_PLMN = true
            //    EXTRA_PLMN = plmn

            IccRecords iccRecords = mIccRecords;
            int rule = getCarrierNameDisplayBitmask(mSS);
            boolean noService = false;
@@ -2777,17 +2775,9 @@ public class ServiceStateTracker extends Handler {
                                == CARRIER_NAME_DISPLAY_BITMASK_SHOW_PLMN);
                if (DBG) log("updateSpnDisplay: rawPlmn = " + plmn);
            } else {
                // Power off state, such as airplane mode, show plmn as "No service"
                // unless connected to WiFi with WFC disabled, then show plmn
                // Power off state, such as airplane mode, show plmn as null
                showPlmn = true;
                if (mPhone.getImsPhone() != null && !mPhone.getImsPhone().isWifiCallingEnabled()
                        && mSS.getDataNetworkType() == TelephonyManager.NETWORK_TYPE_IWLAN) {
                    plmn = mSS.getOperatorAlpha();
                } else {
                    plmn = Resources.getSystem()
                            .getText(com.android.internal.R.string.lockscreen_carrier_default)
                            .toString();
                }
                plmn = null;
                if (DBG) log("updateSpnDisplay: radio is off w/ showPlmn="
                        + showPlmn + " plmn=" + plmn);
            }
@@ -3403,7 +3393,7 @@ public class ServiceStateTracker extends Handler {
            // TODO: we may add filtering to reduce the event logged,
            // i.e. check preferred network setting, only switch to 2G, etc
            if (hasRilVoiceRadioTechnologyChanged) {
                int cid = getCidFromCellIdentity(primaryCellIdentity);
                long cid = getCidFromCellIdentity(primaryCellIdentity);
                // NOTE: this code was previously located after mSS and mNewSS are swapped, so
                // existing logs were incorrectly using the new state for "network_from"
                // and STATE_OUT_OF_SERVICE for "network_to". To avoid confusion, use a new log tag
+14 −5
Original line number Diff line number Diff line
@@ -377,12 +377,15 @@ public class CarrierDisplayNameResolver {
     */
    private CarrierDisplayNameData getOutOfServiceDisplayName(CarrierDisplayNameData data) {
        // Out of service/Power off/Emergency Only override
        // 1) In flight mode(service state is ServiceState.STATE_POWER_OFF), or the service
        //    state is ServiceState.STATE_OUT_OF_SERVICE but emergency call is not allowed.
        // 1) In flight mode (service state is ServiceState.STATE_POWER_OFF).
        //    showPlmn = true
        //    Only show null as PLMN
        //
        // 2) Service state is ServiceState.STATE_OUT_OF_SERVICE but emergency call is not allowed.
        //    showPlmn = true
        //    Only show "No Service" as PLMN
        //
        // 2) Out of service but emergency call is allowed.
        // 3) Out of service but emergency call is allowed.
        //    showPlmn = true
        //    Only show "Emergency call only" as PLMN
        String plmn = null;
@@ -391,8 +394,10 @@ public class CarrierDisplayNameResolver {
        boolean forceDisplayNoService =
                mPhone.getServiceStateTracker().shouldForceDisplayNoService() && !isSimReady;
        ServiceState ss = getServiceState();
        if (ss.getState() == ServiceState.STATE_POWER_OFF
                || forceDisplayNoService || !Phone.isEmergencyCallOnly()) {
        if (ss.getState() == ServiceState.STATE_POWER_OFF && !forceDisplayNoService
                && !Phone.isEmergencyCallOnly()) {
            plmn = null;
        } else if (forceDisplayNoService || !Phone.isEmergencyCallOnly()) {
            plmn = mContext.getResources().getString(
                    com.android.internal.R.string.lockscreen_carrier_default);
        } else {
@@ -417,6 +422,10 @@ public class CarrierDisplayNameResolver {
                if (DBG) {
                    Rlog.d(TAG, "CarrierName override by wifi-calling " + data);
                }
            } else if (getServiceState().getState() == ServiceState.STATE_POWER_OFF) {
                // data in service due to IWLAN but APM on and WFC not available
                data = getOutOfServiceDisplayName(data);
                if (DBG) Rlog.d(TAG, "Out of service carrierName (APM) " + data);
            }
        } else {
            data = getOutOfServiceDisplayName(data);
+29 −4
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ import android.telephony.CellIdentity;
import android.telephony.CellIdentityCdma;
import android.telephony.CellIdentityGsm;
import android.telephony.CellIdentityLte;
import android.telephony.CellIdentityNr;
import android.telephony.CellIdentityTdscdma;
import android.telephony.CellIdentityWcdma;
import android.telephony.CellInfo;
import android.telephony.CellInfoGsm;
import android.telephony.CellSignalStrength;
@@ -107,6 +110,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -2455,7 +2459,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    }

    @Test
    public void testUpdateSpnDisplay_flightMode_displayOOS() {
    public void testUpdateSpnDisplay_flightMode_displayNull() {
        // GSM phone
        doReturn(true).when(mPhone).isPhoneTypeGsm();

@@ -2468,10 +2472,9 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        // update the spn
        sst.updateSpnDisplay();

        // Plmn should be shown, and the string is "No service"
        // Plmn should be shown, and the string is null
        Bundle b = getExtrasFromLastSpnUpdateIntent();
        assertThat(b.getString(TelephonyManager.EXTRA_PLMN))
                .isEqualTo(CARRIER_NAME_DISPLAY_NO_SERVICE);
        assertThat(b.getString(TelephonyManager.EXTRA_PLMN)).isEqualTo(null);
        assertThat(b.getBoolean(TelephonyManager.EXTRA_SHOW_PLMN)).isTrue();
    }

@@ -2720,4 +2723,26 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertEquals(cids.get(0), cellIdentityLte);
        assertEquals(cids.get(1), cellIdentityGsm);
    }

    @Test
    public void testGetCidFromCellIdentity() throws Exception {
        CellIdentity gsmCi = new CellIdentityGsm(
                0, 1, 0, 0, "", "", "", "", Collections.emptyList());
        CellIdentity wcdmaCi = new CellIdentityWcdma(
                0, 2, 0, 0, "", "", "", "", Collections.emptyList(), null);
        CellIdentity tdscdmaCi = new CellIdentityTdscdma(
                "", "", 0, 3, 0, 0, "", "", Collections.emptyList(), null);
        CellIdentity lteCi = new CellIdentityLte(0, 0, 4, 0, 0);
        CellIdentity nrCi = new CellIdentityNr(
                0, 0, 0, new int[] {}, "", "", 5, "", "", Collections.emptyList());

        Method method = ServiceStateTracker.class.getDeclaredMethod(
                "getCidFromCellIdentity", CellIdentity.class);
        method.setAccessible(true);
        assertEquals(1, (long) method.invoke(mSST, gsmCi));
        assertEquals(2, (long) method.invoke(mSST, wcdmaCi));
        assertEquals(3, (long) method.invoke(mSST, tdscdmaCi));
        assertEquals(4, (long) method.invoke(mSST, lteCi));
        assertEquals(5, (long) method.invoke(mSST, nrCi));
    }
}