OSDN Git Service

Fix instant app filtering in ApplicationsState
authorJesse Evans <jsje@google.com>
Thu, 13 Apr 2017 01:06:50 +0000 (18:06 -0700)
committerJesse Evans <jsje@google.com>
Fri, 14 Apr 2017 02:48:48 +0000 (19:48 -0700)
This fixes instant apps showing up as installed apps in the settings
UI where they should not be (namely the opening links page).

Test: Added tests for the filter
      runtest -x packages/SettingsLib/tests/integ

Bug: 37108030
Change-Id: I0fc6cfd237d470a1f4dde7b2db38d8b3643ee6f7

packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
packages/SettingsLib/tests/integ/src/com/android/settingslib/applications/ApplicationsStateTest.java

index dfa1627..8a86c13 100644 (file)
@@ -1502,7 +1502,8 @@ public class ApplicationsState {
 
         @Override
         public boolean filterApp(AppEntry entry) {
-            return (entry.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS) != 0;
+            return !AppUtils.isInstant(entry.info)
+                && (entry.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS) != 0;
         }
     };
 
index c680b2a..fed18fa 100644 (file)
@@ -201,6 +201,22 @@ public class ApplicationsStateTest {
     }
 
     @Test
+    public void testFilterWithDomainUrls() {
+        mEntry.info.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS;
+        // should included updated system apps
+        when(mEntry.info.isInstantApp()).thenReturn(false);
+        assertThat(ApplicationsState.FILTER_WITH_DOMAIN_URLS.filterApp(mEntry))
+                .isTrue();
+        mEntry.info.privateFlags &= ~ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS;
+        assertThat(ApplicationsState.FILTER_WITH_DOMAIN_URLS.filterApp(mEntry))
+                .isFalse();
+        mEntry.info.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS;
+        when(mEntry.info.isInstantApp()).thenReturn(true);
+        assertThat(ApplicationsState.FILTER_WITH_DOMAIN_URLS.filterApp(mEntry))
+                .isFalse();
+    }
+
+    @Test
     public void testDisabledFilterRejectsInstantApp() {
         mEntry.info.enabled = false;
         assertThat(ApplicationsState.FILTER_DISABLED.filterApp(mEntry)).isTrue();