OSDN Git Service

Add a photos app filter and a metric for using it.
authorDaniel Nishi <dhnishi@google.com>
Wed, 23 Aug 2017 17:27:08 +0000 (10:27 -0700)
committerDaniel Nishi <dhnishi@google.com>
Fri, 1 Sep 2017 17:38:43 +0000 (10:38 -0700)
Bug: 64147318
Test: SettingsLib integ tests

Change-Id: Id165a514aa65d2efdd4e6753c3e73762293e892e
Merged-In: I4cae384fa565ac0928177bd85804d7904cd6156c

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

index 443f1ee..87bf0de 100644 (file)
@@ -1638,6 +1638,21 @@ public class ApplicationsState {
         }
     };
 
+    public static final AppFilter FILTER_PHOTOS =
+            new AppFilter() {
+                @Override
+                public void init() {}
+
+                @Override
+                public boolean filterApp(AppEntry entry) {
+                    boolean isPhotosApp;
+                    synchronized (entry) {
+                        isPhotosApp = entry.info.category == ApplicationInfo.CATEGORY_IMAGE;
+                    }
+                    return isPhotosApp;
+                }
+            };
+
     public static final AppFilter FILTER_OTHER_APPS =
             new AppFilter() {
                 @Override
index fed18fa..751b4ba 100644 (file)
@@ -110,6 +110,27 @@ public class ApplicationsStateTest {
     }
 
     @Test
+    public void testPhotosFilterAcceptsFilter() {
+        mEntry.info.category = ApplicationInfo.CATEGORY_IMAGE;
+
+        assertThat(ApplicationsState.FILTER_PHOTOS.filterApp(mEntry)).isTrue();
+    }
+
+    @Test
+    public void testPhotosFilterRejectsNotPhotos() {
+        mEntry.info.category = ApplicationInfo.CATEGORY_VIDEO;
+
+        assertThat(ApplicationsState.FILTER_PHOTOS.filterApp(mEntry)).isFalse();
+    }
+
+    @Test
+    public void testPhotosFilterRejectsDefaultCategory() {
+        mEntry.info.category = ApplicationInfo.CATEGORY_UNDEFINED;
+
+        assertThat(ApplicationsState.FILTER_PHOTOS.filterApp(mEntry)).isFalse();
+    }
+
+    @Test
     public void testDownloadAndLauncherAndInstantAcceptsCorrectApps() {
         // should include instant apps
         mEntry.isHomeApp = false;
index a287254..1d6e76f 100644 (file)
@@ -4282,6 +4282,11 @@ message MetricsEvent {
     // the app transition.
     APP_TRANSITION_REPORTED_DRAWN_MS = 1091;
 
+    // OPEN: Settings > Storage > Photos & Videos
+    // CATEGORY: SETTINGS
+    // OS: O MR
+    APPLICATIONS_STORAGE_PHOTOS = 1092;
+
     // Add new aosp constants above this line.
     // END OF AOSP CONSTANTS
   }