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

Commit 9957dc9b authored by Brad Ebinger's avatar Brad Ebinger Committed by Automerger Merge Worker
Browse files

Merge "Fix leak due to PhoneConfigurationManager" into rvc-dev am: 39fef385 am: 9be46fe9

Change-Id: I04a6b2695fdada9c9e09709b46ba03b9b995c9be
parents ec85d5b2 9be46fe9
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -397,6 +397,13 @@ public class PhoneConfigurationManager {
        sMultiSimConfigChangeRegistrants.remove(h);
        sMultiSimConfigChangeRegistrants.remove(h);
    }
    }


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

    private void broadcastMultiSimConfigChange(int numOfActiveModems) {
    private void broadcastMultiSimConfigChange(int numOfActiveModems) {
        log("broadcastSimSlotNumChange numOfActiveModems" + numOfActiveModems);
        log("broadcastSimSlotNumChange numOfActiveModems" + numOfActiveModems);
        // Notify internal registrants first.
        // Notify internal registrants first.
+9 −0
Original line number Original line Diff line number Diff line
@@ -606,6 +606,15 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal
        bindCarrierServicesIfAvailable();
        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
    // Only start the bind if there is an existing Carrier Configuration. Otherwise, wait for
    // carrier config changed.
    // carrier config changed.
    private void bindCarrierServicesIfAvailable() {
    private void bindCarrierServicesIfAvailable() {
+9 −5
Original line number Original line Diff line number Diff line
@@ -23,15 +23,19 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.ArrayMap;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.ArraySet;


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

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoAnnotations;
@@ -39,7 +43,8 @@ import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
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 String CARRIER_APP = "com.example.carrier";
    private static final ArraySet<String> CARRIER_APPS = new ArraySet<>();
    private static final ArraySet<String> CARRIER_APPS = new ArraySet<>();
    static {
    static {
@@ -62,11 +67,10 @@ public class CarrierAppUtilsTest extends InstrumentationTestCase {
    private SettingsMockContentProvider mContentProvider;
    private SettingsMockContentProvider mContentProvider;
    private MockContentResolver mContentResolver;
    private MockContentResolver mContentResolver;


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


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


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