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

Commit 89935130 authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by android-build-merger
Browse files

Merge changes I1390eccd,I9fa5077d

am: 57ef0b3e

Change-Id: I0f7599c771def3da333c9e76f9b9ce6e96443fd7
parents 6138a64a 57ef0b3e
Loading
Loading
Loading
Loading
+52 −20
Original line number Original line Diff line number Diff line
@@ -37,7 +37,9 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;
import android.util.SparseArray;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.content.PackageMonitor;
import com.android.internal.content.PackageMonitor;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
@@ -59,8 +61,10 @@ public class CarrierServiceBindHelper {


    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private Context mContext;
    private Context mContext;
    private AppBinding[] mBindings;
    @VisibleForTesting
    private String[] mLastSimState;
    public SparseArray<AppBinding> mBindings = new SparseArray();
    @VisibleForTesting
    public SparseArray<String> mLastSimState = new SparseArray<>();
    private final PackageMonitor mPackageMonitor = new CarrierServicePackageMonitor();
    private final PackageMonitor mPackageMonitor = new CarrierServicePackageMonitor();


    private BroadcastReceiver mUserUnlockedReceiver = new BroadcastReceiver() {
    private BroadcastReceiver mUserUnlockedReceiver = new BroadcastReceiver() {
@@ -72,8 +76,8 @@ public class CarrierServiceBindHelper {
            if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
            if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
                // On user unlock, new components might become available, so reevaluate all
                // On user unlock, new components might become available, so reevaluate all
                // bindings.
                // bindings.
                for (int phoneId = 0; phoneId < mBindings.length; phoneId++) {
                for (int phoneId = 0; phoneId < mBindings.size(); phoneId++) {
                    mBindings[phoneId].rebind();
                    mBindings.get(phoneId).rebind();
                }
                }
            }
            }
        }
        }
