Update search for mobile network settings

This CL make all mobile related preferences support:
1. If subId is manually set, check visibility by subId
2. If not, try find whether there is one active subId meets requirement.
If so, isAvailable() will return true to enable search.

Bug: 77276236
Test: RunSettingsRoboTests
Change-Id: I24e2d2f5e882284ba8e997b844caee7722b6b07d
This commit is contained in:
jackqdyulei
2019-01-09 13:15:53 -08:00
parent d2e7bfeb1c
commit e6d7d3b1e7
20 changed files with 338 additions and 109 deletions

View File

@@ -29,18 +29,15 @@ import android.text.TextUtils;
import androidx.preference.Preference;
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.core.BasePreferenceController;
/**
* Preference controller for "Data service setup"
*/
public class DataServiceSetupPreferenceController extends BasePreferenceController {
public class DataServiceSetupPreferenceController extends TelephonyBasePreferenceController {
private CarrierConfigManager mCarrierConfigManager;
private TelephonyManager mTelephonyManager;
private PersistableBundle mCarrierConfig;
private String mSetupUrl;
private int mSubId;
public DataServiceSetupPreferenceController(Context context, String key) {
super(context, key);
@@ -48,16 +45,16 @@ public class DataServiceSetupPreferenceController extends BasePreferenceControll
mTelephonyManager = context.getSystemService(TelephonyManager.class);
mSetupUrl = Settings.Global.getString(mContext.getContentResolver(),
Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
@Override
public int getAvailabilityStatus() {
public int getAvailabilityStatus(int subId) {
final boolean isLteOnCdma = mTelephonyManager.getLteOnCdmaMode()
== PhoneConstants.LTE_ON_CDMA_TRUE;
return mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
&& mCarrierConfig != null
&& !mCarrierConfig.getBoolean(
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
&& carrierConfig != null
&& !carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
&& isLteOnCdma && !TextUtils.isEmpty(mSetupUrl)
? AVAILABLE
@@ -67,7 +64,6 @@ public class DataServiceSetupPreferenceController extends BasePreferenceControll
public void init(int subId) {
mSubId = subId;
mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
}
@Override