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:
@@ -13195,7 +13195,7 @@
|
||||
<!-- Provider Model: Calls and SMS controllers settings screen, item title to go into the Calls and SMS settings -->
|
||||
<string name="calls_and_sms">Calls & SMS</string>
|
||||
<!-- 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 -->
|
||||
<string name="calls_sms_wfc_summary">Make and receive calls over Wi\u2011Fi</string>
|
||||
<!-- Provider Model: Label for footnote on calling preference -->
|
||||
|
@@ -31,7 +31,7 @@ import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
@@ -50,7 +50,6 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 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, PhoneAccountHandle> mSimCallManagerList = new HashMap<>();
|
||||
private Map<Integer, Preference> mWifiCallingForSubPreferences;
|
||||
private Set<Integer> mSubIdList = new ArraySet<>();
|
||||
|
||||
private List<SubscriptionInfo> mSubInfoListForWfc;
|
||||
|
||||
public NetworkProviderWifiCallingGroup(Context context, Lifecycle lifecycle,
|
||||
String preferenceGroupKey) {
|
||||
@@ -83,18 +81,26 @@ public class NetworkProviderWifiCallingGroup extends
|
||||
|
||||
mPreferenceGroupKey = preferenceGroupKey;
|
||||
mWifiCallingForSubPreferences = new ArrayMap<>();
|
||||
lifecycle.addObserver(this);
|
||||
setSubscriptionInfoList(context);
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
private void setSubscriptionInfoList(Context context){
|
||||
final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions(
|
||||
mSubscriptionManager);
|
||||
for (SubscriptionInfo info : subscriptions) {
|
||||
final int subId = info.getSubscriptionId();
|
||||
mSubIdList.add(subId);
|
||||
setTelephonyManagerForSubscriptionId(context, subId);
|
||||
setPhoneAccountHandleForSubscriptionId(context, subId);
|
||||
private void setSubscriptionInfoList(Context context) {
|
||||
mSubInfoListForWfc = SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager);
|
||||
if (mSubInfoListForWfc != null) {
|
||||
mSubInfoListForWfc.removeIf(info -> {
|
||||
final int subId = info.getSubscriptionId();
|
||||
setTelephonyManagerForSubscriptionId(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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,12 +116,12 @@ public class NetworkProviderWifiCallingGroup extends
|
||||
mSimCallManagerList.put(subId, phoneAccountHandle);
|
||||
}
|
||||
|
||||
private TelephonyManager getTelephonyManagerForSubscriptionId(int subId){
|
||||
return mTelephonyManagerList.get(subId);
|
||||
private TelephonyManager getTelephonyManagerForSubscriptionId(int subId) {
|
||||
return mTelephonyManagerList.get(subId);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subId){
|
||||
protected PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subId) {
|
||||
return mSimCallManagerList.get(subId);
|
||||
}
|
||||
|
||||
@@ -131,7 +137,12 @@ public class NetworkProviderWifiCallingGroup extends
|
||||
|
||||
@Override
|
||||
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
|
||||
@@ -167,19 +178,15 @@ public class NetworkProviderWifiCallingGroup extends
|
||||
|
||||
final Map<Integer, Preference> toRemovePreferences = mWifiCallingForSubPreferences;
|
||||
mWifiCallingForSubPreferences = new ArrayMap<>();
|
||||
final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions(
|
||||
mSubscriptionManager);
|
||||
setSubscriptionInfoForPreference(subscriptions, toRemovePreferences);
|
||||
|
||||
setSubscriptionInfoForPreference(toRemovePreferences);
|
||||
for (Preference pref : toRemovePreferences.values()) {
|
||||
mPreferenceGroup.removePreference(pref);
|
||||
}
|
||||
}
|
||||
|
||||
private void setSubscriptionInfoForPreference(List<SubscriptionInfo> subscriptions,
|
||||
Map<Integer, Preference> toRemovePreferences) {
|
||||
private void setSubscriptionInfoForPreference(Map<Integer, Preference> toRemovePreferences) {
|
||||
int order = PREF_START_ORDER;
|
||||
for (SubscriptionInfo info : subscriptions) {
|
||||
for (SubscriptionInfo info : mSubInfoListForWfc) {
|
||||
final int subId = info.getSubscriptionId();
|
||||
|
||||
if (!shouldShowWifiCallingForSub(subId)) {
|
||||
@@ -192,9 +199,11 @@ public class NetworkProviderWifiCallingGroup extends
|
||||
mPreferenceGroup.addPreference(pref);
|
||||
}
|
||||
|
||||
CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(info, mContext);
|
||||
CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(info,
|
||||
mContext);
|
||||
if (getPhoneAccountHandleForSubscriptionId(subId) != null) {
|
||||
final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
|
||||
final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(
|
||||
mContext,
|
||||
getPhoneAccountHandleForSubscriptionId(subId));
|
||||
if (intent != null) {
|
||||
final PackageManager pm = mContext.getPackageManager();
|
||||
@@ -245,7 +254,7 @@ public class NetworkProviderWifiCallingGroup extends
|
||||
* 1. Check the subscription is valid or not.
|
||||
* 2. Check whether Wi-Fi Calling can be perform or not on this subscription.
|
||||
* 3. Check the carrier's config (carrier_wfc_ims_available_bool). If true, the carrier
|
||||
* supports the Wi-Fi calling, otherwise false.
|
||||
* supports the Wi-Fi calling, otherwise false.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
protected boolean shouldShowWifiCallingForSub(int subId) {
|
||||
|
Reference in New Issue
Block a user