[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 a6a35b8409
)
This commit is contained in:
@@ -179,7 +179,8 @@ public class WifiCallingSliceHelper {
|
|||||||
.setTitle(res.getText(R.string.wifi_calling_settings_title))
|
.setTitle(res.getText(R.string.wifi_calling_settings_title))
|
||||||
.addEndItem(
|
.addEndItem(
|
||||||
SliceAction.createToggle(
|
SliceAction.createToggle(
|
||||||
getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED),
|
getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED,
|
||||||
|
isWifiCallingEnabled),
|
||||||
null /* actionTitle */, isWifiCallingEnabled))
|
null /* actionTitle */, isWifiCallingEnabled))
|
||||||
.setPrimaryAction(SliceAction.createDeeplink(
|
.setPrimaryAction(SliceAction.createDeeplink(
|
||||||
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
|
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
|
||||||
@@ -316,7 +317,7 @@ public class WifiCallingSliceHelper {
|
|||||||
final Resources res = getResourcesForSubId(subId);
|
final Resources res = getResourcesForSubId(subId);
|
||||||
return new RowBuilder()
|
return new RowBuilder()
|
||||||
.setTitle(res.getText(preferenceTitleResId))
|
.setTitle(res.getText(preferenceTitleResId))
|
||||||
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
|
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action, checked),
|
||||||
icon, res.getText(preferenceTitleResId), checked));
|
icon, res.getText(preferenceTitleResId), checked));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,25 +371,31 @@ public class WifiCallingSliceHelper {
|
|||||||
public void handleWifiCallingChanged(Intent intent) {
|
public void handleWifiCallingChanged(Intent intent) {
|
||||||
final int subId = getDefaultVoiceSubId();
|
final int subId = getDefaultVoiceSubId();
|
||||||
|
|
||||||
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
if (SubscriptionManager.isValidSubscriptionId(subId)
|
||||||
|
&& intent.hasExtra(EXTRA_TOGGLE_STATE)) {
|
||||||
final WifiCallingQueryImsState queryState = queryImsState(subId);
|
final WifiCallingQueryImsState queryState = queryImsState(subId);
|
||||||
if (queryState.isWifiCallingProvisioned()) {
|
if (queryState.isWifiCallingProvisioned()) {
|
||||||
final boolean currentValue = queryState.isEnabledByUser()
|
final boolean currentValue = isWifiCallingEnabled();
|
||||||
&& queryState.isAllowUserControl();
|
|
||||||
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
||||||
currentValue);
|
currentValue);
|
||||||
final Intent activationAppIntent =
|
final Intent activationAppIntent =
|
||||||
getWifiCallingCarrierActivityIntent(subId);
|
getWifiCallingCarrierActivityIntent(subId);
|
||||||
if (!newValue || activationAppIntent == null) {
|
if ((newValue == currentValue) && activationAppIntent == null) {
|
||||||
// If either the action is to turn off wifi calling setting
|
// If either the action is to turn off wifi calling setting
|
||||||
// or there is no activation involved - Update the setting
|
// or there is no activation involved - Update the setting
|
||||||
if (newValue != currentValue) {
|
|
||||||
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
||||||
imsMmTelManager.setVoWiFiSettingEnabled(newValue);
|
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
|
// notify change in slice in any case to get re-queried. This would result in displaying
|
||||||
// appropriate message with the updated setting.
|
// appropriate message with the updated setting.
|
||||||
mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
|
mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
|
||||||
@@ -541,10 +548,20 @@ public class WifiCallingSliceHelper {
|
|||||||
PendingIntent.FLAG_IMMUTABLE);
|
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);
|
final Intent intent = new Intent(action);
|
||||||
intent.setClass(mContext, SliceBroadcastReceiver.class);
|
intent.setClass(mContext, SliceBroadcastReceiver.class);
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||||
|
intent.putExtra(EXTRA_TOGGLE_STATE, isChecked);
|
||||||
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
|
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user