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

Commit 5fb74efe authored by Jordan Liu's avatar Jordan Liu Committed by Automerger Merge Worker
Browse files

Merge "Convert MEID 0's into null" am: 43bf1366

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1566339

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1ce7bb07f2b45657de02eda82b9e5b8f02ec52e8
parents 608b77db 43bf1366
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2782,6 +2782,11 @@ public class GsmCdmaPhone extends Phone {
                mImeiSv = respId[1];
                mEsn  =  respId[2];
                mMeid =  respId[3];
                // some modems return all 0's instead of null/empty string when MEID is unavailable
                if (!TextUtils.isEmpty(mMeid) && mMeid.matches("^0*$")) {
                    logd("EVENT_GET_DEVICE_IDENTITY_DONE: set mMeid to null");
                    mMeid = null;
                }
            }
            break;

+28 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
@@ -71,6 +72,7 @@ import android.testing.TestableLooper;
import androidx.test.filters.FlakyTest;

import com.android.internal.telephony.test.SimulatedCommands;
import com.android.internal.telephony.test.SimulatedCommandsVerifier;
import com.android.internal.telephony.uicc.IccCardApplicationStatus;
import com.android.internal.telephony.uicc.IccCardStatus;
import com.android.internal.telephony.uicc.IccRecords;
@@ -981,6 +983,32 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        assertEquals(SimulatedCommands.FAKE_MEID, mPhoneUT.getMeid());
    }

    @Test
    public void testZeroMeid() {
        doReturn(false).when(mSST).isDeviceShuttingDown();

        SimulatedCommands sc = new SimulatedCommands() {
            @Override
            public void getDeviceIdentity(Message response) {
                SimulatedCommandsVerifier.getInstance().getDeviceIdentity(response);
                resultSuccess(response, new String[] {FAKE_IMEI, FAKE_IMEISV, FAKE_ESN, "0000000"});
            }
        };

        Phone phone = new GsmCdmaPhone(mContext, sc, mNotifier, true, 0,
                PhoneConstants.PHONE_TYPE_GSM, mTelephonyComponentFactory);
        phone.setVoiceCallSessionStats(mVoiceCallSessionStats);
        ArgumentCaptor<Integer> integerArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
        verify(mUiccController).registerForIccChanged(eq(phone), integerArgumentCaptor.capture(),
                nullable(Object.class));
        Message msg = Message.obtain();
        msg.what = integerArgumentCaptor.getValue();
        phone.sendMessage(msg);
        processAllMessages();

        assertNull(phone.getMeid());
    }

    @Test
    @SmallTest
    public void testEmergencyCallbackMessages() throws Exception {
+1 −1
Original line number Diff line number Diff line
@@ -1733,7 +1733,7 @@ public class SimulatedCommands extends BaseCommands
    }

    @UnsupportedAppUsage
    private void resultSuccess(Message result, Object ret) {
    protected void resultSuccess(Message result, Object ret) {
        if (result != null) {
            AsyncResult.forMessage(result).result = ret;
            if (mPausedResponseCount > 0) {