Loading src/com/android/settings/applications/ApplicationFeatureProviderImpl.java +7 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.text.TextUtils; import android.util.ArraySet; import com.android.internal.telephony.SmsApplication; import com.android.internal.telephony.euicc.EuiccConnector; import com.android.settings.R; import java.util.ArrayList; Loading Loading @@ -141,6 +142,12 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide keepEnabledPackages.add(defaultSms.getPackageName()); } // Keep Euicc Service enabled. final ComponentInfo euicc = EuiccConnector.findBestComponent(mPm); if (euicc != null) { keepEnabledPackages.add(euicc.packageName); } keepEnabledPackages.addAll(getEnabledPackageWhitelist()); final LocationManager locationManager = Loading tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java +61 −5 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ComponentInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; Loading @@ -36,11 +37,12 @@ import android.os.Build; import android.os.UserHandle; import android.os.UserManager; import com.android.settings.R; import com.android.internal.telephony.euicc.EuiccConnector; import com.android.settings.testutils.ApplicationTestUtils; import com.android.settingslib.testutils.shadow.ShadowDefaultDialerManager; import com.android.settingslib.testutils.shadow.ShadowSmsApplication; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -49,6 +51,8 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.shadows.ShadowApplication; import org.robolectric.util.ReflectionHelpers; Loading Loading @@ -105,6 +109,12 @@ public final class ApplicationFeatureProviderImplTest { mPackageManagerService, mDevicePolicyManager); } @After @Config(shadows = {ShadowEuiccConnector.class}) public void tearDown() { ShadowEuiccConnector.reset(); } private void verifyCalculateNumberOfPolicyInstalledApps(boolean async) { setUpUsersAndInstalledApps(); Loading Loading @@ -282,6 +292,33 @@ public final class ApplicationFeatureProviderImplTest { assertThat(keepEnabledPackages).containsAllIn(expectedPackages); } @Test @Config(shadows = {ShadowSmsApplication.class, ShadowDefaultDialerManager.class, ShadowEuiccConnector.class}) public void getKeepEnabledPackages_hasEuiccComponent_shouldContainEuiccPackage() { final String testDialer = "com.android.test.defaultdialer"; final String testSms = "com.android.test.defaultsms"; final String testLocationHistory = "com.android.test.location.history"; final String testEuicc = "com.android.test.euicc"; ShadowSmsApplication.setDefaultSmsApplication(new ComponentName(testSms, "receiver")); ShadowDefaultDialerManager.setDefaultDialerApplication(testDialer); final ComponentInfo componentInfo = new ComponentInfo(); componentInfo.packageName = testEuicc; ShadowEuiccConnector.setBestComponent(componentInfo); // Spy the real context to mock LocationManager. Context spyContext = spy(RuntimeEnvironment.application); when(mLocationManager.getExtraLocationControllerPackage()).thenReturn(testLocationHistory); when(spyContext.getSystemService(Context.LOCATION_SERVICE)).thenReturn(mLocationManager); ReflectionHelpers.setField(mProvider, "mContext", spyContext); final Set<String> keepEnabledPackages = mProvider.getKeepEnabledPackages(); assertThat(keepEnabledPackages).contains(testEuicc); } @Test @Config(shadows = {ShadowSmsApplication.class, ShadowDefaultDialerManager.class}) public void getKeepEnabledPackages_shouldContainSettingsIntelligence() { Loading Loading @@ -354,4 +391,23 @@ public final class ApplicationFeatureProviderImplTest { resolveInfo.activityInfo = activityInfo; return resolveInfo; } @Implements(EuiccConnector.class) public static class ShadowEuiccConnector { private static ComponentInfo sBestComponent; @Implementation protected static ComponentInfo findBestComponent(PackageManager packageManager) { return sBestComponent; } public static void setBestComponent(ComponentInfo componentInfo) { sBestComponent = componentInfo; } public static void reset() { sBestComponent = null; } } } Loading
src/com/android/settings/applications/ApplicationFeatureProviderImpl.java +7 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.text.TextUtils; import android.util.ArraySet; import com.android.internal.telephony.SmsApplication; import com.android.internal.telephony.euicc.EuiccConnector; import com.android.settings.R; import java.util.ArrayList; Loading Loading @@ -141,6 +142,12 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide keepEnabledPackages.add(defaultSms.getPackageName()); } // Keep Euicc Service enabled. final ComponentInfo euicc = EuiccConnector.findBestComponent(mPm); if (euicc != null) { keepEnabledPackages.add(euicc.packageName); } keepEnabledPackages.addAll(getEnabledPackageWhitelist()); final LocationManager locationManager = Loading
tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java +61 −5 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ComponentInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; Loading @@ -36,11 +37,12 @@ import android.os.Build; import android.os.UserHandle; import android.os.UserManager; import com.android.settings.R; import com.android.internal.telephony.euicc.EuiccConnector; import com.android.settings.testutils.ApplicationTestUtils; import com.android.settingslib.testutils.shadow.ShadowDefaultDialerManager; import com.android.settingslib.testutils.shadow.ShadowSmsApplication; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -49,6 +51,8 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.shadows.ShadowApplication; import org.robolectric.util.ReflectionHelpers; Loading Loading @@ -105,6 +109,12 @@ public final class ApplicationFeatureProviderImplTest { mPackageManagerService, mDevicePolicyManager); } @After @Config(shadows = {ShadowEuiccConnector.class}) public void tearDown() { ShadowEuiccConnector.reset(); } private void verifyCalculateNumberOfPolicyInstalledApps(boolean async) { setUpUsersAndInstalledApps(); Loading Loading @@ -282,6 +292,33 @@ public final class ApplicationFeatureProviderImplTest { assertThat(keepEnabledPackages).containsAllIn(expectedPackages); } @Test @Config(shadows = {ShadowSmsApplication.class, ShadowDefaultDialerManager.class, ShadowEuiccConnector.class}) public void getKeepEnabledPackages_hasEuiccComponent_shouldContainEuiccPackage() { final String testDialer = "com.android.test.defaultdialer"; final String testSms = "com.android.test.defaultsms"; final String testLocationHistory = "com.android.test.location.history"; final String testEuicc = "com.android.test.euicc"; ShadowSmsApplication.setDefaultSmsApplication(new ComponentName(testSms, "receiver")); ShadowDefaultDialerManager.setDefaultDialerApplication(testDialer); final ComponentInfo componentInfo = new ComponentInfo(); componentInfo.packageName = testEuicc; ShadowEuiccConnector.setBestComponent(componentInfo); // Spy the real context to mock LocationManager. Context spyContext = spy(RuntimeEnvironment.application); when(mLocationManager.getExtraLocationControllerPackage()).thenReturn(testLocationHistory); when(spyContext.getSystemService(Context.LOCATION_SERVICE)).thenReturn(mLocationManager); ReflectionHelpers.setField(mProvider, "mContext", spyContext); final Set<String> keepEnabledPackages = mProvider.getKeepEnabledPackages(); assertThat(keepEnabledPackages).contains(testEuicc); } @Test @Config(shadows = {ShadowSmsApplication.class, ShadowDefaultDialerManager.class}) public void getKeepEnabledPackages_shouldContainSettingsIntelligence() { Loading Loading @@ -354,4 +391,23 @@ public final class ApplicationFeatureProviderImplTest { resolveInfo.activityInfo = activityInfo; return resolveInfo; } @Implements(EuiccConnector.class) public static class ShadowEuiccConnector { private static ComponentInfo sBestComponent; @Implementation protected static ComponentInfo findBestComponent(PackageManager packageManager) { return sBestComponent; } public static void setBestComponent(ComponentInfo componentInfo) { sBestComponent = componentInfo; } public static void reset() { sBestComponent = null; } } }