@@ -81,24 +85,34 @@ public class CarrierServiceBindHelper {


    private static final int EVENT_REBIND = 0;
    private static final int EVENT_REBIND = 0;
    private static final int EVENT_PERFORM_IMMEDIATE_UNBIND = 1;
    private static final int EVENT_PERFORM_IMMEDIATE_UNBIND = 1;
    @VisibleForTesting
    public static final int EVENT_MULTI_SIM_CONFIG_CHANGED = 2;


    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private Handler mHandler = new Handler() {
    private Handler mHandler = new Handler() {
        @Override
        @Override
        public void handleMessage(Message msg) {
        public void handleMessage(Message msg) {
            int phoneId;
            AppBinding binding;
            AppBinding binding;
            log("mHandler: " + msg.what);
            log("mHandler: " + msg.what);


            switch (msg.what) {
            switch (msg.what) {
                case EVENT_REBIND:
                case EVENT_REBIND:
                    binding = (AppBinding) msg.obj;
                    phoneId = (int) msg.obj;
                    binding = mBindings.get(phoneId);
                    if (binding == null) return;
                    log("Rebinding if necessary for phoneId: " + binding.getPhoneId());
                    log("Rebinding if necessary for phoneId: " + binding.getPhoneId());
                    binding.rebind();
                    binding.rebind();
                    break;
                    break;
                case EVENT_PERFORM_IMMEDIATE_UNBIND:
                case EVENT_PERFORM_IMMEDIATE_UNBIND:
                    binding = (AppBinding) msg.obj;
                    phoneId = (int) msg.obj;
                    binding = mBindings.get(phoneId);
                    if (binding == null) return;
                    binding.performImmediateUnbind();
                    binding.performImmediateUnbind();
                    break;
                    break;
                case EVENT_MULTI_SIM_CONFIG_CHANGED:
                    updateBindingsAndSimStates();
                    break;
            }
            }
        }
        }
    };
    };
@@ -106,13 +120,10 @@ public class CarrierServiceBindHelper {
    public CarrierServiceBindHelper(Context context) {
    public CarrierServiceBindHelper(Context context) {
        mContext = context;
        mContext = context;


        int numPhones = TelephonyManager.from(context).getSupportedModemCount();
        updateBindingsAndSimStates();
        mBindings = new AppBinding[numPhones];
        mLastSimState = new String[numPhones];


        for (int phoneId = 0; phoneId < numPhones; phoneId++) {
        PhoneConfigurationManager.getInstance().registerForMultiSimConfigChange(
            mBindings[phoneId] = new AppBinding(phoneId);
                mHandler, EVENT_MULTI_SIM_CONFIG_CHANGED, null);
        }


        mPackageMonitor.register(
        mPackageMonitor.register(
                context, mHandler.getLooper(), UserHandle.ALL, false /* externalStorage */);
                context, mHandler.getLooper(), UserHandle.ALL, false /* externalStorage */);
@@ -121,19 +132,39 @@ public class CarrierServiceBindHelper {
                mHandler);
                mHandler);
    }
    }


    // Create or dispose mBindings and mLastSimState objects.
    private void updateBindingsAndSimStates() {
        int prevLen = mBindings.size();
        int newLen = ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE))
                .getActiveModemCount();

        // If prevLen < newLen, allocate AppBinding and simState objects.
        for (int phoneId = prevLen; phoneId < newLen; phoneId++) {
            mBindings.put(phoneId, new AppBinding(phoneId));
            mLastSimState.put(phoneId, new String());
        }

        // If prevLen > newLen, dispose AppBinding and simState objects.
        for (int phoneId = newLen; phoneId < prevLen; phoneId++) {
            mBindings.get(phoneId).unbind(true);
            mBindings.delete(phoneId);
            mLastSimState.delete(phoneId);
        }
    }

    void updateForPhoneId(int phoneId, String simState) {
    void updateForPhoneId(int phoneId, String simState) {
        log("update binding for phoneId: " + phoneId + " simState: " + simState);
        log("update binding for phoneId: " + phoneId + " simState: " + simState);
        if (!SubscriptionManager.isValidPhoneId(phoneId)) {
        if (!SubscriptionManager.isValidPhoneId(phoneId)) {
            return;
            return;
        }
        }
        if (TextUtils.isEmpty(simState) || phoneId >= mLastSimState.length) return;
        if (TextUtils.isEmpty(simState) || phoneId >= mLastSimState.size()) return;
        if (simState.equals(mLastSimState[phoneId])) {
        if (simState.equals(mLastSimState.get(phoneId))) {
            // ignore consecutive duplicated events
            // ignore consecutive duplicated events
            return;
            return;
        } else {
        } else {
            mLastSimState[phoneId] = simState;
            mLastSimState.put(phoneId, simState);
        }
        }
        mHandler.sendMessage(mHandler.obtainMessage(EVENT_REBIND, mBindings[phoneId]));
        mHandler.sendMessage(mHandler.obtainMessage(EVENT_REBIND, phoneId));
    }
    }


    private class AppBinding {
    private class AppBinding {
@@ -274,7 +305,7 @@ public class CarrierServiceBindHelper {
                mUnbindScheduledUptimeMillis = currentUptimeMillis + UNBIND_DELAY_MILLIS;
                mUnbindScheduledUptimeMillis = currentUptimeMillis + UNBIND_DELAY_MILLIS;
                log("Scheduling unbind in " + UNBIND_DELAY_MILLIS + " millis");
                log("Scheduling unbind in " + UNBIND_DELAY_MILLIS + " millis");
                mHandler.sendMessageAtTime(
                mHandler.sendMessageAtTime(
                        mHandler.obtainMessage(EVENT_PERFORM_IMMEDIATE_UNBIND, this),
                        mHandler.obtainMessage(EVENT_PERFORM_IMMEDIATE_UNBIND, phoneId),
                        mUnbindScheduledUptimeMillis);
                        mUnbindScheduledUptimeMillis);
            }
            }
        }
        }
