Merge "[automerger skipped] Merge "Treat mcx apn type as not wild-cardable." am: 61841ba690 am: afa7f96768 -s ours am skip reason: change_id Ic3e643646491e5a187505fd54ca767ad91e285f5 with SHA1 2fa0b7ed85 is in history" into qt-dev-plus-aosp
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index 766fa50..8274634 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -112,7 +112,8 @@
private UserManager mUserManager;
private PackageManager mPm;
- private boolean mFinishing;
+ @VisibleForTesting
+ boolean mFinishing;
private boolean mListeningToPackageRemove;
@@ -544,7 +545,7 @@
@VisibleForTesting
void retrieveAppEntry() {
final Activity activity = getActivity();
- if (activity == null) {
+ if (activity == null || mFinishing) {
return;
}
if (mState == null) {
@@ -650,7 +651,7 @@
|| TextUtils.equals(mAppEntry.info.packageName, packageName)) {
onPackageRemoved();
} else if (mAppEntry.info.isResourceOverlay()
- && TextUtils.equals(mPackageInfo.overlayTarget, packageName)) {
+ && TextUtils.equals(mPackageInfo.overlayTarget, packageName)) {
refreshUi();
}
}
diff --git a/src/com/android/settings/network/MobileNetworkListController.java b/src/com/android/settings/network/MobileNetworkListController.java
index 79715e3..a2e4116 100644
--- a/src/com/android/settings/network/MobileNetworkListController.java
+++ b/src/com/android/settings/network/MobileNetworkListController.java
@@ -24,12 +24,12 @@
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.euicc.EuiccManager;
import android.util.ArrayMap;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.network.telephony.MobileNetworkActivity;
+import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.List;
@@ -81,8 +81,8 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreferenceScreen = screen;
- final EuiccManager euiccManager = mContext.getSystemService(EuiccManager.class);
- mPreferenceScreen.findPreference(KEY_ADD_MORE).setVisible(euiccManager.isEnabled());
+ mPreferenceScreen.findPreference(KEY_ADD_MORE).setVisible(
+ MobileNetworkUtils.showEuiccSettings(mContext));
update();
}
diff --git a/src/com/android/settings/network/MobileNetworkSummaryController.java b/src/com/android/settings/network/MobileNetworkSummaryController.java
index 56735ab..463d7ae 100644
--- a/src/com/android/settings/network/MobileNetworkSummaryController.java
+++ b/src/com/android/settings/network/MobileNetworkSummaryController.java
@@ -28,6 +28,7 @@
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.network.telephony.MobileNetworkActivity;
+import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.widget.AddPreference;
import com.android.settingslib.Utils;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -49,7 +50,6 @@
private SubscriptionManager mSubscriptionManager;
private SubscriptionsChangeListener mChangeListener;
- private EuiccManager mEuiccManager;
private AddPreference mPreference;
/**
@@ -70,7 +70,6 @@
public MobileNetworkSummaryController(Context context, Lifecycle lifecycle) {
super(context);
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
- mEuiccManager = mContext.getSystemService(EuiccManager.class);
if (lifecycle != null) {
mChangeListener = new SubscriptionsChangeListener(context, this);
lifecycle.addObserver(this);
@@ -99,7 +98,7 @@
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
mSubscriptionManager);
if (subs.isEmpty()) {
- if (mEuiccManager.isEnabled()) {
+ if (MobileNetworkUtils.showEuiccSettings(mContext)) {
return mContext.getResources().getString(
R.string.mobile_network_summary_add_a_network);
}
@@ -133,7 +132,7 @@
mSubscriptionManager);
if (subs.isEmpty()) {
- if (mEuiccManager.isEnabled()) {
+ if (MobileNetworkUtils.showEuiccSettings(mContext)) {
mPreference.setOnPreferenceClickListener((Preference pref) -> {
startAddSimFlow();
return true;
@@ -142,7 +141,7 @@
} else {
// We have one or more existing subscriptions, so we want the plus button if eSIM is
// supported.
- if (mEuiccManager.isEnabled()) {
+ if (MobileNetworkUtils.showEuiccSettings(mContext)) {
mPreference.setAddWidgetEnabled(!mChangeListener.isAirplaneModeOn());
mPreference.setOnAddClickListener(p -> startAddSimFlow());
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 42c1b93..939598b 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -177,7 +177,7 @@
*/
public static boolean showEuiccSettings(Context context) {
EuiccManager euiccManager =
- (EuiccManager) context.getSystemService(Context.EUICC_SERVICE);
+ (EuiccManager) context.getSystemService(EuiccManager.class);
if (!euiccManager.isEnabled()) {
return false;
}
@@ -185,7 +185,7 @@
final ContentResolver cr = context.getContentResolver();
TelephonyManager tm =
- (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ (TelephonyManager) context.getSystemService(TelephonyManager.class);
String currentCountry = tm.getNetworkCountryIso().toLowerCase();
String supportedCountries =
Settings.Global.getString(cr, Settings.Global.EUICC_SUPPORTED_COUNTRIES);
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
index 56e59f7..e46cd06 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
@@ -282,6 +282,13 @@
}
@Test
+ public void getPreferenceControllers_exiting_shouldReturnNull() {
+ mFragment.mFinishing = true;
+
+ assertThat(mFragment.createPreferenceControllers(mShadowContext)).isNull();
+ }
+
+ @Test
public void getNumberOfUserWithPackageInstalled_twoUsersInstalled_shouldReturnTwo()
throws PackageManager.NameNotFoundException {
final String packageName = "Package1";
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java
index 10264ab..342fed5 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java
@@ -21,7 +21,6 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
@@ -31,7 +30,9 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.provider.Settings;
import android.telephony.SubscriptionInfo;
+import android.telephony.TelephonyManager;
import android.telephony.euicc.EuiccManager;
import org.junit.After;
@@ -53,6 +54,8 @@
@RunWith(RobolectricTestRunner.class)
public class MobileNetworkListControllerTest {
@Mock
+ TelephonyManager mTelephonyManager;
+ @Mock
EuiccManager mEuiccManager;
@Mock
@@ -69,7 +72,9 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(Robolectric.setupActivity(Activity.class));
+ when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager);
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.EUICC_PROVISIONED, 1);
when(mPreferenceScreen.getContext()).thenReturn(mContext);
mAddMorePreference = new Preference(mContext);
when(mPreferenceScreen.findPreference(MobileNetworkListController.KEY_ADD_MORE)).thenReturn(
@@ -99,6 +104,7 @@
@Test
public void displayPreference_eSimSupported_addMoreLinkIsVisible() {
when(mEuiccManager.isEnabled()).thenReturn(true);
+ when(mTelephonyManager.getNetworkCountryIso()).thenReturn("");
mController.displayPreference(mPreferenceScreen);
mController.onResume();
assertThat(mAddMorePreference.isVisible()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
index 3404ca2..8bcf8b6 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
@@ -33,6 +33,7 @@
import android.net.ConnectivityManager;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
+import android.telephony.TelephonyManager;
import android.telephony.euicc.EuiccManager;
import android.text.TextUtils;
@@ -59,6 +60,8 @@
@Mock
private Lifecycle mLifecycle;
@Mock
+ private TelephonyManager mTelephonyManager;
+ @Mock
private EuiccManager mEuiccManager;
@Mock
private PreferenceScreen mPreferenceScreen;
@@ -71,8 +74,11 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(Robolectric.setupActivity(Activity.class));
+ when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager);
+ when(mTelephonyManager.getNetworkCountryIso()).thenReturn("");
when(mEuiccManager.isEnabled()).thenReturn(true);
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.EUICC_PROVISIONED, 1);
mController = new MobileNetworkSummaryController(mContext, mLifecycle);
mPreference = spy(new AddPreference(mContext, null));