Loading src/java/com/android/internal/telephony/GsmCdmaPhone.java +5 −0 Original line number Diff line number Diff line Loading @@ -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; Loading tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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 { Loading tests/telephonytests/src/com/android/internal/telephony/SimulatedCommands.java +1 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading
src/java/com/android/internal/telephony/GsmCdmaPhone.java +5 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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 { Loading
tests/telephonytests/src/com/android/internal/telephony/SimulatedCommands.java +1 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading