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

Commit 05d22605 authored by Jordan Liu's avatar Jordan Liu Committed by Android (Google) Code Review
Browse files

Merge "Convert MEID 0's into null"

parents f3bbce91 f6488ebc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2786,6 +2786,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) {