@@ -365,7 +396,8 @@ public class CarrierServiceBindHelper {
        }
        }


        private void evaluateBinding(String carrierPackageName, boolean forceUnbind) {
        private void evaluateBinding(String carrierPackageName, boolean forceUnbind) {
            for (AppBinding appBinding : mBindings) {
            for (int i = 0; i < mBindings.size(); i++) {
                AppBinding appBinding = mBindings.get(i);
                String appBindingPackage = appBinding.getPackage();
                String appBindingPackage = appBinding.getPackage();
                boolean isBindingForPackage = carrierPackageName.equals(appBindingPackage);
                boolean isBindingForPackage = carrierPackageName.equals(appBindingPackage);
                // Only log if this package was a carrier package to avoid log spam in the common
                // Only log if this package was a carrier package to avoid log spam in the common
@@ -391,8 +423,8 @@ public class CarrierServiceBindHelper {


    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("CarrierServiceBindHelper:");
        pw.println("CarrierServiceBindHelper:");
        for (AppBinding binding : mBindings) {
        for (int i = 0; i < mBindings.size(); i++) {
            binding.dump(fd, pw, args);
            mBindings.get(i).dump(fd, pw, args);
        }
        }
    }
    }
}
}
+95 −40
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.AsyncResult;
import android.os.Handler;
import android.os.Handler;
import android.os.Message;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager;
import android.os.RegistrantList;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.storage.StorageManager;
import android.os.storage.StorageManager;
import android.telephony.PhoneCapability;
import android.telephony.PhoneCapability;
@@ -32,6 +33,8 @@ import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.Log;


import com.android.internal.annotations.VisibleForTesting;

import java.util.HashMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.NoSuchElementException;
@@ -57,9 +60,12 @@ public class PhoneConfigurationManager {
    private final Context mContext;
    private final Context mContext;
    private PhoneCapability mStaticCapability;
    private PhoneCapability mStaticCapability;
    private final RadioConfig mRadioConfig;
    private final RadioConfig mRadioConfig;
    private final MainThreadHandler mHandler;
    private final Handler mHandler;
    private final Phone[] mPhones;
    private final Phone[] mPhones;
    private final Map<Integer, Boolean> mPhoneStatusMap;
    private final Map<Integer, Boolean> mPhoneStatusMap;
    private MockableInterface mMi = new MockableInterface();
    private TelephonyManager mTelephonyManager;
    private static final RegistrantList sMultiSimConfigChangeRegistrants = new RegistrantList();


    /**
    /**
     * Init method to instantiate the object
     * Init method to instantiate the object
@@ -83,11 +89,11 @@ public class PhoneConfigurationManager {
    private PhoneConfigurationManager(Context context) {
    private PhoneConfigurationManager(Context context) {
        mContext = context;
        mContext = context;
        // TODO: send commands to modem once interface is ready.
        // TODO: send commands to modem once interface is ready.
        TelephonyManager telephonyManager = new TelephonyManager(context);
        mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        //initialize with default, it'll get updated when RADIO is ON/AVAILABLE
        //initialize with default, it'll get updated when RADIO is ON/AVAILABLE
        mStaticCapability = getDefaultCapability();
        mStaticCapability = getDefaultCapability();
        mRadioConfig = RadioConfig.getInstance(mContext);
        mRadioConfig = RadioConfig.getInstance(mContext);
        mHandler = new MainThreadHandler();
        mHandler = new ConfigManagerHandler();
        mPhoneStatusMap = new HashMap<>();
        mPhoneStatusMap = new HashMap<>();


        notifyCapabilityChanged();
        notifyCapabilityChanged();
@@ -139,7 +145,7 @@ public class PhoneConfigurationManager {
    /**
    /**
     * Handler class to handle callbacks
     * Handler class to handle callbacks
     */
     */
    private final class MainThreadHandler extends Handler {
    private final class ConfigManagerHandler extends Handler {
        @Override
        @Override
        public void handleMessage(Message msg) {
        public void handleMessage(Message msg) {
            AsyncResult ar;
            AsyncResult ar;
@@ -163,7 +169,7 @@ public class PhoneConfigurationManager {
                    ar = (AsyncResult) msg.obj;
                    ar = (AsyncResult) msg.obj;
                    if (ar != null && ar.exception == null) {
                    if (ar != null && ar.exception == null) {
                        int numOfLiveModems = msg.arg1;
                        int numOfLiveModems = msg.arg1;
                        setMultiSimProperties(numOfLiveModems);
                        onMultiSimConfigChanged(numOfLiveModems);
                    } else {
                    } else {
                        log(msg.what + " failure. Not switching multi-sim config." + ar.exception);
                        log(msg.what + " failure. Not switching multi-sim config." + ar.exception);
                    }
                    }
@@ -287,8 +293,7 @@ public class PhoneConfigurationManager {
     * Returns how many phone objects the device supports.
     * Returns how many phone objects the device supports.
     */
     */
    public int getPhoneCount() {
    public int getPhoneCount() {
        TelephonyManager tm = new TelephonyManager(mContext);
        return mTelephonyManager.getActiveModemCount();
        return tm.getPhoneCount();
    }
    }


    /**
    /**
@@ -301,6 +306,7 @@ public class PhoneConfigurationManager {
                    mHandler, EVENT_GET_PHONE_CAPABILITY_DONE);
                    mHandler, EVENT_GET_PHONE_CAPABILITY_DONE);
            mRadioConfig.getPhoneCapability(callback);
            mRadioConfig.getPhoneCapability(callback);
        }
        }
        log("getStaticPhoneCapability: mStaticCapability " + mStaticCapability);
        return mStaticCapability;
        return mStaticCapability;
    }
    }


@@ -348,41 +354,19 @@ public class PhoneConfigurationManager {
     * Return value defaults to true
     * Return value defaults to true
     */
     */
    public boolean isRebootRequiredForModemConfigChange() {
    public boolean isRebootRequiredForModemConfigChange() {
        String rebootRequired = SystemProperties.get(
        return mMi.isRebootRequiredForModemConfigChange();
                TelephonyProperties.PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE);
        log("isRebootRequiredForModemConfigChange: isRebootRequired = " + rebootRequired);
        return !rebootRequired.equals("false");
    }
    }


    /**
    private void onMultiSimConfigChanged(int numOfActiveModems) {
     * Helper method to set system properties for setting multi sim configs,
        setMultiSimProperties(numOfActiveModems);
     * as well as doing the phone reboot
     * NOTE: In order to support more than 3 sims, we need to change this method.
     * @param numOfSims number of active sims
     */
    private void setMultiSimProperties(int numOfSims) {
        String finalMultiSimConfig;
        switch(numOfSims) {
            case 3:
                finalMultiSimConfig = TSTS;
                break;
            case 2:
                finalMultiSimConfig = DSDS;
                break;
            default:
                finalMultiSimConfig = SSSS;
        }


        SystemProperties.set(TelephonyProperties.PROPERTY_MULTI_SIM_CONFIG, finalMultiSimConfig);
        if (isRebootRequiredForModemConfigChange()) {
        if (isRebootRequiredForModemConfigChange()) {
            log("setMultiSimProperties: Rebooting due to switching multi-sim config to "
            log("onMultiSimConfigChanged: Rebooting.");
                    + finalMultiSimConfig);
            PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
            PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
            pm.reboot("Switching to " + finalMultiSimConfig);
            pm.reboot("Multi-SIM config changed.");
        } else {
        } else {
            log("setMultiSimProperties: Rebooting is not required to switch multi-sim config to "
            log("onMultiSimConfigChanged: Rebooting is not required.");
                    + finalMultiSimConfig);
            broadcastMultiSimConfigChange(numOfActiveModems);
            broadcastSimSlotNumChange(numOfSims);
            // Register to RIL service if needed.
            // Register to RIL service if needed.
            for (int i = 0; i < mPhones.length; i++) {
            for (int i = 0; i < mPhones.length; i++) {
                Phone phone = mPhones[i];
                Phone phone = mPhones[i];
@@ -391,13 +375,84 @@ public class PhoneConfigurationManager {
        }
        }
    }
    }


    private void broadcastSimSlotNumChange(int numOfSims) {
    /**
        log("broadcastSimSlotNumChange numOfSims" + numOfSims);
     * Helper method to set system properties for setting multi sim configs,
     * as well as doing the phone reboot
     * NOTE: In order to support more than 3 sims, we need to change this method.
     * @param numOfActiveModems number of active sims
     */
    private void setMultiSimProperties(int numOfActiveModems) {
        mMi.setMultiSimProperties(numOfActiveModems);
    }

    @VisibleForTesting
    public static void notifyMultiSimConfigChange(int numOfActiveModems) {
        sMultiSimConfigChangeRegistrants.notifyResult(numOfActiveModems);
    }

    /**
     * Register for multi-SIM configuration change, for example if the devices switched from single
     * SIM to dual-SIM mode.
     *
     * It doesn't trigger callback upon registration as multi-SIM config change is in-frequent.
     */
    public static void registerForMultiSimConfigChange(Handler h, int what, Object obj) {
        sMultiSimConfigChangeRegistrants.addUnique(h, what, obj);
    }

    /**
     * Unregister for multi-SIM configuration change.
     */
    public static void unregisterForMultiSimConfigChange(Handler h) {
        sMultiSimConfigChangeRegistrants.remove(h);
    }

    private void broadcastMultiSimConfigChange(int numOfActiveModems) {
        log("broadcastSimSlotNumChange numOfActiveModems" + numOfActiveModems);
        // Notify internal registrants first.
        notifyMultiSimConfigChange(numOfActiveModems);

        Intent intent = new Intent(ACTION_MULTI_SIM_CONFIG_CHANGED);
        Intent intent = new Intent(ACTION_MULTI_SIM_CONFIG_CHANGED);
        intent.putExtra(EXTRA_NUM_OF_ACTIVE_SIM_SUPPORTED, numOfSims);
        intent.putExtra(EXTRA_NUM_OF_ACTIVE_SIM_SUPPORTED, numOfActiveModems);
        mContext.sendBroadcast(intent);
        mContext.sendBroadcast(intent);
    }
    }


    /**
     * A wrapper class that wraps some methods so that they can be replaced or mocked in unit-tests.
     *
     * For example, setting or reading system property are static native methods that can't be
     * directly mocked. We can mock it by replacing MockableInterface object with a mock instance
     * in unittest.
     */
    @VisibleForTesting
    public static class MockableInterface {
        @VisibleForTesting
        public boolean isRebootRequiredForModemConfigChange() {
            String rebootRequired = SystemProperties.get(
                    TelephonyProperties.PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE);
            log("isRebootRequiredForModemConfigChange: isRebootRequired = " + rebootRequired);
            return !rebootRequired.equals("false");
        }

        @VisibleForTesting
        public void setMultiSimProperties(int numOfActiveModems) {
            String multiSimConfig;
            switch(numOfActiveModems) {
                case 3:
                    multiSimConfig = TSTS;
                    break;
                case 2:
                    multiSimConfig = DSDS;
                    break;
                default:
                    multiSimConfig = SSSS;
            }

            log("setMultiSimProperties to " + multiSimConfig);
            SystemProperties.set(TelephonyProperties.PROPERTY_MULTI_SIM_CONFIG, multiSimConfig);
        }
    }

    private static void log(String s) {
    private static void log(String s) {
        Rlog.d(LOG_TAG, s);
        Rlog.d(LOG_TAG, s);
    }
    }
+84 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import static android.telephony.TelephonyManager.MODEM_COUNT_DUAL_MODEM;
import static android.telephony.TelephonyManager.MODEM_COUNT_SINGLE_MODEM;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doReturn;

import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class CarrierServiceBindHelperTest extends TelephonyTest {
    CarrierServiceBindHelper mCarrierServiceBindHelper;
    @Before
    public void setUp() throws Exception {
        super.setUp(getClass().getSimpleName());
        doReturn(MODEM_COUNT_SINGLE_MODEM).when(mTelephonyManager).getActiveModemCount();
    }

    @After
    public void tearDown() throws Exception {
        // Restore system properties.
        super.tearDown();
    }

    @Test
    @SmallTest
    public void testMultiSimConfigChanged() throws Exception {
        clearInvocations(mPhoneConfigurationManager);
        mCarrierServiceBindHelper = new CarrierServiceBindHelper(mContext);
        assertEquals(MODEM_COUNT_SINGLE_MODEM, mCarrierServiceBindHelper.mBindings.size());
        assertEquals(MODEM_COUNT_SINGLE_MODEM, mCarrierServiceBindHelper.mLastSimState.size());
        assertNotNull(mCarrierServiceBindHelper.mBindings.get(0));
        assertNotNull(mCarrierServiceBindHelper.mLastSimState.get(0));

        // Verify registration of EVENT_MULTI_SIM_CONFIG_CHANGED.
        doReturn(MODEM_COUNT_DUAL_MODEM).when(mTelephonyManager).getActiveModemCount();
        PhoneConfigurationManager.notifyMultiSimConfigChange(MODEM_COUNT_DUAL_MODEM);
        processAllMessages();

        assertEquals(MODEM_COUNT_DUAL_MODEM, mCarrierServiceBindHelper.mBindings.size());
        assertEquals(MODEM_COUNT_DUAL_MODEM, mCarrierServiceBindHelper.mLastSimState.size());
        assertNotNull(mCarrierServiceBindHelper.mBindings.get(0));
        assertNotNull(mCarrierServiceBindHelper.mBindings.get(1));
        assertNotNull(mCarrierServiceBindHelper.mLastSimState.get(0));
        assertNotNull(mCarrierServiceBindHelper.mLastSimState.get(1));

        // Switch back to single SIM.
        doReturn(MODEM_COUNT_SINGLE_MODEM).when(mTelephonyManager).getActiveModemCount();
        PhoneConfigurationManager.notifyMultiSimConfigChange(MODEM_COUNT_SINGLE_MODEM);
        processAllMessages();

        assertEquals(MODEM_COUNT_SINGLE_MODEM, mCarrierServiceBindHelper.mBindings.size());
        assertEquals(MODEM_COUNT_SINGLE_MODEM, mCarrierServiceBindHelper.mLastSimState.size());
        assertNotNull(mCarrierServiceBindHelper.mBindings.get(0));
        assertNotNull(mCarrierServiceBindHelper.mLastSimState.get(0));
    }
}
+189 −0

File added.

Preview size limit exceeded, changes collapsed.

+3 −1
Original line number Original line Diff line number Diff line
@@ -563,8 +563,10 @@ public abstract class TelephonyTest {
        //SIM
        //SIM
        doReturn(1).when(mTelephonyManager).getSimCount();
        doReturn(1).when(mTelephonyManager).getSimCount();
        doReturn(1).when(mTelephonyManager).getPhoneCount();
        doReturn(1).when(mTelephonyManager).getPhoneCount();
        doReturn(1).when(mTelephonyManager).getActiveModemCount();
        // Have getMaxPhoneCount always return the same value with getPhoneCount by default.
        // Have getMaxPhoneCount always return the same value with getPhoneCount by default.
        doAnswer((invocation)->mTelephonyManager.getPhoneCount())
        doAnswer((invocation)->Math.max(mTelephonyManager.getActiveModemCount(),
                mTelephonyManager.getPhoneCount()))
                .when(mTelephonyManager).getSupportedModemCount();
                .when(mTelephonyManager).getSupportedModemCount();


        //Data
        //Data