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

Commit 38c5d9b9 authored by James Mattis's avatar James Mattis
Browse files

Return false for emergency calls for automotive

For automotive devices that lack the feature Telephony calling, return
false for emergency calls for the status bar. Not doing so results in
the UI crashing.

Flag: EXEMPT bugfix

Bug: 396801499
Bug: 310710841
Bug: 398045526
Test: AndroidAutomotiveNavigationBarTests:
        android.platform.tests.NavigationBarTest#testNotificationButton
Change-Id: I978a4c1f2ca151193cb71d151375b0f675cd9634
parent e9389790
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.telephony.CarrierConfigManager
import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager
@@ -192,6 +193,19 @@ constructor(
        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 =
                    context.packageManager.hasSystemFeature(
                        PackageManager.FEATURE_TELEPHONY_CALLING
                    )
                if (isAutomotive && !hasFeatureCalling) {
                    return@mapLatest false
                }

                // 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)