Merge "[Provider Model] Should not show WiFi call if all sims do not support it." into sc-dev am: bef9945917 am: 45e7dcb29d

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14860439

Change-Id: Ic88d73bb30dcb1408f06bfc793a3493e90810627
This commit is contained in:
Zoey Chen
2021-06-08 09:33:53 +00:00
committed by Automerger Merge Worker
2 changed files with 37 additions and 28 deletions

View File

@@ -13195,7 +13195,7 @@
<!-- Provider Model: Calls and SMS controllers settings screen, item title to go into the Calls and SMS settings --> <!-- Provider Model: Calls and SMS controllers settings screen, item title to go into the Calls and SMS settings -->
<string name="calls_and_sms">Calls &amp; SMS</string> <string name="calls_and_sms">Calls &amp; SMS</string>
<!-- Provider Model: Name for call settings category [CHAR LIMIT=NONE] --> <!-- Provider Model: Name for call settings category [CHAR LIMIT=NONE] -->
<string name="calls_and_sms_category">Wi\u2011Fi Calling</string> <string name="calls_and_sms_category">Wi\u2011Fi calling</string>
<!-- Provider Model: Summary for calling preference --> <!-- Provider Model: Summary for calling preference -->
<string name="calls_sms_wfc_summary">Make and receive calls over Wi\u2011Fi</string> <string name="calls_sms_wfc_summary">Make and receive calls over Wi\u2011Fi</string>
<!-- Provider Model: Label for footnote on calling preference --> <!-- Provider Model: Label for footnote on calling preference -->

View File

@@ -31,7 +31,7 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.ArraySet; import android.util.Log;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LifecycleObserver;
@@ -50,7 +50,6 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* Copied the logic of WiFi calling from {@link WifiCallingPreferenceController}. * Copied the logic of WiFi calling from {@link WifiCallingPreferenceController}.
@@ -72,8 +71,7 @@ public class NetworkProviderWifiCallingGroup extends
private Map<Integer, TelephonyManager> mTelephonyManagerList = new HashMap<>(); private Map<Integer, TelephonyManager> mTelephonyManagerList = new HashMap<>();
private Map<Integer, PhoneAccountHandle> mSimCallManagerList = new HashMap<>(); private Map<Integer, PhoneAccountHandle> mSimCallManagerList = new HashMap<>();
private Map<Integer, Preference> mWifiCallingForSubPreferences; private Map<Integer, Preference> mWifiCallingForSubPreferences;
private Set<Integer> mSubIdList = new ArraySet<>(); private List<SubscriptionInfo> mSubInfoListForWfc;
public NetworkProviderWifiCallingGroup(Context context, Lifecycle lifecycle, public NetworkProviderWifiCallingGroup(Context context, Lifecycle lifecycle,
String preferenceGroupKey) { String preferenceGroupKey) {
@@ -83,18 +81,26 @@ public class NetworkProviderWifiCallingGroup extends
mPreferenceGroupKey = preferenceGroupKey; mPreferenceGroupKey = preferenceGroupKey;
mWifiCallingForSubPreferences = new ArrayMap<>(); mWifiCallingForSubPreferences = new ArrayMap<>();
lifecycle.addObserver(this);
setSubscriptionInfoList(context); setSubscriptionInfoList(context);
lifecycle.addObserver(this);
} }
private void setSubscriptionInfoList(Context context) { private void setSubscriptionInfoList(Context context) {
final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions( mSubInfoListForWfc = SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager);
mSubscriptionManager); if (mSubInfoListForWfc != null) {
for (SubscriptionInfo info : subscriptions) { mSubInfoListForWfc.removeIf(info -> {
final int subId = info.getSubscriptionId(); final int subId = info.getSubscriptionId();
mSubIdList.add(subId);
setTelephonyManagerForSubscriptionId(context, subId); setTelephonyManagerForSubscriptionId(context, subId);
setPhoneAccountHandleForSubscriptionId(context, subId); setPhoneAccountHandleForSubscriptionId(context, subId);
boolean isExisted = mSubInfoListForWfc.contains(info);
boolean shouldShowWfcForSub = shouldShowWifiCallingForSub(subId);
if (!shouldShowWfcForSub && isExisted) {
return true;
}
return false;
});
} else {
Log.d(TAG, "No active subscriptions");
} }
} }
@@ -131,7 +137,12 @@ public class NetworkProviderWifiCallingGroup extends
@Override @Override
public boolean isAvailable() { public boolean isAvailable() {
return mSubIdList.size() >= 1; if (mSubInfoListForWfc == null) {
Log.d(TAG, "No active subscriptions, hide the controller");
return false;
} else {
return mSubInfoListForWfc.size() >= 1;
}
} }
@Override @Override
@@ -167,19 +178,15 @@ public class NetworkProviderWifiCallingGroup extends
final Map<Integer, Preference> toRemovePreferences = mWifiCallingForSubPreferences; final Map<Integer, Preference> toRemovePreferences = mWifiCallingForSubPreferences;
mWifiCallingForSubPreferences = new ArrayMap<>(); mWifiCallingForSubPreferences = new ArrayMap<>();
final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions( setSubscriptionInfoForPreference(toRemovePreferences);
mSubscriptionManager);
setSubscriptionInfoForPreference(subscriptions, toRemovePreferences);
for (Preference pref : toRemovePreferences.values()) { for (Preference pref : toRemovePreferences.values()) {
mPreferenceGroup.removePreference(pref); mPreferenceGroup.removePreference(pref);
} }
} }
private void setSubscriptionInfoForPreference(List<SubscriptionInfo> subscriptions, private void setSubscriptionInfoForPreference(Map<Integer, Preference> toRemovePreferences) {
Map<Integer, Preference> toRemovePreferences) {
int order = PREF_START_ORDER; int order = PREF_START_ORDER;
for (SubscriptionInfo info : subscriptions) { for (SubscriptionInfo info : mSubInfoListForWfc) {
final int subId = info.getSubscriptionId(); final int subId = info.getSubscriptionId();
if (!shouldShowWifiCallingForSub(subId)) { if (!shouldShowWifiCallingForSub(subId)) {
@@ -192,9 +199,11 @@ public class NetworkProviderWifiCallingGroup extends
mPreferenceGroup.addPreference(pref); mPreferenceGroup.addPreference(pref);
} }
CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(info, mContext); CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(info,
mContext);
if (getPhoneAccountHandleForSubscriptionId(subId) != null) { if (getPhoneAccountHandleForSubscriptionId(subId) != null) {
final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext, final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(
mContext,
getPhoneAccountHandleForSubscriptionId(subId)); getPhoneAccountHandleForSubscriptionId(subId));
if (intent != null) { if (intent != null) {
final PackageManager pm = mContext.getPackageManager(); final PackageManager pm = mContext.getPackageManager();