Merge "[Provider Model] Should not show WiFi call if all sims do not support it." into sc-dev am: bef9945917
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14860439 Change-Id: I6b63442d4bb9053e0dede0789984596047e4e26c
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 -->
|
<!-- 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>
|
<string name="calls_and_sms">Calls & 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 -->
|
||||||
|
@@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,12 +116,12 @@ public class NetworkProviderWifiCallingGroup extends
|
|||||||
mSimCallManagerList.put(subId, phoneAccountHandle);
|
mSimCallManagerList.put(subId, phoneAccountHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TelephonyManager getTelephonyManagerForSubscriptionId(int subId){
|
private TelephonyManager getTelephonyManagerForSubscriptionId(int subId) {
|
||||||
return mTelephonyManagerList.get(subId);
|
return mTelephonyManagerList.get(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subId){
|
protected PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subId) {
|
||||||
return mSimCallManagerList.get(subId);
|
return mSimCallManagerList.get(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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();
|
||||||
@@ -245,7 +254,7 @@ public class NetworkProviderWifiCallingGroup extends
|
|||||||
* 1. Check the subscription is valid or not.
|
* 1. Check the subscription is valid or not.
|
||||||
* 2. Check whether Wi-Fi Calling can be perform or not on this subscription.
|
* 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
|
* 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
|
@VisibleForTesting
|
||||||
protected boolean shouldShowWifiCallingForSub(int subId) {
|
protected boolean shouldShowWifiCallingForSub(int subId) {
|
||||||
|
Reference in New Issue
Block a user