diff --git a/tests/src/com/android/TelephonyTestBase.java b/tests/src/com/android/TelephonyTestBase.java
index ffda81b..d72d85e 100644
--- a/tests/src/com/android/TelephonyTestBase.java
+++ b/tests/src/com/android/TelephonyTestBase.java
@@ -24,10 +24,16 @@
 
 import com.android.internal.telephony.PhoneConfigurationManager;
 
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Rule;
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
@@ -40,6 +46,10 @@
 
     protected TestContext mContext;
 
+    private final HashMap<InstanceKey, Object> mOldInstances = new HashMap<>();
+    private final LinkedList<InstanceKey> mInstanceKeys = new LinkedList<>();
+
+    @Before
     public void setUp() throws Exception {
         mContext = spy(new TestContext());
         // Set up the looper if it does not exist on the test thread.
@@ -56,9 +66,11 @@
         }
     }
 
+    @After
     public void tearDown() throws Exception {
         // Ensure there are no static references to handlers after test completes.
         PhoneConfigurationManager.unregisterAllMultiSimConfigChangeRegistrants();
+        restoreInstances();
     }
 
     protected final boolean waitForExecutorAction(Executor executor, long timeoutMillis) {
@@ -108,6 +120,61 @@
         }
     }
 
+    protected synchronized void replaceInstance(final Class c, final String instanceName,
+            final Object obj, final Object newValue)
+            throws Exception {
+        Field field = c.getDeclaredField(instanceName);
+        field.setAccessible(true);
+
+        InstanceKey key = new InstanceKey(c, instanceName, obj);
+        if (!mOldInstances.containsKey(key)) {
+            mOldInstances.put(key, field.get(obj));
+            mInstanceKeys.add(key);
+        }
+        field.set(obj, newValue);
+    }
+
+    private synchronized void restoreInstances() throws Exception {
+        Iterator<InstanceKey> it = mInstanceKeys.descendingIterator();
+
+        while (it.hasNext()) {
+            InstanceKey key = it.next();
+            Field field = key.mClass.getDeclaredField(key.mInstName);
+            field.setAccessible(true);
+            field.set(key.mObj, mOldInstances.get(key));
+        }
+
+        mInstanceKeys.clear();
+        mOldInstances.clear();
+    }
+
+    private static class InstanceKey {
+        public final Class mClass;
+        public final String mInstName;
+        public final Object mObj;
+        InstanceKey(final Class c, final String instName, final Object obj) {
+            mClass = c;
+            mInstName = instName;
+            mObj = obj;
+        }
+
+        @Override
+        public int hashCode() {
+            return (mClass.getName().hashCode() * 31 + mInstName.hashCode()) * 31;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj == null || obj.getClass() != getClass()) {
+                return false;
+            }
+
+            InstanceKey other = (InstanceKey) obj;
+            return (other.mClass == mClass && other.mInstName.equals(mInstName)
+                    && other.mObj == mObj);
+        }
+    }
+
     protected TestContext getTestContext() {
         return mContext;
     }
diff --git a/tests/src/com/android/phone/ImsStateCallbackControllerTest.java b/tests/src/com/android/phone/ImsStateCallbackControllerTest.java
index 60374bc..2bd87be 100644
--- a/tests/src/com/android/phone/ImsStateCallbackControllerTest.java
+++ b/tests/src/com/android/phone/ImsStateCallbackControllerTest.java
@@ -52,6 +52,7 @@
 import android.testing.TestableLooper;
 import android.util.Log;
 
+import com.android.TelephonyTestBase;
 import com.android.ims.FeatureConnector;
 import com.android.ims.ImsManager;
 import com.android.ims.RcsFeatureManager;
@@ -70,13 +71,12 @@
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
-import java.lang.reflect.Field;
 import java.util.concurrent.Executor;
 
 /**
  * Unit tests for RcsProvisioningMonitor
  */
