Refactor EuiccPreference
Bug: 114749736 Test: RunSettingsRoboTests Change-Id: I7192e40c5ff6eb064f29517c21021a095d505d7f
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network.telephony;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.PersistableBundle;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.euicc.EuiccManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
/**
|
||||
* Preference controller for "Euicc preference"
|
||||
*/
|
||||
public class EuiccPreferenceController extends BasePreferenceController {
|
||||
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private int mSubId;
|
||||
|
||||
public EuiccPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return MobileNetworkUtils.showEuiccSettings(mContext)
|
||||
? AVAILABLE
|
||||
: CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mTelephonyManager.getSimOperatorName();
|
||||
}
|
||||
|
||||
public void init(int subId) {
|
||||
mSubId = subId;
|
||||
mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||
Intent intent = new Intent(EuiccManager.ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -122,7 +122,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
|
||||
//UI objects
|
||||
private SwitchPreference mButton4glte;
|
||||
private Preference mEuiccSettingsPref;
|
||||
private PreferenceCategory mCallingCategory;
|
||||
private Preference mWiFiCallingPref;
|
||||
private SwitchPreference mVideoCallingPref;
|
||||
@@ -222,10 +221,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
REQUEST_CODE_EXIT_ECM);
|
||||
}
|
||||
return true;
|
||||
} else if (preference == mEuiccSettingsPref) {
|
||||
Intent intent = new Intent(EuiccManager.ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
} else if (preference == mWiFiCallingPref || preference == mVideoCallingPref) {
|
||||
return false;
|
||||
}
|
||||
@@ -279,6 +274,7 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
use(EnabledNetworkModePreferenceController.class).init(mSubId);
|
||||
use(Enhanced4gLtePreferenceController.class).init(mSubId);
|
||||
use(DataServiceSetupPreferenceController.class).init(mSubId);
|
||||
use(EuiccPreferenceController.class).init(mSubId);
|
||||
|
||||
mCdmaSystemSelectPreferenceController = use(CdmaSystemSelectPreferenceController.class);
|
||||
mCdmaSystemSelectPreferenceController.init(getPreferenceManager(), mSubId);
|
||||
@@ -319,12 +315,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
mShow4GForLTE = false;
|
||||
}
|
||||
|
||||
//get UI object references
|
||||
PreferenceScreen prefSet = getPreferenceScreen();
|
||||
|
||||
mEuiccSettingsPref = prefSet.findPreference(BUTTON_CARRIER_SETTINGS_EUICC_KEY);
|
||||
mEuiccSettingsPref.setOnPreferenceChangeListener(this);
|
||||
|
||||
// Initialize mActiveSubInfo
|
||||
int max = mSubscriptionManager.getActiveSubscriptionInfoCountMax();
|
||||
mActiveSubInfos = mSubscriptionManager.getActiveSubscriptionInfoList();
|
||||
@@ -450,12 +440,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
|
||||
if (hasActiveSubscriptions) {
|
||||
updateBodyAdvancedFields(activity, prefSet, mSubId, hasActiveSubscriptions);
|
||||
} else {
|
||||
// Shows the "Carrier" preference that allows user to add a e-sim profile.
|
||||
if (MobileNetworkUtils.showEuiccSettings(getContext())) {
|
||||
mEuiccSettingsPref.setSummary(null /* summary */);
|
||||
prefSet.addPreference(mEuiccSettingsPref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,16 +452,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
log("updateBody: isLteOnCdma=" + isLteOnCdma + " phoneSubId=" + phoneSubId);
|
||||
}
|
||||
|
||||
if (MobileNetworkUtils.showEuiccSettings(getContext())) {
|
||||
prefSet.addPreference(mEuiccSettingsPref);
|
||||
String spn = mTelephonyManager.getSimOperatorName();
|
||||
if (TextUtils.isEmpty(spn)) {
|
||||
mEuiccSettingsPref.setSummary(null);
|
||||
} else {
|
||||
mEuiccSettingsPref.setSummary(spn);
|
||||
}
|
||||
}
|
||||
|
||||
int settingsNetworkMode = android.provider.Settings.Global.getInt(
|
||||
getContext().getContentResolver(),
|
||||
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
|
||||
@@ -880,8 +854,7 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
// For ListPreferences, we log it here without a value, only indicating it's clicked to
|
||||
// open the list dialog. When a value is chosen, another MetricsEvent is logged with
|
||||
// new value in onPreferenceChange.
|
||||
if (preference == mEuiccSettingsPref
|
||||
|| preference == mWiFiCallingPref
|
||||
if (preference == mWiFiCallingPref
|
||||
|| preference == preferenceScreen.findPreference(BUTTON_CDMA_SYSTEM_SELECT_KEY)
|
||||
|| preference == preferenceScreen.findPreference(BUTTON_CDMA_SUBSCRIPTION_KEY)
|
||||
|| preference == preferenceScreen.findPreference(BUTTON_GSM_APN_EXPAND_KEY)
|
||||
@@ -915,8 +888,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
|
||||
|
||||
if (preference == null) {
|
||||
return MetricsProto.MetricsEvent.VIEW_UNKNOWN;
|
||||
} else if (preference == mEuiccSettingsPref) {
|
||||
return MetricsProto.MetricsEvent.ACTION_MOBILE_NETWORK_EUICC_SETTING;
|
||||
} else if (preference == mWiFiCallingPref) {
|
||||
return MetricsProto.MetricsEvent.ACTION_MOBILE_NETWORK_WIFI_CALLING;
|
||||
} else if (preference == mVideoCallingPref) {
|
||||
|
Reference in New Issue
Block a user