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

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

Merge "Add APIs to return max possible active phones."

parents 95112612 30693c0a
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -361,7 +361,6 @@ public class TelephonyManager {
        }
    }


    /**
     * Returns the number of phones available.
     * Returns 0 if none of voice, sms, data is not supported
@@ -394,6 +393,31 @@ public class TelephonyManager {
        return phoneCount;
    }

    /**
     *
     * Return how many phone / logical modem can be active simultaneously, in terms of device
     * capability.
     * For example, for a dual-SIM capable device, it always returns 2, even if only one logical
     * modem / SIM is active (aka in single SIM mode).
     *
     * TODO: b/139642279 publicize and rename.
     * @hide
     */
    public static int getMaxPhoneCount() {
        // TODO: b/139642279 when turning on this feature, remove dependency of
        // PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE and always return result based on
        // PROPERTY_MAX_ACTIVE_MODEMS.
        String rebootRequired = SystemProperties.get(
                TelephonyProperties.PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE);
        if (rebootRequired.equals("false")) {
            // If no reboot is required, return max possible active modems.
            return SystemProperties.getInt(
                    TelephonyProperties.PROPERTY_MAX_ACTIVE_MODEMS, getDefault().getPhoneCount());
        } else {
            return getDefault().getPhoneCount();
        }
    }

    /** {@hide} */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    public static TelephonyManager from(Context context) {
+7 −0
Original line number Diff line number Diff line
@@ -234,4 +234,11 @@ public interface TelephonyProperties
    String DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME =
            "persist.radio.display_opportunistic_carrier";

    /**
     * How many logical modems can be active simultaneously. For example, if a device is dual-SIM
     * capable but currently only one SIM slot and one logical modem is active, this value is still
     * two.
     * Type: int
     */
    static final String PROPERTY_MAX_ACTIVE_MODEMS = "ro.telephony.max.active.modems";
}