Fixed failing tests.
Amit Mahajan [Mon, 29 Aug 2016 21:57:10 +0000 (14:57 -0700)]
Also marked some of them @Postsubmit.

Bug: 31041734
Change-Id: I9a93bbb6d7f9c28fa90bab260d837761bc07eb77

26 files changed:
src/java/com/android/internal/telephony/dataconnection/DcTracker.java
tests/telephonytests/src/com/android/internal/telephony/CallManagerTest.java
tests/telephonytests/src/com/android/internal/telephony/GsmCdmaCallTrackerTest.java
tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java
tests/telephonytests/src/com/android/internal/telephony/ImsSMSDispatcherTest.java
tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java
tests/telephonytests/src/com/android/internal/telephony/PhoneStateListenerTest.java
tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java
tests/telephonytests/src/com/android/internal/telephony/SmsStorageMonitorTest.java
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java
tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaInboundSmsHandlerTest.java
tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsDispatcherTest.java
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcControllerTest.java
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java
tests/telephonytests/src/com/android/internal/telephony/gsm/GsmCellBroadcastHandlerTest.java
tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java
tests/telephonytests/src/com/android/internal/telephony/gsm/GsmSmsDispatcherTest.java
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsExternalCallTrackerTest.java
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneFactoryTest.java
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java
tests/telephonytests/src/com/android/internal/telephony/uicc/IccPhoneBookInterfaceManagerTest.java
tests/telephonytests/src/com/android/internal/telephony/uicc/UiccCardApplicationTest.java
tests/telephonytests/src/com/android/internal/telephony/uicc/UiccCardTest.java
tests/telephonytests/src/com/android/internal/telephony/uicc/UiccControllerTest.java

