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

Commit 00754008 authored by Brad Ebinger's avatar Brad Ebinger Committed by Gerrit Code Review
Browse files

Merge "Fix leak due to PhoneConfigurationManager"

parents 9365a658 948a208a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -396,6 +396,13 @@ public class PhoneConfigurationManager {
        sMultiSimConfigChangeRegistrants.remove(h);
    }

    /**
     * Unregister for all multi-SIM configuration change events.
     */
    public static void unregisterAllMultiSimConfigChangeRegistrants() {
        sMultiSimConfigChangeRegistrants.removeAll();
    }

    private void broadcastMultiSimConfigChange(int numOfActiveModems) {
        log("broadcastSimSlotNumChange numOfActiveModems" + numOfActiveModems);
        // Notify internal registrants first.
+9 −0
Original line number Diff line number Diff line
@@ -606,6 +606,15 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal
        bindCarrierServicesIfAvailable();
    }

    /**
     * Destroys this ImsResolver. Used for tearing down static resources during testing.
     */
    @VisibleForTesting
    public void destroy() {
        PhoneConfigurationManager.unregisterForMultiSimConfigChange(mHandler);
        mHandler.removeCallbacksAndMessages(null);
    }

    // Only start the bind if there is an existing Carrier Configuration. Otherwise, wait for
    // carrier config changed.
    private void bindCarrierServicesIfAvailable() {
+10 −5
Original line number Diff line number Diff line
@@ -22,14 +22,19 @@ import android.content.pm.PackageManager;
import android.os.Bundle;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.ArrayMap;
import android.util.ArraySet;


import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -37,7 +42,8 @@ import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.List;

public class CarrierAppUtilsTest extends InstrumentationTestCase {
@RunWith(AndroidJUnit4.class)
public class CarrierAppUtilsTest {
    private static final String CARRIER_APP = "com.example.carrier";
    private static final ArraySet<String> CARRIER_APPS = new ArraySet<>();
    static {
@@ -59,11 +65,10 @@ public class CarrierAppUtilsTest extends InstrumentationTestCase {
    private SettingsMockContentProvider mContentProvider;
    private MockContentResolver mContentResolver;

    @Override
    @Before
    public void setUp() throws Exception {
        super.setUp();
        System.setProperty("dexmaker.dexcache",
                getInstrumentation().getTargetContext().getCacheDir().getPath());
                InstrumentationRegistry.getTargetContext().getCacheDir().getPath());
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
        MockitoAnnotations.initMocks(this);

+2 −0
Original line number Diff line number Diff line
@@ -662,6 +662,8 @@ public abstract class TelephonyTest {
    }

    protected void tearDown() throws Exception {
        // Ensure there are no references to handlers between tests.
        PhoneConfigurationManager.unregisterAllMultiSimConfigChangeRegistrants();
        // unmonitor TestableLooper for TelephonyTest class
        if (mTestableLooper != null) {
            unmonitorTestableLooper(mTestableLooper);
+1 −0
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ public class ImsResolverTest extends ImsTestBase {
    @After
    @Override
    public void tearDown() throws Exception {
        mTestImsResolver.destroy();
        mTestImsResolver = null;
        mLooper.destroy();
        mLooper = null;