From aee115ee3bf9fc36b2a06d7350512d61f1953728 Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Thu, 22 Dec 2022 07:41:32 +0000 Subject: [PATCH] [Settings] get wrong toggle when handle the WFC changed WFC toggle's state(EXTRA_TOGGLE_STATE) is set to the newValue after each notifyChange. However, WFC slice gets the same newValue from EXTRA_TOGGLE_STATE when users change the toggle state before the EXTRA_TOGGLE_STATE is updated. Need to get the "correct" new value to set the WFC Follow the original logic(ag/3820815), 1. don't turn on WFC and only can turn off WFC if activationApp is not null. 2. turn on/off if no activationApp. Bug: 261922170 Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSliceHelperTest Change-Id: I823f00029c24f1901f40757ba13e7c0f90d6c0bc --- .../settings/wifi/calling/WifiCallingSliceHelper.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java index c73bffa7411..522d697299c 100644 --- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java +++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java @@ -376,15 +376,17 @@ public class WifiCallingSliceHelper { final WifiCallingQueryImsState queryState = queryImsState(subId); if (queryState.isWifiCallingProvisioned()) { final boolean currentValue = isWifiCallingEnabled(); - final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE, - currentValue); + final boolean newValue = !(intent.getBooleanExtra(EXTRA_TOGGLE_STATE, + currentValue)); final Intent activationAppIntent = getWifiCallingCarrierActivityIntent(subId); - if ((newValue == currentValue) && activationAppIntent == null) { + // 1. If activationApp is not null, users only can turn off WFC, or + // 2. Turn on/off directly if there is no activationApp. + if ((newValue != currentValue) && (activationAppIntent == null || !newValue)) { // If either the action is to turn off wifi calling setting // or there is no activation involved - Update the setting final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId); - imsMmTelManager.setVoWiFiSettingEnabled(!newValue); + imsMmTelManager.setVoWiFiSettingEnabled(newValue); } else { Log.w(TAG, "action not taken: subId " + subId + " from " + currentValue + " to " + newValue);