[Settings] Enable WiFi calling toggle in search
WiFi calling toggle in search need to pass the toggle request to
receiver to make it work.
Bug: 206871758
Test: local
Change-Id: If23d1ae1eaeb5d505e584dec94e1980f6e329c65
(cherry picked from commit a6a35b8409e9b012d3e7baa7bde1351255e12794)
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index 3636341..c73bffa 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -179,7 +179,8 @@
.setTitle(res.getText(R.string.wifi_calling_settings_title))
.addEndItem(
SliceAction.createToggle(
- getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED),
+ getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED,
+ isWifiCallingEnabled),
null /* actionTitle */, isWifiCallingEnabled))
.setPrimaryAction(SliceAction.createDeeplink(
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
@@ -316,7 +317,7 @@
final Resources res = getResourcesForSubId(subId);
return new RowBuilder()
.setTitle(res.getText(preferenceTitleResId))
- .setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
+ .setTitleItem(SliceAction.createToggle(getBroadcastIntent(action, checked),
icon, res.getText(preferenceTitleResId), checked));
}
@@ -370,25 +371,31 @@
public void handleWifiCallingChanged(Intent intent) {
final int subId = getDefaultVoiceSubId();
- if (SubscriptionManager.isValidSubscriptionId(subId)) {
+ if (SubscriptionManager.isValidSubscriptionId(subId)
+ && intent.hasExtra(EXTRA_TOGGLE_STATE)) {
final WifiCallingQueryImsState queryState = queryImsState(subId);
if (queryState.isWifiCallingProvisioned()) {
- final boolean currentValue = queryState.isEnabledByUser()
- && queryState.isAllowUserControl();
+ final boolean currentValue = isWifiCallingEnabled();
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
currentValue);
final Intent activationAppIntent =
getWifiCallingCarrierActivityIntent(subId);
- if (!newValue || activationAppIntent == null) {
+ if ((newValue == currentValue) && activationAppIntent == null) {
// If either the action is to turn off wifi calling setting
// or there is no activation involved - Update the setting
- if (newValue != currentValue) {
- final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
- imsMmTelManager.setVoWiFiSettingEnabled(newValue);
- }
+ final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
+ imsMmTelManager.setVoWiFiSettingEnabled(!newValue);
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId
+ + " from " + currentValue + " to " + newValue);
}
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId + " needs provision");
}
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId);
}
+
// notify change in slice in any case to get re-queried. This would result in displaying
// appropriate message with the updated setting.
mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
@@ -541,10 +548,20 @@
PendingIntent.FLAG_IMMUTABLE);
}
- private PendingIntent getBroadcastIntent(String action) {
+ /**
+ * Create PendingIntent for Slice.
+ * Note: SliceAction#createDeeplink() didn't support toggle status so far,
+ * therefore, embedding toggle status within PendingIntent.
+ *
+ * @param action Slice action
+ * @param isChecked Status when Slice created.
+ * @return PendingIntent
+ */
+ private PendingIntent getBroadcastIntent(String action, boolean isChecked) {
final Intent intent = new Intent(action);
intent.setClass(mContext, SliceBroadcastReceiver.class);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ intent.putExtra(EXTRA_TOGGLE_STATE, isChecked);
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}