From b38edbb5d48283154b6d8b375ca4150a271e5f0a Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Fri, 12 Apr 2019 12:20:13 -0400 Subject: Fix "No Service" in QS when Airplane Mode QSCarrierGroup now accounts for the device being on airplane mode when deciding what to display. In particular, in QS, it marks the view as GONE. Test: visual, in phone with DSDS Test: atest CarrierTextControllerTest Fixes: 129839626 Change-Id: I54d03f6a00e6e9604fc646b8993a04429881552a --- .../android/keyguard/CarrierTextController.java | 15 ++++- .../com/android/systemui/qs/QSCarrierGroup.java | 72 ++++++++++++---------- 2 files changed, 52 insertions(+), 35 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java index 64517bae6d6b..baaa3fdb16ba 100644 --- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java +++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java @@ -311,20 +311,23 @@ public class CarrierTextController { displayText = updateCarrierTextWithSimIoError(displayText, carrierNames, subOrderBySlot, allSimsMissing); + boolean airplaneMode = false; // APM (airplane mode) != no carrier state. There are carrier services // (e.g. WFC = Wi-Fi calling) which may operate in APM. if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) { displayText = getAirplaneModeMessage(); + airplaneMode = true; } - if (TextUtils.isEmpty(displayText)) { + if (TextUtils.isEmpty(displayText) && !airplaneMode) { displayText = TextUtils.join(mSeparator, carrierNames); } final CarrierTextCallbackInfo info = new CarrierTextCallbackInfo( displayText, carrierNames, !allSimsMissing, - subsIds); + subsIds, + airplaneMode); postToCallback(info); } @@ -525,14 +528,22 @@ public class CarrierTextController { public final CharSequence[] listOfCarriers; public final boolean anySimReady; public final int[] subscriptionIds; + public boolean airplaneMode; @VisibleForTesting public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers, boolean anySimReady, int[] subscriptionIds) { + this(carrierText, listOfCarriers, anySimReady, subscriptionIds, false); + } + + @VisibleForTesting + public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers, + boolean anySimReady, int[] subscriptionIds, boolean airplaneMode) { this.carrierText = carrierText; this.listOfCarriers = listOfCarriers; this.anySimReady = anySimReady; this.subscriptionIds = subscriptionIds; + this.airplaneMode = airplaneMode; } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSCarrierGroup.java b/packages/SystemUI/src/com/android/systemui/qs/QSCarrierGroup.java index 0eeaa9b75382..7de8b74f30cc 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSCarrierGroup.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSCarrierGroup.java @@ -139,43 +139,49 @@ public class QSCarrierGroup extends LinearLayout implements @Override public void updateCarrierInfo(CarrierTextController.CarrierTextCallbackInfo info) { - if (info.anySimReady) { - boolean[] slotSeen = new boolean[SIM_SLOTS]; - if (info.listOfCarriers.length == info.subscriptionIds.length) { - for (int i = 0; i < SIM_SLOTS && i < info.listOfCarriers.length; i++) { - int slot = getSlotIndex(info.subscriptionIds[i]); - if (slot >= SIM_SLOTS) { - Log.w(TAG, "updateInfoCarrier - slot: " + slot); - continue; - } - if (slot == SubscriptionManager.INVALID_SIM_SLOT_INDEX) { - Log.e(TAG, - "Invalid SIM slot index for subscription: " - + info.subscriptionIds[i]); - continue; + if (info.airplaneMode) { + setVisibility(View.GONE); + } else { + setVisibility(View.VISIBLE); + if (info.anySimReady) { + boolean[] slotSeen = new boolean[SIM_SLOTS]; + if (info.listOfCarriers.length == info.subscriptionIds.length) { + for (int i = 0; i < SIM_SLOTS && i < info.listOfCarriers.length; i++) { + int slot = getSlotIndex(info.subscriptionIds[i]); + if (slot >= SIM_SLOTS) { + Log.w(TAG, "updateInfoCarrier - slot: " + slot); + continue; + } + if (slot == SubscriptionManager.INVALID_SIM_SLOT_INDEX) { + Log.e(TAG, + "Invalid SIM slot index for subscription: " + + info.subscriptionIds[i]); + continue; + } + mInfos[slot].visible = true; + slotSeen[slot] = true; + mCarrierGroups[slot].setCarrierText( + info.listOfCarriers[i].toString().trim()); + mCarrierGroups[slot].setVisibility(View.VISIBLE); } - mInfos[slot].visible = true; - slotSeen[slot] = true; - mCarrierGroups[slot].setCarrierText(info.listOfCarriers[i].toString().trim()); - mCarrierGroups[slot].setVisibility(View.VISIBLE); - } - for (int i = 0; i < SIM_SLOTS; i++) { - if (!slotSeen[i]) { - mInfos[i].visible = false; - mCarrierGroups[i].setVisibility(View.GONE); + for (int i = 0; i < SIM_SLOTS; i++) { + if (!slotSeen[i]) { + mInfos[i].visible = false; + mCarrierGroups[i].setVisibility(View.GONE); + } } + } else { + Log.e(TAG, "Carrier information arrays not of same length"); } } else { - Log.e(TAG, "Carrier information arrays not of same length"); - } - } else { - mInfos[0].visible = false; - mCarrierGroups[0].setCarrierText(info.carrierText); - mCarrierGroups[0].setVisibility(View.VISIBLE); - for (int i = 1; i < SIM_SLOTS; i++) { - mInfos[i].visible = false; - mCarrierGroups[i].setCarrierText(""); - mCarrierGroups[i].setVisibility(View.GONE); + mInfos[0].visible = false; + mCarrierGroups[0].setCarrierText(info.carrierText); + mCarrierGroups[0].setVisibility(View.VISIBLE); + for (int i = 1; i < SIM_SLOTS; i++) { + mInfos[i].visible = false; + mCarrierGroups[i].setCarrierText(""); + mCarrierGroups[i].setVisibility(View.GONE); + } } } handleUpdateState(); -- cgit v1.2.3-59-g8ed1b