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

Commit da67c9ba authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Gerrit Code Review
Browse files

Merge "Update/clear connection proxy of RIL upon single SIM and dual SIM switch"

parents 27f92d01 cb5330cd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2363,6 +2363,14 @@ public interface CommandsInterface {
     */
    default void enableModem(boolean enable, Message result) {};

    /**
     * Notify CommandsInterface that whether its corresponding slot is active or not. If not,
     * it means it has no RIL service or logical modem to connect to.
     *
     * @param active whether there's a matching active SIM slot.
     */
    default void onSlotActiveStatusChange(boolean active) {}

    /**
     * Query whether logical modem is enabled or disabled
     *
+18 −0
Original line number Diff line number Diff line
@@ -119,6 +119,19 @@ public class PhoneConfigurationManager {
        return sInstance;
    }

    /**
     * Whether the phoneId has a corresponding active slot / logical modem. If a DSDS capable
     * device is in single SIM mode, phoneId=1 is valid but not active.
     *
     * TODO: b/139642279 combine with SubscriptionManager#isValidPhoneId when phone objects
     * are dynamically allocated instead of always based on getMaxPhoneCount.
     * @hide
     */
    public static boolean isPhoneActive(int phoneId) {
        // Currently it simply depends on getPhoneCount. In future it can be generalized.
        return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount();
    }

    /**
     * Handler class to handle callbacks
     */
@@ -365,6 +378,11 @@ public class PhoneConfigurationManager {
        } else {
            log("setMultiSimProperties: Rebooting is not required to switch multi-sim config to "
                    + finalMultiSimConfig);
            // Register to RIL service if needed.
            for (int i = 0; i < mPhones.length; i++) {
                Phone phone = mPhones[i];
                phone.mCi.onSlotActiveStatusChange(isPhoneActive(i));
            }
        }
    }

+11 −3
Original line number Diff line number Diff line
@@ -91,7 +91,6 @@ 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;
@@ -414,7 +413,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 (!PhoneConfigurationManager.isPhoneActive(mPhoneId)) return null;
        if (!mIsMobileNetworkSupported) {
            if (RILJ_LOGV) riljLog("getRadioProxy: Not calling getService(): wifi-only");
            if (result != null) {
@@ -505,10 +504,19 @@ public class RIL extends BaseCommands implements CommandsInterface {
        return mRadioProxy;
    }

    @Override
    public synchronized void onSlotActiveStatusChange(boolean active) {
        if (active) {
            // Try to connect to RIL services and set response functions.
            getRadioProxy(null);
            getOemHookProxy(null);
        }
    }

    /** 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 (!PhoneConfigurationManager.isPhoneActive(mPhoneId)) return null;
        if (!mIsMobileNetworkSupported) {
            if (RILJ_LOGV) riljLog("getOemHookProxy: Not calling getService(): wifi-only");
            if (result != null) {