-public class ImsStateCallbackControllerTest {
+public class ImsStateCallbackControllerTest extends TelephonyTestBase {
     private static final String TAG = "ImsStateCallbackControllerTest";
     private static final int FAKE_SUB_ID_BASE = 0x0FFFFFF0;
 
@@ -189,6 +189,7 @@
             mLooper.destroy();
             mLooper = null;
         }
+        super.tearDown();
     }
 
     @Test
@@ -952,13 +953,6 @@
         }
     }
 
-    private static void replaceInstance(final Class c,
-            final String instanceName, final Object obj, final Object newValue) throws Exception {
-        Field field = c.getDeclaredField(instanceName);
-        field.setAccessible(true);
-        field.set(obj, newValue);
-    }
-
     private void makeFakeActiveSubIds(int count) {
         final int[] subIds = new int[count];
         for (int i = 0; i < count; i++) {
diff --git a/tests/src/com/android/phone/NotificationMgrTest.java b/tests/src/com/android/phone/NotificationMgrTest.java
index a6ee276..bd5ca1d 100644
--- a/tests/src/com/android/phone/NotificationMgrTest.java
+++ b/tests/src/com/android/phone/NotificationMgrTest.java
@@ -69,9 +69,12 @@
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 
+import com.android.TelephonyTestBase;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.PhoneFactory;
+import com.android.internal.telephony.data.DataNetworkController;
+import com.android.internal.telephony.data.DataSettingsManager;
 import com.android.internal.telephony.util.NotificationChannelController;
 
 import org.junit.Before;
@@ -81,15 +84,14 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
-import java.lang.reflect.Field;
+import java.util.Collections;
 
 /**
  * Unit Test for NotificationMgr
  */
 @RunWith(AndroidTestingRunner.class)
 @TestableLooper.RunWithLooper
-public class NotificationMgrTest {
-
+public class NotificationMgrTest extends TelephonyTestBase {
     private static final int TEST_SUB_ID = 1;
     private static final long SERIAL_NUMBER_OF_USER = 1234567L;
     private static final String TEST_LABEL_CF = "test_call_forwarding";
@@ -111,8 +113,11 @@
     @Mock NotificationManager mNotificationManager;
     @Mock SubscriptionInfo mSubscriptionInfo;
     @Mock Resources mResources;
+    @Mock Context mMockedContext;
     @Mock ServiceState mServiceState;
     @Mock CarrierConfigManager mCarrierConfigManager;
+    @Mock DataNetworkController mDataNetworkController;
+    @Mock DataSettingsManager mDataSettingsManager;
 
     private Phone[] mPhones;
     private NotificationMgr mNotificationMgr;
@@ -123,6 +128,14 @@
         mPhones = new Phone[]{mPhone};
         replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
         when(mPhone.getPhoneType()).thenReturn(PhoneConstants.PHONE_TYPE_GSM);
+        when(mPhone.getContext()).thenReturn(mMockedContext);
+        when(mMockedContext.getResources()).thenReturn(mResources);
+        when(mPhone.getServiceState()).thenReturn(mServiceState);
+        when(mPhone.getDataNetworkController()).thenReturn(mDataNetworkController);
+        when(mDataNetworkController.getInternetDataDisallowedReasons()).thenReturn(
+                Collections.emptyList());
+        when(mPhone.getDataSettingsManager()).thenReturn(mDataSettingsManager);
+        when(mDataSettingsManager.isDataEnabledForReason(anyInt())).thenReturn(true);
         when(mApp.getSharedPreferences(anyString(), anyInt())).thenReturn(mSharedPreferences);
 
         when(mApp.getPackageName()).thenReturn(TEST_PACKAGE_NAME);
@@ -157,8 +170,7 @@
     }
 
     @Test
-    public void testUpdateCfi_visible_noActiveSubscription_notificationNeverSent()
-            throws Exception {
+    public void testUpdateCfi_visible_noActiveSubscription_notificationNeverSent() {
         // Given no active subscription available
         when(mSubscriptionManager.getActiveSubscriptionInfo(eq(TEST_SUB_ID))).thenReturn(null);
 
@@ -170,7 +182,7 @@
     }
 
     @Test
-    public void testUpdateCfi_visible_hasActiveSub_singleSIM_notificationSent() throws Exception {
+    public void testUpdateCfi_visible_hasActiveSub_singleSIM_notificationSent() {
         when(mTelephonyManager.getPhoneCount()).thenReturn(1);
         when(mSubscriptionManager.getActiveSubscriptionInfo(eq(TEST_SUB_ID))).thenReturn(
                 mSubscriptionInfo);
@@ -181,8 +193,7 @@
     }
 
     @Test
-    public void testUpdateCfi_visible_hasActiveSub_multiSIM_notificationSentWithoutDisplayName()
-            throws Exception {
+    public void testUpdateCfi_visible_hasActiveSub_multiSIM_notificationSentWithoutDisplayName() {
         when(mTelephonyManager.getPhoneCount()).thenReturn(2);
         when(mSubscriptionManager.getActiveSubscriptionInfo(eq(TEST_SUB_ID))).thenReturn(
                 mSubscriptionInfo);
@@ -194,8 +205,7 @@
     }
 
     @Test
-    public void testUpdateCfi_visible_hasActiveSub_multiSIM_notificationSentWithDisplayName()
-            throws Exception {
+    public void testUpdateCfi_visible_hasActiveSub_multiSIM_notificationSentWithDisplayName() {
         when(mTelephonyManager.getPhoneCount()).thenReturn(2);
         when(mSubscriptionManager.getActiveSubscriptionInfo(eq(TEST_SUB_ID))).thenReturn(
                 mSubscriptionInfo);
@@ -207,8 +217,7 @@
     }
 
     @Test
-    public void testUpdateCfi_invisible_hasUnmanagedProfile_notificationCanceled()
-            throws Exception {
+    public void testUpdateCfi_invisible_hasUnmanagedProfile_notificationCanceled() {
         when(mUserManager.isManagedProfile(anyInt())).thenReturn(false);
 
         mNotificationMgr.updateCfi(TEST_SUB_ID, /*visible=*/false, /*isFresh=*/false);
@@ -217,8 +226,7 @@
     }
 
     @Test
-    public void testUpdateCfi_invisible_allProfilesAreManaged_notificationNeverCanceled()
-            throws Exception {
+    public void testUpdateCfi_invisible_allProfilesAreManaged_notificationNeverCanceled() {
         when(mUserManager.isManagedProfile(anyInt())).thenReturn(true);
 
         mNotificationMgr.updateCfi(TEST_SUB_ID, /*visible=*/false, /*isFresh=*/false);
@@ -227,7 +235,7 @@
     }
 
     @Test
-    public void testShowDataRoamingNotification_roamingOn() throws Exception {
+    public void testShowDataRoamingNotification_roamingOn() {
         mNotificationMgr.showDataRoamingNotification(TEST_SUB_ID, /*roamingOn=*/true);
 
         verifyNotificationSentWithChannelId(
@@ -235,7 +243,7 @@
     }
 
     @Test
-    public void testShowDataRoamingNotification_roamingOff() throws Exception {
+    public void testShowDataRoamingNotification_roamingOff() {
         mNotificationMgr.showDataRoamingNotification(TEST_SUB_ID, /*roamingOn=*/false);
 
         verifyNotificationSentWithChannelId(
@@ -250,8 +258,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_justOutOfService_notificationNeverSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_justOutOfService_notificationNeverSent() {
         prepareResourcesForNetworkSelection();
 
         mNotificationMgr.updateNetworkSelection(ServiceState.STATE_OUT_OF_SERVICE, TEST_SUB_ID);
@@ -265,8 +272,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_oosEnoughTime_selectionVisibleToUser_notificationSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_oosEnoughTime_selectionVisibleToUser_notificationSent() {
         prepareResourcesForNetworkSelection();
         when(mTelephonyManager.isManualNetworkSelectionAllowed()).thenReturn(true);
         PersistableBundle config = new PersistableBundle();
@@ -288,8 +294,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_invalidSubscription_notificationNotSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_invalidSubscription_notificationNotSent() {
         prepareResourcesForNetworkSelection();
         when(mTelephonyManager.isManualNetworkSelectionAllowed()).thenReturn(true);
         PersistableBundle config = new PersistableBundle();
@@ -312,8 +317,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_nullCarrierConfig_notificationNotSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_nullCarrierConfig_notificationNotSent() {
         prepareResourcesForNetworkSelection();
 
         when(mCarrierConfigManager.getConfigForSubId(TEST_SUB_ID)).thenReturn(null);
@@ -329,8 +333,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_userNotAllowedToChooseOperator_notificationNotSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_userNotAllowedToChooseOperator_notificationNotSent() {
         prepareResourcesForNetworkSelection();
 
         PersistableBundle config = new PersistableBundle();
@@ -353,8 +356,8 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_OverrideHideCarrierNetworkSelection_notificationNotSent()
-            throws Exception {
+    public void
+            testUpdateNetworkSelection_OverrideHideCarrierNetworkSelection_notificationNotSent() {
         prepareResourcesForNetworkSelection();
 
         PersistableBundle config = new PersistableBundle();
@@ -401,8 +404,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_worldMode_userSetLTE_notificationNotSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_worldMode_userSetLTE_notificationNotSent() {
         prepareResourcesForNetworkSelection();
 
         PersistableBundle config = new PersistableBundle();
@@ -431,8 +433,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_worldMode_userSetTDSCDMA_notSupported_notifNotSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_worldMode_userSetTDSCDMA_notSupported_notifNotSent() {
         prepareResourcesForNetworkSelection();
 
         PersistableBundle config = new PersistableBundle();
@@ -462,8 +463,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_worldMode_userSetWCDMA_notificationSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_worldMode_userSetWCDMA_notificationSent() {
         prepareResourcesForNetworkSelection();
 
         PersistableBundle config = new PersistableBundle();
@@ -494,8 +494,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_worldPhone_networkSelectionNotHide_notificationSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_worldPhone_networkSelectionNotHide_notificationSent() {
         prepareResourcesForNetworkSelection();
 
         PersistableBundle config = new PersistableBundle();
@@ -519,8 +518,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_gsmBasicOptionOn_notificationSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_gsmBasicOptionOn_notificationSent() {
         prepareResourcesForNetworkSelection();
 
         PersistableBundle config = new PersistableBundle();
@@ -545,8 +543,7 @@
     }
 
     @Test
-    public void testUpdateNetworkSelection_gsmBasicOptionOff_notificationNotSent()
-            throws Exception {
+    public void testUpdateNetworkSelection_gsmBasicOptionOff_notificationNotSent() {
         prepareResourcesForNetworkSelection();
 
         PersistableBundle config = new PersistableBundle();
@@ -569,8 +566,7 @@
     }
 
     @Test
-    public void testShowLimitedSimFunctionWarningNotification_forTheFirstTime_notificationSent()
-            throws Exception {
+    public void testShowLimitedSimFunctionWarningNotification_forTheFirstTime_notificationSent() {
         when(mResources.getText(R.string.limited_sim_function_notification_message)).thenReturn(
                 CARRIER_NAME);
         when(mResources.getText(
@@ -584,8 +580,8 @@
     }
 
     @Test
-    public void testShowLimitedSimFunctionWarningNotification_consecutiveCall_notificationSentOnce()
-            throws Exception {
+    public void
+            testShowLimitedSimFunctionWarningNotification_consecutiveCall_notificationSentOnce() {
         when(mResources.getText(R.string.limited_sim_function_notification_message)).thenReturn(
                 CARRIER_NAME);
         when(mResources.getText(
@@ -602,8 +598,7 @@
     }
 
     @Test
-    public void testDismissLimitedSimFunctionWarningNotification_noShowCalledBefore_noCancelSent()
-            throws Exception {
+    public void testDismissLimitedSimFunctionWarningNotification_noShowCalledBefore_noCancelSent() {
         // showLimitedSimFunctionWarningNotification was never called before
 
         mNotificationMgr.dismissLimitedSimFunctionWarningNotification(TEST_SUB_ID);
@@ -612,8 +607,7 @@
     }
 
     @Test
-    public void testDismissLimitedSimFunctionWarningNotification_showCalledBefore_cancelSent()
-            throws Exception {
+    public void testDismissLimitedSimFunctionWarningNotification_showCalledBefore_cancelSent() {
         when(mResources.getText(R.string.limited_sim_function_notification_message)).thenReturn(
                 CARRIER_NAME);
         when(mResources.getText(
@@ -651,11 +645,4 @@
         when(mApp.getString(R.string.mobile_network_settings_class)).thenReturn(
                 MOBILE_NETWORK_SELECTION_CLASS);
     }
-
-    private static void replaceInstance(final Class c,
-            final String instanceName, final Object obj, final Object newValue) throws Exception {
-        Field field = c.getDeclaredField(instanceName);
-        field.setAccessible(true);
-        field.set(obj, newValue);
-    }
 }
diff --git a/tests/src/com/android/phone/PhoneUtilsTest.java b/tests/src/com/android/phone/PhoneUtilsTest.java
index eb4c248..521a0bb 100644
--- a/tests/src/com/android/phone/PhoneUtilsTest.java
+++ b/tests/src/com/android/phone/PhoneUtilsTest.java
@@ -28,23 +28,19 @@
 
 import androidx.test.runner.AndroidJUnit4;
 
+import com.android.TelephonyTestBase;
 import com.android.internal.telephony.GsmCdmaPhone;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneFactory;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-
 @RunWith(AndroidJUnit4.class)
-public class PhoneUtilsTest {
+public class PhoneUtilsTest extends TelephonyTestBase {
     @Mock
     private SubscriptionManager mMockSubscriptionManager;
     @Mock
@@ -59,37 +55,6 @@
     private PhoneAccountHandle mPhoneAccountHandleTest = new PhoneAccountHandle(
             PSTN_CONNECTION_SERVICE_COMPONENT, mPhoneAccountHandleIdString);
 
-    private HashMap<InstanceKey, Object> mOldInstances = new HashMap<InstanceKey, Object>();
-
-    private ArrayList<InstanceKey> mInstanceKeys = new ArrayList<InstanceKey>();
-
-    private static class InstanceKey {
-        public final Class mClass;
-        public final String mInstName;
-        public final Object mObj;
-        InstanceKey(final Class c, final String instName, final Object obj) {
-            mClass = c;
-            mInstName = instName;
-            mObj = obj;
-        }
-
-        @Override
-        public int hashCode() {
-            return (mClass.getName().hashCode() * 31 + mInstName.hashCode()) * 31;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (obj == null || !(obj instanceof InstanceKey)) {
-                return false;
-            }
-
-            InstanceKey other = (InstanceKey) obj;
-            return (other.mClass == mClass && other.mInstName.equals(mInstName)
-                    && other.mObj == mObj);
-        }
-    }
-
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
@@ -100,37 +65,6 @@
         replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
     }
 
-    @After
-    public void tearDown() throws Exception {
-        restoreInstance(PhoneFactory.class, "sPhones", null);
-    }
-
-    protected synchronized void replaceInstance(final Class c, final String instanceName,
-            final Object obj, final Object newValue)
-            throws Exception {
-        Field field = c.getDeclaredField(instanceName);
-        field.setAccessible(true);
-
-        InstanceKey key = new InstanceKey(c, instanceName, obj);
-        if (!mOldInstances.containsKey(key)) {
-            mOldInstances.put(key, field.get(obj));
-            mInstanceKeys.add(key);
-        }
-        field.set(obj, newValue);
-    }
-
-    protected synchronized void restoreInstance(final Class c, final String instanceName,
-            final Object obj) throws Exception {
-        InstanceKey key = new InstanceKey(c, instanceName, obj);
-        if (mOldInstances.containsKey(key)) {
-            Field field = c.getDeclaredField(instanceName);
-            field.setAccessible(true);
-            field.set(obj, mOldInstances.get(key));
-            mOldInstances.remove(key);
-            mInstanceKeys.remove(key);
-        }
-    }
-
     @Test
     public void testIsPhoneAccountActive() throws Exception {
         assertTrue(PhoneUtils.isPhoneAccountActive(
diff --git a/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java b/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
index 28a7b02..969622a 100644
--- a/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
+++ b/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
@@ -38,19 +38,14 @@
 import com.android.internal.telephony.PhoneFactory;
 import com.android.phone.common.R;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Locale;
 
-
 @RunWith(AndroidJUnit4.class)
 public class DisconnectCauseUtilTest extends TelephonyTestBase {
 
@@ -60,42 +55,11 @@
 
     // dynamic
     private Context mContext;
-    private HashMap<InstanceKey, Object> mOldInstances = new HashMap<InstanceKey, Object>();
-    private ArrayList<InstanceKey> mInstanceKeys = new ArrayList<InstanceKey>();
 
     //Mocks
     @Mock
     private GsmCdmaPhone mMockPhone;
 
-    // inner classes
-    private static class InstanceKey {
-        public final Class mClass;
-        public final String mInstName;
-        public final Object mObj;
-
-        InstanceKey(final Class c, final String instName, final Object obj) {
-            mClass = c;
-            mInstName = instName;
-            mObj = obj;
-        }
-
-        @Override
-        public int hashCode() {
-            return (mClass.getName().hashCode() * 31 + mInstName.hashCode()) * 31;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (obj == null || !(obj instanceof InstanceKey)) {
-                return false;
-            }
-
-            InstanceKey other = (InstanceKey) obj;
-            return (other.mClass == mClass && other.mInstName.equals(mInstName)
-                    && other.mObj == mObj);
-        }
-    }
-
     @Before
     public void setUp() throws Exception {
         super.setUp();
@@ -106,15 +70,6 @@
         setSinglePhone();
     }
 
-    @After
-    public void tearDown() throws Exception {
-        // restoreInstance.
-        // Not doing so will potentially "confuse" other tests with the mocked instance
-        restoreInstance(PhoneFactory.class, "sPhones", null);
-        super.tearDown();
-    }
-
-
     /**
      * Verifies that a call drop due to loss of WIFI results in a disconnect cause of error and that
      * the label, description and tone are all present.
@@ -176,33 +131,6 @@
         replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
     }
 
-
-    protected synchronized void replaceInstance(final Class c, final String instanceName,
-            final Object obj, final Object newValue)
-            throws Exception {
-        Field field = c.getDeclaredField(instanceName);
-        field.setAccessible(true);
-
-        InstanceKey key = new InstanceKey(c, instanceName, obj);
-        if (!mOldInstances.containsKey(key)) {
-            mOldInstances.put(key, field.get(obj));
-            mInstanceKeys.add(key);
-        }
-        field.set(obj, newValue);
-    }
-
-    protected synchronized void restoreInstance(final Class c, final String instanceName,
-            final Object obj) throws Exception {
-        InstanceKey key = new InstanceKey(c, instanceName, obj);
-        if (mOldInstances.containsKey(key)) {
-            Field field = c.getDeclaredField(instanceName);
-            field.setAccessible(true);
-            field.set(obj, mOldInstances.get(key));
-            mOldInstances.remove(key);
-            mInstanceKeys.remove(key);
-        }
-    }
-
     private Resources getResourcesForLocale(Context context, Locale locale) {
         Configuration config = new Configuration();
         config.setToDefaults();