index 83c5d4b..4cc4792 100644 (file)
@@ -1090,7 +1090,7 @@ public class DcTracker extends Handler {
 
     @Override
     protected void finalize() {
-        if(DBG) log("finalize");
+        if(DBG && mPhone != null) log("finalize");
     }
 
     private ApnContext addApnContext(String type, NetworkConfig networkConfig) {
index cfa3bcb..a255f26 100644 (file)
@@ -122,6 +122,7 @@ public class CallManagerTest extends TelephonyTest {
     @After
     public void tearDown() throws Exception {
         CallManager.getInstance().unregisterPhone(mPhone);
+        mCallManagerHandlerThread.quitSafely();
         super.tearDown();
     }
 
index edb4554..0c9e1a1 100644 (file)
@@ -44,6 +44,7 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
     private String mDialString = PhoneNumberUtils.stripSeparators("+17005554141");
     /* Handler class initiated at the HandlerThread */
     private GsmCdmaCallTracker mCTUT;
+    private GsmCdmaCTHandlerThread mGsmCdmaCTHandlerThread;
     @Mock
     GsmCdmaCall mCall;
     @Mock
@@ -69,7 +70,8 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
         mContextFixture.putStringArrayResource(com.android.internal.R.array.dial_string_replace,
                 new String[]{});
 
-        new GsmCdmaCTHandlerThread(TAG).start();
+        mGsmCdmaCTHandlerThread = new GsmCdmaCTHandlerThread(TAG);
+        mGsmCdmaCTHandlerThread.start();
 
         waitUntilReady();
         logd("GsmCdmaCallTracker initiated, waiting for Power on");
@@ -82,6 +84,7 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
     @After
     public void tearDown() throws Exception {
         mCTUT = null;
+        mGsmCdmaCTHandlerThread.quitSafely();
         super.tearDown();
     }
 
index 201a0aa..103da3d 100644 (file)
@@ -72,6 +72,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
 
     //mPhoneUnderTest
     private GsmCdmaPhone mPhoneUT;
+    private GsmCdmaPhoneTestHandler mGsmCdmaPhoneTestHandler;
 
     private static final int EVENT_EMERGENCY_CALLBACK_MODE_EXIT = 1;
     private static final int EVENT_EMERGENCY_CALL_TOGGLE = 2;
@@ -114,7 +115,8 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
 
         doReturn(false).when(mSST).isDeviceShuttingDown();
 
-        new GsmCdmaPhoneTestHandler(TAG).start();
+        mGsmCdmaPhoneTestHandler = new GsmCdmaPhoneTestHandler(TAG);
+        mGsmCdmaPhoneTestHandler.start();
         waitUntilReady();
         ArgumentCaptor<Integer> integerArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
         verify(mUiccController).registerForIccChanged(eq(mPhoneUT), integerArgumentCaptor.capture(),
@@ -129,6 +131,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
     public void tearDown() throws Exception {
         mPhoneUT.removeCallbacksAndMessages(null);
         mPhoneUT = null;
+        mGsmCdmaPhoneTestHandler.quitSafely();
         super.tearDown();
     }
 
index fc755bb..24c1283 100644 (file)
@@ -52,6 +52,7 @@ public class ImsSMSDispatcherTest extends TelephonyTest {
     private SMSDispatcher.SmsTracker mTracker;
 
     private ImsSMSDispatcher mImsSmsDispatcher;
+    private ImsSmsDispatcherTestHandler mImsSmsDispatcherTestHandler;
     private boolean mReceivedTestIntent = false;
     private Object mLock = new Object();
     private static final String TEST_INTENT = "com.android.internal.telephony.TEST_INTENT";
@@ -86,13 +87,15 @@ public class ImsSMSDispatcherTest extends TelephonyTest {
         super.setUp(getClass().getSimpleName());
         setupMockPackagePermissionChecks();
 
-        new ImsSmsDispatcherTestHandler(getClass().getSimpleName()).start();
+        mImsSmsDispatcherTestHandler = new ImsSmsDispatcherTestHandler(getClass().getSimpleName());
+        mImsSmsDispatcherTestHandler.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
         mImsSmsDispatcher = null;
+        mImsSmsDispatcherTestHandler.quitSafely();
         super.tearDown();
     }
 
index 31510b7..5af733b 100644 (file)
@@ -17,6 +17,7 @@
 package com.android.internal.telephony;
 
 import android.net.Uri;
+import android.platform.test.annotations.Postsubmit;
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 import android.text.SpannableStringBuilder;
@@ -412,6 +413,7 @@ public class PhoneNumberUtilsTest extends AndroidTestCase {
     }
 
     // To run this test, the device has to be registered with network
+    @Postsubmit
     public void testCheckAndProcessPlusCode() {
         assertEquals("0118475797000",
                 PhoneNumberUtils.cdmaCheckAndProcessPlusCode("+8475797000"));
index fe2bf9c..4a17199 100644 (file)
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.verify;
 public class PhoneStateListenerTest extends TelephonyTest {
 
     private PhoneStateListener mPhoneStateListenerUT;
+    private PhoneStateListenerHandler mPhoneStateListenerHandler;
 
     private class PhoneStateListenerHandler extends HandlerThread {
         private PhoneStateListenerHandler(String name) {
@@ -52,12 +53,14 @@ public class PhoneStateListenerTest extends TelephonyTest {
     @Before
     public void setUp() throws Exception {
         this.setUp(this.getClass().getSimpleName());
-        new PhoneStateListenerHandler(TAG).start();
+        mPhoneStateListenerHandler = new PhoneStateListenerHandler(TAG);
+        mPhoneStateListenerHandler.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
+        mPhoneStateListenerHandler.quitSafely();
         super.tearDown();
     }
 
index caee15d..1841e02 100644 (file)
@@ -28,7 +28,6 @@ import android.os.Message;
 import android.os.Parcel;
 import android.os.SystemClock;
 import android.os.UserHandle;
-import android.platform.test.annotations.Postsubmit;
 import android.telephony.CellInfo;
 import android.telephony.CellInfoGsm;
 import android.telephony.ServiceState;
@@ -140,6 +139,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
     @After
     public void tearDown() throws Exception {
         sst = null;
+        mSSTTestHandler.quitSafely();
         super.tearDown();
     }
 
@@ -185,10 +185,9 @@ public class ServiceStateTrackerTest extends TelephonyTest {
         assertTrue(sst.getPowerStateFromCarrier());
     }
 
-    @Postsubmit
     @Test
     @MediumTest
-    public void testNoRilTrafficAfterSetRadioPower() {
+    public void testRilTrafficAfterSetRadioPower() {
         sst.setRadioPower(true);
         final int getOperatorCallCount = mSimulatedCommands.getGetOperatorCallCount();
         final int getDataRegistrationStateCallCount =
@@ -203,12 +202,14 @@ public class ServiceStateTrackerTest extends TelephonyTest {
         sst.pollState();
         waitForMs(250);
 
-        assertEquals(getOperatorCallCount, mSimulatedCommands.getGetOperatorCallCount());
-        assertEquals(getDataRegistrationStateCallCount,
+        // This test was meant to be for *no* ril traffic. However, RADIO_STATE_CHANGED is
+        // considered a modem triggered action and that causes a pollState() to be done
+        assertEquals(getOperatorCallCount + 1, mSimulatedCommands.getGetOperatorCallCount());
+        assertEquals(getDataRegistrationStateCallCount + 1,
                 mSimulatedCommands.getGetDataRegistrationStateCallCount());
-        assertEquals(getVoiceRegistrationStateCallCount,
+        assertEquals(getVoiceRegistrationStateCallCount + 1,
                 mSimulatedCommands.getGetVoiceRegistrationStateCallCount());
-        assertEquals(getNetworkSelectionModeCallCount,
+        assertEquals(getNetworkSelectionModeCallCount + 1,
                 mSimulatedCommands.getGetNetworkSelectionModeCallCount());
 
         // Note that if the poll is triggered by a network change notification
@@ -216,12 +217,12 @@ public class ServiceStateTrackerTest extends TelephonyTest {
         mSimulatedCommands.notifyVoiceNetworkStateChanged();
         waitForMs(250);
 
-        assertEquals(getOperatorCallCount + 1 , mSimulatedCommands.getGetOperatorCallCount());
-        assertEquals(getDataRegistrationStateCallCount + 1,
+        assertEquals(getOperatorCallCount + 2 , mSimulatedCommands.getGetOperatorCallCount());
+        assertEquals(getDataRegistrationStateCallCount + 2,
                 mSimulatedCommands.getGetDataRegistrationStateCallCount());
-        assertEquals(getVoiceRegistrationStateCallCount + 1,
+        assertEquals(getVoiceRegistrationStateCallCount + 2,
                 mSimulatedCommands.getGetVoiceRegistrationStateCallCount());
-        assertEquals(getNetworkSelectionModeCallCount + 1,
+        assertEquals(getNetworkSelectionModeCallCount + 2,
                 mSimulatedCommands.getGetNetworkSelectionModeCallCount());
     }
 
@@ -295,7 +296,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
     @MediumTest
     public void testImsRegState() {
         // Simulate IMS registered
-        mSimulatedCommands.setImsRegistrationState(new int[]{1});
+        mSimulatedCommands.setImsRegistrationState(new int[]{1, PhoneConstants.PHONE_TYPE_GSM});
 
         sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_IMS_STATE_CHANGED, null));
         waitForMs(200);
@@ -303,7 +304,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
         assertTrue(sst.isImsRegistered());
 
         // Simulate IMS unregistered
-        mSimulatedCommands.setImsRegistrationState(new int[]{0});
+        mSimulatedCommands.setImsRegistrationState(new int[]{0, PhoneConstants.PHONE_TYPE_GSM});
 
         sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_IMS_STATE_CHANGED, null));
         waitForMs(200);
index 2911c3f..7c8c15c 100644 (file)
@@ -41,6 +41,7 @@ import static org.mockito.Mockito.*;
 public class SmsStorageMonitorTest extends TelephonyTest {
 
     private SmsStorageMonitor mSmsStorageMonitor;
+    private SmsStorageMonitorTestHandler mSmsStorageMonitorTestHandler;
 
     private class SmsStorageMonitorTestHandler extends HandlerThread {
 
@@ -58,13 +59,15 @@ public class SmsStorageMonitorTest extends TelephonyTest {
     @Before
     public void setUp() throws Exception {
         super.setUp(getClass().getSimpleName());
-        new SmsStorageMonitorTestHandler(TAG).start();
+        mSmsStorageMonitorTestHandler = new SmsStorageMonitorTestHandler(TAG);
+        mSmsStorageMonitorTestHandler.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
         mSmsStorageMonitor = null;
+        mSmsStorageMonitorTestHandler.quitSafely();
         super.tearDown();
     }
 
index 3b28327..2834304 100644 (file)
@@ -67,7 +67,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
     private static final int FAKE_SUB_ID = 1;
     private static final String FAKE_PLMN = "123456";
 
-
+    private SubscriptionInfoUpdaterHandlerThread mSubscriptionInfoUpdaterHandlerThread;
     private IccRecords mIccRecord;
     @Mock
     private UserInfo mUserInfo;
@@ -130,12 +130,14 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                 mContentProvider);
         mIccRecord = mIccCardProxy.getIccRecords();
 
-        new SubscriptionInfoUpdaterHandlerThread(TAG).start();
+        mSubscriptionInfoUpdaterHandlerThread = new SubscriptionInfoUpdaterHandlerThread(TAG);
+        mSubscriptionInfoUpdaterHandlerThread.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
+        mSubscriptionInfoUpdaterHandlerThread.quitSafely();
         super.tearDown();
     }
 
index 0f2138b..e635793 100644 (file)
@@ -34,6 +34,7 @@ import com.android.internal.telephony.InboundSmsHandler;
 import com.android.internal.telephony.SmsStorageMonitor;
 import com.android.internal.telephony.TelephonyTest;
 import com.android.internal.telephony.cdma.sms.SmsEnvelope;
+import com.android.internal.util.HexDump;
 import com.android.internal.util.IState;
 import com.android.internal.util.StateMachine;
 
@@ -67,6 +68,7 @@ public class CdmaInboundSmsHandlerTest extends TelephonyTest {
     private SmsMessage mCdmaSmsMessage;
 
     private CdmaInboundSmsHandler mCdmaInboundSmsHandler;
+    private CdmaInboundSmsHandlerTestHandler mCdmaInboundSmsHandlerTestHandler;
     private SmsEnvelope mSmsEnvelope = new SmsEnvelope();
     private ContentValues mInboundSmsTrackerCV = new ContentValues();
     private FakeSmsContentProvider mContentProvider;
@@ -118,6 +120,16 @@ public class CdmaInboundSmsHandlerTest extends TelephonyTest {
         mSmsMessage.mWrappedSmsMessage = mCdmaSmsMessage;
         doReturn(smsPdu).when(mCdmaSmsMessage).getPdu();
 
+        mInboundSmsTrackerCV.put("destination_port", 1 << 16);
+        mInboundSmsTrackerCV.put("pdu", HexDump.toHexString(smsPdu));
+        mInboundSmsTrackerCV.put("address", "1234567890");
+        mInboundSmsTrackerCV.put("reference_number", 1);
+        mInboundSmsTrackerCV.put("sequence", 1);
+        mInboundSmsTrackerCV.put("count", 1);
+        mInboundSmsTrackerCV.put("date", System.currentTimeMillis());
+        mInboundSmsTrackerCV.put("message_body", "This is the message body of a single-part " +
+                "message");
+
         doReturn(true).when(mTelephonyManager).getSmsReceiveCapableForPhone(anyInt(), anyBoolean());
         doReturn(true).when(mSmsStorageMonitor).isStorageAvailable();
         doReturn(1).when(mInboundSmsTracker).getMessageCount();
@@ -131,7 +143,8 @@ public class CdmaInboundSmsHandlerTest extends TelephonyTest {
         ((MockContentResolver)mContext.getContentResolver()).addProvider(
                 Telephony.Sms.CONTENT_URI.getAuthority(), mContentProvider);
 
-        new CdmaInboundSmsHandlerTestHandler(TAG).start();
+        mCdmaInboundSmsHandlerTestHandler = new CdmaInboundSmsHandlerTestHandler(TAG);
+        mCdmaInboundSmsHandlerTestHandler.start();
         waitUntilReady();
     }
 
@@ -146,6 +159,7 @@ public class CdmaInboundSmsHandlerTest extends TelephonyTest {
         assertFalse(mCdmaInboundSmsHandler.getWakeLock().isHeld());
         mCdmaInboundSmsHandler = null;
         mContentProvider.shutdown();
+        mCdmaInboundSmsHandlerTestHandler.quitSafely();
         super.tearDown();
     }
 
index f71367b..37f09b5 100644 (file)
@@ -42,6 +42,7 @@ public class CdmaSmsDispatcherTest extends TelephonyTest {
     private SMSDispatcher.SmsTracker mSmsTracker;
 
     private CdmaSMSDispatcher mCdmaSmsDispatcher;
+    private CdmaSmsDispatcherTestHandler mCdmaSmsDispatcherTestHandler;
 
     private class CdmaSmsDispatcherTestHandler extends HandlerThread {
 
@@ -63,13 +64,15 @@ public class CdmaSmsDispatcherTest extends TelephonyTest {
 
         setupMockPackagePermissionChecks();
 
-        new CdmaSmsDispatcherTestHandler(TAG).start();
+        mCdmaSmsDispatcherTestHandler = new CdmaSmsDispatcherTestHandler(TAG);
+        mCdmaSmsDispatcherTestHandler.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
         mCdmaSmsDispatcher = null;
+        mCdmaSmsDispatcherTestHandler.quitSafely();
         super.tearDown();
     }
 
index 5f1c4e3..579b45b 100644 (file)
@@ -70,6 +70,7 @@ public class DataConnectionTest extends TelephonyTest {
     DcFailBringUp mDcFailBringUp;
 
     private DataConnection mDc;
+    private DataConnectionTestHandler mDataConnectionTestHandler;
     private DcController mDcc;
 
     private ApnSetting mApn1 = new ApnSetting(
@@ -149,7 +150,8 @@ public class DataConnectionTest extends TelephonyTest {
 
         mDcp.mApnContext = mApnContext;
 
-        new DataConnectionTestHandler(getClass().getSimpleName()).start();
+        mDataConnectionTestHandler = new DataConnectionTestHandler(getClass().getSimpleName());
+        mDataConnectionTestHandler.start();
 
         waitUntilReady();
         logd("-Setup!");
@@ -160,6 +162,7 @@ public class DataConnectionTest extends TelephonyTest {
         logd("tearDown");
         mDc = null;
         mDcc = null;
+        mDataConnectionTestHandler.quitSafely();
         super.tearDown();
     }
 
index 181ea42..cb4232c 100644 (file)
@@ -60,6 +60,7 @@ public class DcControllerTest extends TelephonyTest {
     UpdateLinkPropertyResult mResult;
 
     private DcController mDcc;
+    private DcControllerTestHandler mDcControllerTestHandler;
 
     private class DcControllerTestHandler extends HandlerThread {
 
@@ -100,12 +101,14 @@ public class DcControllerTest extends TelephonyTest {
         mResult = new UpdateLinkPropertyResult(lp);
         doReturn(mResult).when(mDc).updateLinkProperty(any(DataCallResponse.class));
 
-        new DcControllerTestHandler(TAG).start();
+        mDcControllerTestHandler = new DcControllerTestHandler(TAG);
+        mDcControllerTestHandler.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
+        mDcControllerTestHandler.quitSafely();
         super.tearDown();
     }
 
index 2ce6324..0cd750b 100644 (file)
@@ -112,6 +112,7 @@ public class DcTrackerTest extends TelephonyTest {
     SubscriptionInfo mSubscriptionInfo;
 
     private DcTracker mDct;
+    private DcTrackerTestHandler mDcTrackerTestHandler;
 
     private AlarmManager mAlarmManager;
 
@@ -333,7 +334,8 @@ public class DcTrackerTest extends TelephonyTest {
         mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
         mBundle = mContextFixture.getCarrierConfigBundle();
 
-        new DcTrackerTestHandler(getClass().getSimpleName()).start();
+        mDcTrackerTestHandler = new DcTrackerTestHandler(getClass().getSimpleName());
+        mDcTrackerTestHandler.start();
         waitUntilReady();
         waitForMs(600);
         logd("DcTrackerTest -Setup!");
@@ -344,6 +346,7 @@ public class DcTrackerTest extends TelephonyTest {
         logd("DcTrackerTest -tearDown");
         mDct.removeCallbacksAndMessages(null);
         mDct = null;
+        mDcTrackerTestHandler.quitSafely();
         super.tearDown();
     }
 
index 3a9df0d..2cddd8a 100644 (file)
@@ -46,7 +46,7 @@ public class GsmCellBroadcastHandlerTest extends TelephonyTest {
     private SmsMessage mGsmSmsMessage;
 
     private GsmCellBroadcastHandler mGsmCellBroadcastHandler;
-
+    private GsmCellBroadcastHandlerTestHandler mGsmCellBroadcastHandlerTestHandler;
 
     private class GsmCellBroadcastHandlerTestHandler extends HandlerThread {
 
@@ -70,13 +70,16 @@ public class GsmCellBroadcastHandlerTest extends TelephonyTest {
         doReturn(true).when(mTelephonyManager).getSmsReceiveCapableForPhone(anyInt(), anyBoolean());
         doReturn(true).when(mSmsStorageMonitor).isStorageAvailable();
 
-        new GsmCellBroadcastHandlerTestHandler(getClass().getSimpleName()).start();
+        mGsmCellBroadcastHandlerTestHandler =
+                new GsmCellBroadcastHandlerTestHandler(getClass().getSimpleName());
+        mGsmCellBroadcastHandlerTestHandler.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
         mGsmCellBroadcastHandler = null;
+        mGsmCellBroadcastHandlerTestHandler.quitSafely();
         super.tearDown();
     }
 
index 7e10229..9729729 100644 (file)
@@ -74,6 +74,7 @@ public class GsmInboundSmsHandlerTest extends TelephonyTest {
     private CdmaInboundSmsHandler mCdmaInboundSmsHandler;
 
     private GsmInboundSmsHandler mGsmInboundSmsHandler;
+    private GsmInboundSmsHandlerTestHandler mGsmInboundSmsHandlerTestHandler;
 
     private FakeSmsContentProvider mContentProvider;
     private static final String RAW_TABLE_NAME = "raw";
@@ -156,7 +157,8 @@ public class GsmInboundSmsHandlerTest extends TelephonyTest {
         ((MockContentResolver)mContext.getContentResolver()).addProvider(
                 Telephony.Sms.CONTENT_URI.getAuthority(), mContentProvider);
 
-        new GsmInboundSmsHandlerTestHandler(TAG).start();
+        mGsmInboundSmsHandlerTestHandler = new GsmInboundSmsHandlerTestHandler(TAG);
+        mGsmInboundSmsHandlerTestHandler.start();
         waitUntilReady();
     }
 
@@ -171,6 +173,7 @@ public class GsmInboundSmsHandlerTest extends TelephonyTest {
         assertFalse(mGsmInboundSmsHandler.getWakeLock().isHeld());
         mGsmInboundSmsHandler = null;
         mContentProvider.shutdown();
+        mGsmInboundSmsHandlerTestHandler.quitSafely();
         super.tearDown();
     }
 
index 8a4277c..2b7f33b 100644 (file)
@@ -57,6 +57,7 @@ public class GsmSmsDispatcherTest extends TelephonyTest {
     private ISub.Stub mISubStub;
 
     private GsmSMSDispatcher mGsmSmsDispatcher;
+    private GsmSmsDispatcherTestHandler mGsmSmsDispatcherTestHandler;
 
     private class GsmSmsDispatcherTestHandler extends HandlerThread {
 
@@ -81,13 +82,15 @@ public class GsmSmsDispatcherTest extends TelephonyTest {
         // in the cache, a real instance is used.
         mServiceManagerMockedServices.put("isub", mISubStub);
 
-        new GsmSmsDispatcherTestHandler(getClass().getSimpleName()).start();
+        mGsmSmsDispatcherTestHandler = new GsmSmsDispatcherTestHandler(getClass().getSimpleName());
+        mGsmSmsDispatcherTestHandler.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
         mGsmSmsDispatcher = null;
+        mGsmSmsDispatcherTestHandler.quitSafely();
         super.tearDown();
     }
 
index b60112b..bc12cf0 100644 (file)
@@ -31,6 +31,7 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
 import android.net.Uri;
+import android.platform.test.annotations.Postsubmit;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -68,6 +69,7 @@ public class ImsExternalCallTrackerTest {
         mTracker = new ImsExternalCallTracker(mImsPhone, mImsPullCall, mCallNotifier);
     }
 
+    @Postsubmit
     @Test
     public void testAddExternalCall() {
         List<ImsExternalCallState> dep = new ArrayList<>();
@@ -90,6 +92,7 @@ public class ImsExternalCallTrackerTest {
         assert(connection instanceof ImsExternalConnection);
     }
 
+    @Postsubmit
     @Test
     public void testRemoveExternalCall() {
         testAddExternalCall();
index 3662777..116dcdd 100644 (file)
@@ -61,6 +61,7 @@ import static org.mockito.Mockito.verify;
 
 public class ImsPhoneCallTrackerTest extends TelephonyTest {
     private ImsPhoneCallTracker mCTUT;
+    private ImsCTHandlerThread mImsCTHandlerThread;
     private ImsConnectionStateListener mImsConnectionStateListener;
     private ImsCall.Listener mImsCallListener;
     private ImsCall mImsCall;
@@ -177,7 +178,8 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
         }).when(mImsManager).makeCall(eq(mServiceId), eq(mImsCallProfile), (String []) any(),
                 (ImsCall.Listener) any());
 
-        new ImsCTHandlerThread(this.getClass().getSimpleName()).start();
+        mImsCTHandlerThread = new ImsCTHandlerThread(this.getClass().getSimpleName());
+        mImsCTHandlerThread.start();
 
         waitUntilReady();
         logd("ImsPhoneCallTracker initiated");
@@ -188,6 +190,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
     @After
     public void tearDown() throws Exception {
         mCTUT = null;
+        mImsCTHandlerThread.quitSafely();
         super.tearDown();
     }
 
index b78bd62..8a7c53a 100644 (file)
@@ -35,6 +35,7 @@ public class ImsPhoneFactoryTest extends TelephonyTest {
     @Mock
     private PhoneNotifier mPhoneNotifer;
     private ImsPhone mImsPhoneUT;
+    private ImsPhoneFactoryHandler mImsPhoneFactoryHandler;
 
     private class ImsPhoneFactoryHandler extends HandlerThread {
 
@@ -51,13 +52,15 @@ public class ImsPhoneFactoryTest extends TelephonyTest {
     @Before
     public void setUp() throws Exception {
         super.setUp(this.getClass().getSimpleName());
-        new ImsPhoneFactoryHandler(this.getClass().getSimpleName()).start();
+        mImsPhoneFactoryHandler = new ImsPhoneFactoryHandler(this.getClass().getSimpleName());
+        mImsPhoneFactoryHandler.start();
 
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
+        mImsPhoneFactoryHandler.quitSafely();
         super.tearDown();
     }
 
index 472c7c3..934f87a 100644 (file)
@@ -91,6 +91,7 @@ public class ImsPhoneTest extends TelephonyTest {
     ImsUtInterface mImsUtInterface;
 
     private ImsPhone mImsPhoneUT;
+    private ImsPhoneTestHandler mImsPhoneTestHandler;
     private boolean mDoesRilSendMultipleCallRing;
     private static final int EVENT_SUPP_SERVICE_NOTIFICATION = 1;
     private static final int EVENT_SUPP_SERVICE_FAILED = 2;
@@ -123,7 +124,8 @@ public class ImsPhoneTest extends TelephonyTest {
 
         mContextFixture.putBooleanResource(com.android.internal.R.bool.config_voice_capable, true);
 
-        new ImsPhoneTestHandler(TAG).start();
+        mImsPhoneTestHandler = new ImsPhoneTestHandler(TAG);
+        mImsPhoneTestHandler.start();
         waitUntilReady();
 
         mDoesRilSendMultipleCallRing = SystemProperties.getBoolean(
@@ -143,6 +145,7 @@ public class ImsPhoneTest extends TelephonyTest {
     @After
     public void tearDown() throws Exception {
         mImsPhoneUT = null;
+        mImsPhoneTestHandler.quitSafely();
         super.tearDown();
     }
 
index d65a902..c99bd75 100644 (file)
@@ -48,6 +48,7 @@ public class IccPhoneBookInterfaceManagerTest extends TelephonyTest {
     @Mock
     private AdnRecord mAdnRecord;
     private IccPhoneBookInterfaceManager mIccPhoneBookInterfaceMgr;
+    private IccPhoneBookInterfaceManagerHandler mIccPhoneBookInterfaceManagerHandler;
     private List<AdnRecord> mAdnList = Arrays.asList(mAdnRecord);
 
     private class IccPhoneBookInterfaceManagerHandler extends HandlerThread {
@@ -81,12 +82,14 @@ public class IccPhoneBookInterfaceManagerTest extends TelephonyTest {
             }
         }).when(mAdnRecordCache).requestLoadAllAdnLike(anyInt(), anyInt(), (Message) anyObject());
 
-        new IccPhoneBookInterfaceManagerHandler(TAG).start();
+        mIccPhoneBookInterfaceManagerHandler = new IccPhoneBookInterfaceManagerHandler(TAG);
+        mIccPhoneBookInterfaceManagerHandler.start();
         waitUntilReady();
     }
 
     @After
     public void tearDown() throws Exception {
+        mIccPhoneBookInterfaceManagerHandler.quitSafely();
         super.tearDown();
     }
     @Test
index d3ef013..1a5daeb 100644 (file)
@@ -110,6 +110,7 @@ public class UiccCardApplicationTest extends TelephonyTest {
 
     @After
     public void tearDown() throws Exception {
+        mTestHandlerThread.quitSafely();
         super.tearDown();
     }
 
index c434ac4..0436ff4 100644 (file)
@@ -134,7 +134,7 @@ public class UiccCardTest extends TelephonyTest {
 
     @After
     public void tearDown() throws Exception {
-        mTestHandlerThread = null;
+        mTestHandlerThread.quitSafely();
         super.tearDown();
     }
 
index dd63b12..12c2690 100644 (file)
@@ -37,6 +37,7 @@ import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;
 
 public class UiccControllerTest extends TelephonyTest {
     private UiccController mUiccControllerUT;
+    private UiccControllerHandlerThread mUiccControllerHandlerThread;
     private static final int PHONE_COUNT = 1;
     private static int ICC_CHANGED_EVENT = 0;
     @Mock
@@ -85,7 +86,8 @@ public class UiccControllerTest extends TelephonyTest {
                 mIccCardStatus.mImsSubscriptionAppIndex =
                         mIccCardStatus.mGsmUmtsSubscriptionAppIndex = -1;
         mSimulatedCommands.setIccCardStatus(mIccCardStatus);
-        new UiccControllerHandlerThread(TAG).start();
+        mUiccControllerHandlerThread = new UiccControllerHandlerThread(TAG);
+        mUiccControllerHandlerThread.start();
         waitUntilReady();
         /* expected to get new UiccCards being created
         wait till the async result and message delay */
@@ -94,6 +96,7 @@ public class UiccControllerTest extends TelephonyTest {
 
     @After
     public void tearDown() throws Exception {
+        mUiccControllerHandlerThread.quitSafely();
         super.tearDown();
     }