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

Commit 5e89a188 authored by Aleksander Morgado's avatar Aleksander Morgado
Browse files

systemui: check for telephony calling support in global actions dialog

When FEATURE_TELEPHONY is declared, the global actions dialog in
SystemUI has logic to show an "Emergency" red button that allows
opening the dialer to call emergency services.

The check for FEATURE_TELEPHONY is very broad and would also pass on
data-only telephony-capable devices (e.g. those declaring
FEATURE_TELEPHONY_DATA but not FEATURE_TELEPHONY_CALLING), effectively
making the Emergency calling option be shown in devices where voice
calling is unsupported, so unusable. Directly checking for
FEATURE_TELEPHONY_CALLING solves this issue.

The global actions dialog has two different ways to check for airplane
mode activation, either via the Telephony stack (when telephony is
available) or via the ContentObserver (when telephony is not
available). Given that the more reliable Telephony-stack based
airplane mode detection is needed to ensure airplane mode is not
disabled during an emergency call, it also makes sense to modify this
logic to be specific to devices with calling support, not just
telephony. The change to check for FEATURE_TELEPHONY_CALLING is
appropriate also in this context.

Bug: 435624005
Test: atest GlobalActionsDialogLiteTest (after manual re-enabling it)
Flag: EXEMPT bugfix

Change-Id: Ib177756d832007fa5be7ebfcca1805c840e98a70
parent 08d0feb9
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
    private boolean mDeviceProvisioned = false;
    private ToggleState mAirplaneState = ToggleState.Off;
    private boolean mIsWaitingForEcmExit = false;
    private boolean mHasTelephony;
    private boolean mHasTelephonyCalling;
    private boolean mHasVibrator;
    private final boolean mShowSilentToggle;
    private final boolean mIsTv;
@@ -492,7 +492,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        filter.addAction(TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
        mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter);

        mHasTelephony = packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
        mHasTelephonyCalling = packageManager.hasSystemFeature(
                PackageManager.FEATURE_TELEPHONY_CALLING);
        mIsTv = packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK);

        // get notified of phone state changes
@@ -877,8 +878,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene

    @VisibleForTesting
    boolean shouldDisplayEmergency() {
        // Emergency calling requires a telephony radio.
        return mHasTelephony;
        // Emergency calling requires a telephony radio with voice calling capabilities.
        return mHasTelephonyCalling;
    }

    @VisibleForTesting
@@ -2259,7 +2260,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        }

        void onToggle(boolean on) {
            if (mHasTelephony && TelephonyProperties.in_ecm_mode().orElse(false)) {
            if (mHasTelephonyCalling && TelephonyProperties.in_ecm_mode().orElse(false)) {
                mIsWaitingForEcmExit = true;
                // Launch ECM exit dialog
                Intent ecmDialogIntent =
@@ -2273,7 +2274,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene

        @Override
        protected void changeStateFromPress(boolean buttonOn) {
            if (!mHasTelephony) return;
            if (!mHasTelephonyCalling) return;

            // In ECM mode airplane state cannot be changed
            if (!TelephonyProperties.in_ecm_mode().orElse(false)) {
@@ -2431,7 +2432,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
            new TelephonyCallback.ServiceStateListener() {
        @Override
        public void onServiceStateChanged(ServiceState serviceState) {
            if (!mHasTelephony) return;
            if (!mHasTelephonyCalling) return;
            if (mAirplaneModeOn == null) {
                Log.d(TAG, "Service changed before actions created");
                return;
@@ -2471,7 +2472,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene

    private void onAirplaneModeChanged() {
        // Let the service state callbacks handle the state.
        if (mHasTelephony || mAirplaneModeOn == null) return;
        if (mHasTelephonyCalling || mAirplaneModeOn == null) return;

        boolean airplaneModeOn = mGlobalSettings.getInt(
                Settings.Global.AIRPLANE_MODE_ON,
@@ -2497,7 +2498,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
        intent.putExtra("state", on);
        mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
        if (!mHasTelephony) {
        if (!mHasTelephonyCalling) {
            mAirplaneState = on ? ToggleState.On : ToggleState.Off;
        }
    }