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

Commit 4668b242 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
Merged-In: I9a99853a22de0a4a78fd4ca622faddcdba3f8e06
parent 536c9535
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -106,7 +106,7 @@ public class CarrierServiceBindHelper {
    public CarrierServiceBindHelper(Context context) {
    public CarrierServiceBindHelper(Context context) {
        mContext = context;
        mContext = context;


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


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


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


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


                int[] networkModes = new int[numPhones];
                int[] networkModes = new int[numPhones];
                sPhones = new Phone[numPhones];
                sPhones = new Phone[numPhones];
+3 −3
Original line number Original line Diff line number Diff line
@@ -151,7 +151,7 @@ public class ProxyController {
    public void registerForAllDataDisconnected(int subId, Handler h, int what) {
    public void registerForAllDataDisconnected(int subId, Handler h, int what) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);
        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);
            mPhones[phoneId].registerForAllDataDisconnected(h, what);
        }
        }
    }
    }
@@ -159,7 +159,7 @@ public class ProxyController {
    public void unregisterForAllDataDisconnected(int subId, Handler h) {
    public void unregisterForAllDataDisconnected(int subId, Handler h) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);


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