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

Commit bb8c4aed authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ia402e0f5,I3b5ef470 into main

* changes:
  Check for telephony features before using their APIs
  Revert "Return false for emergency calls for automotive"
parents ffb1312e d0cc7051
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -203,7 +203,9 @@ public class CarrierTextManager {
            CarrierTextManagerLogger logger) {

        mContext = context;
        mIsEmergencyCallCapable = telephonyManager.isVoiceCapable();
        boolean hasTelephony = mContext.getPackageManager()
                .hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
        mIsEmergencyCallCapable = telephonyManager.isVoiceCapable() && hasTelephony;

        mShowAirplaneMode = showAirplaneMode;
        mShowMissingSim = showMissingSim;
@@ -221,9 +223,7 @@ public class CarrierTextManager {
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
        mLogger = logger;
        mBgExecutor.execute(() -> {
            boolean supported = mContext.getPackageManager()
                    .hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
            if (supported && mNetworkSupported.compareAndSet(false, supported)) {
            if (hasTelephony && mNetworkSupported.compareAndSet(false, hasTelephony)) {
                // This will set/remove the listeners appropriately. Note that it will never double
                // add the listeners.
                handleSetListening(mCarrierTextCallback);
+5 −9
Original line number Diff line number Diff line
@@ -192,20 +192,16 @@ constructor(
    override val isDeviceEmergencyCallCapable: StateFlow<Boolean> =
        serviceStateChangedEvent
            .mapLatest {
                val modems = telephonyManager.activeModemCount

                // Assume false for automotive devices which don't have the calling feature.
                // TODO: b/398045526 to revisit the below.
                val isAutomotive: Boolean =
                    context.packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
                val hasFeatureCalling: Boolean =
                // TODO(b/400460777): check for hasSystemFeature only once
                val hasRadioAccess: Boolean =
                    context.packageManager.hasSystemFeature(
                        PackageManager.FEATURE_TELEPHONY_CALLING
                        PackageManager.FEATURE_TELEPHONY_RADIO_ACCESS
                    )
                if (isAutomotive && !hasFeatureCalling) {
                if (!hasRadioAccess) {
                    return@mapLatest false
                }

                val modems = telephonyManager.activeModemCount
                // Check the service state for every modem. If any state reports emergency calling
                // capable, then consider the device to have emergency call capabilities
                (0..<modems)