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

Commit 781630e4 authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Android (Google) Code Review
Browse files

Merge changes from topic "141388730"

* changes:
  In CarrierTextController replace getPhoneCount with getMaxPhoneCount.
  Replace getPhoneCount with getMaxPhoneCount upon object allocation.
parents 5fd49699 7a6936f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -167,7 +167,7 @@ public class CarrierTextController {
        mSeparator = separator;
        mSeparator = separator;
        mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
        mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
        mSimSlotsNumber = ((TelephonyManager) context.getSystemService(
        mSimSlotsNumber = ((TelephonyManager) context.getSystemService(
                Context.TELEPHONY_SERVICE)).getPhoneCount();
                Context.TELEPHONY_SERVICE)).getMaxPhoneCount();
        mSimErrorState = new boolean[mSimSlotsNumber];
        mSimErrorState = new boolean[mSimSlotsNumber];
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -125,7 +125,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {


        mCarrierTextCallbackInfo = new CarrierTextController.CarrierTextCallbackInfo("",
        mCarrierTextCallbackInfo = new CarrierTextController.CarrierTextCallbackInfo("",
                new CharSequence[]{}, false, new int[]{});
                new CharSequence[]{}, false, new int[]{});
        when(mTelephonyManager.getPhoneCount()).thenReturn(3);
        when(mTelephonyManager.getMaxPhoneCount()).thenReturn(3);


        mCarrierTextController = new TestCarrierTextController(mContext, SEPARATOR, true, true,
        mCarrierTextController = new TestCarrierTextController(mContext, SEPARATOR, true, true,
                mKeyguardUpdateMonitor);
                mKeyguardUpdateMonitor);
+1 −1
Original line number Original line Diff line number Diff line
@@ -385,7 +385,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
        mContext = context;
        mContext = context;
        mBatteryStats = BatteryStatsService.getService();
        mBatteryStats = BatteryStatsService.getService();


        int numPhones = TelephonyManager.getDefault().getPhoneCount();
        int numPhones = TelephonyManager.getDefault().getMaxPhoneCount();
        if (DBG) log("TelephonyRegistry: ctor numPhones=" + numPhones);
        if (DBG) log("TelephonyRegistry: ctor numPhones=" + numPhones);
        mNumPhones = numPhones;
        mNumPhones = numPhones;
        mCallState = new int[numPhones];
        mCallState = new int[numPhones];
+15 −2
Original line number Original line Diff line number Diff line
@@ -2101,13 +2101,26 @@ public class SubscriptionManager {
    /** @hide */
    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    public static boolean isValidSlotIndex(int slotIndex) {
    public static boolean isValidSlotIndex(int slotIndex) {
        return slotIndex >= 0 && slotIndex < TelephonyManager.getDefault().getSimCount();
        return slotIndex >= 0 && slotIndex < TelephonyManager.getDefault().getMaxPhoneCount();
    }
    }


    /** @hide */
    /** @hide */
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    public static boolean isValidPhoneId(int phoneId) {
    public static boolean isValidPhoneId(int phoneId) {
        return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount();
        return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getMaxPhoneCount();
    }

    /**
     * When getPhoneCount and getMaxPhoneCount return different value, isValidPhoneId being true
     * doesn't mean 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 isActivePhoneId(int slotIndex) {
        return slotIndex < TelephonyManager.getDefault().getPhoneCount();
    }
    }


    /** @hide */
    /** @hide */
+3 −3
Original line number Original line Diff line number Diff line
@@ -399,7 +399,7 @@ public class TelephonyManager {
     * TODO: b/139642279 publicize and rename.
     * TODO: b/139642279 publicize and rename.
     * @hide
     * @hide
     */
     */
    public static int getMaxPhoneCount() {
    public int getMaxPhoneCount() {
        // TODO: b/139642279 when turning on this feature, remove dependency of
        // TODO: b/139642279 when turning on this feature, remove dependency of
        // PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE and always return result based on
        // PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE and always return result based on
        // PROPERTY_MAX_ACTIVE_MODEMS.
        // PROPERTY_MAX_ACTIVE_MODEMS.
@@ -408,9 +408,9 @@ public class TelephonyManager {
        if (rebootRequired.equals("false")) {
        if (rebootRequired.equals("false")) {
            // If no reboot is required, return max possible active modems.
            // If no reboot is required, return max possible active modems.
            return SystemProperties.getInt(
            return SystemProperties.getInt(
                    TelephonyProperties.PROPERTY_MAX_ACTIVE_MODEMS, getDefault().getPhoneCount());
                    TelephonyProperties.PROPERTY_MAX_ACTIVE_MODEMS, getPhoneCount());
        } else {
        } else {
            return getDefault().getPhoneCount();
            return getPhoneCount();
        }
        }
    }
    }