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

Commit 351e9670 authored by Malcolm Chen's avatar Malcolm Chen
Browse files

Replace getPhoneCount with getMaxPhoneCount upon object allocation.

As first step for smooth single SIM to DSDS switch, for DSDS capable
deviced we always allocate objects as if it's in DSDS mode. For example
there will be two Phone objects.
Later we'll evaluate to make the allocations dynamic to save memory.

Bug: 141388730
Test: unittest and manual
Change-Id: I9a99853a22de0a4a78fd4ca622faddcdba3f8e06
parent 9f3b9ba9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public class CarrierServiceBindHelper {
    public CarrierServiceBindHelper(Context context) {
        mContext = context;

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

+1 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ public class MultiSimSettingController extends Handler {

        // Initialize mCarrierConfigLoadedSubIds and register to listen to carrier config change.
        final int phoneCount = ((TelephonyManager) mContext.getSystemService(
                Context.TELEPHONY_SERVICE)).getPhoneCount();
                Context.TELEPHONY_SERVICE)).getMaxPhoneCount();
        mCarrierConfigLoadedSubIds = new int[phoneCount];
        Arrays.fill(mCarrierConfigLoadedSubIds, SubscriptionManager.INVALID_SUBSCRIPTION_ID);

+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ public class PhoneFactory {
                /* In case of multi SIM mode two instances of Phone, RIL are created,
                   where as in single SIM mode only instance. isMultiSimEnabled() function checks
                   whether it is single SIM or multi SIM mode */
                int numPhones = TelephonyManager.getDefault().getPhoneCount();
                int numPhones = TelephonyManager.getDefault().getMaxPhoneCount();

                int[] networkModes = new int[numPhones];
                sPhones = new Phone[numPhones];
+3 −3
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public class ProxyController {
    public void registerForAllDataDisconnected(int subId, Handler h, int what) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount()) {
        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getMaxPhoneCount()) {
            mPhones[phoneId].registerForAllDataDisconnected(h, what);
        }
    }
@@ -168,7 +168,7 @@ public class ProxyController {
    public void unregisterForAllDataDisconnected(int subId, Handler h) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount()) {
        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getMaxPhoneCount()) {
            mPhones[phoneId].unregisterForAllDataDisconnected(h);
        }
    }
@@ -177,7 +177,7 @@ public class ProxyController {
    public boolean areAllDataDisconnected(int subId) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount()) {
        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getMaxPhoneCount()) {
            return mPhones[phoneId].areAllDataDisconnected();
        } else {
            // if we can't find a phone for the given subId, it is disconnected.
+3 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyHistogram;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager.PrefNetworkMode;
@@ -413,6 +414,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
    /** Returns a {@link IRadio} instance or null if the service is not available. */
    @VisibleForTesting
    public synchronized IRadio getRadioProxy(Message result) {
        if (!SubscriptionManager.isActivePhoneId(mPhoneId)) return null;
        if (!mIsMobileNetworkSupported) {
            if (RILJ_LOGV) riljLog("getRadioProxy: Not calling getService(): wifi-only");
            if (result != null) {
@@ -506,6 +508,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
    /** Returns an {@link IOemHook} instance or null if the service is not available. */
    @VisibleForTesting
    public synchronized IOemHook getOemHookProxy(Message result) {
        if (!SubscriptionManager.isActivePhoneId(mPhoneId)) return null;
        if (!mIsMobileNetworkSupported) {
            if (RILJ_LOGV) riljLog("getOemHookProxy: Not calling getService(): wifi-only");
            if (result != null) {
Loading