From 8cb6c27e8e2f171a0d9f9c4580092ebc4ce562fa Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Wed, 14 Apr 2021 21:07:43 +0800 Subject: [PATCH] Storage Settings Apps category shows image/video/audio APPs Shows image/video/audio APPs in APPs category when there is a file browser for Images/Videos/Audios category. Bug: 170918505 Test: atest ApplicationsStateTest Change-Id: Iece8596c7ed19b0a195b929297271b1e9a472021 --- .../applications/ApplicationsState.java | 18 ++++++++++++ .../applications/ApplicationsStateTest.java | 28 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java index f180776bbe935..f046f06cc691d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java @@ -2027,6 +2027,7 @@ public class ApplicationsState { } }; + /* For the Storage Settings which shows category of app types. */ public static final AppFilter FILTER_OTHER_APPS = new AppFilter() { @Override @@ -2046,4 +2047,21 @@ public class ApplicationsState { return !isCategorized; } }; + + /* For the Storage Settings which shows category of file types. */ + public static final AppFilter FILTER_APPS_EXCEPT_GAMES = + new AppFilter() { + @Override + public void init() { + } + + @Override + public boolean filterApp(AppEntry entry) { + boolean isCategorized; + synchronized (entry) { + isCategorized = FILTER_GAMES.filterApp(entry); + } + return !isCategorized; + } + }; } diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/applications/ApplicationsStateTest.java b/packages/SettingsLib/tests/integ/src/com/android/settingslib/applications/ApplicationsStateTest.java index d9ac262f44146..f1e1e7d920ccc 100644 --- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/applications/ApplicationsStateTest.java +++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/applications/ApplicationsStateTest.java @@ -137,6 +137,34 @@ public class ApplicationsStateTest { assertThat(ApplicationsState.FILTER_PHOTOS.filterApp(mEntry)).isFalse(); } + @Test + public void testAppsExceptGamesFilterRejectsGame() { + mEntry.info.category = ApplicationInfo.CATEGORY_GAME; + + assertThat(ApplicationsState.FILTER_APPS_EXCEPT_GAMES.filterApp(mEntry)).isFalse(); + } + + @Test + public void testAppsExceptGamesFilterAcceptsImage() { + mEntry.info.category = ApplicationInfo.CATEGORY_IMAGE; + + assertThat(ApplicationsState.FILTER_APPS_EXCEPT_GAMES.filterApp(mEntry)).isTrue(); + } + + @Test + public void testAppsExceptGamesFilterAcceptsVideo() { + mEntry.info.category = ApplicationInfo.CATEGORY_VIDEO; + + assertThat(ApplicationsState.FILTER_APPS_EXCEPT_GAMES.filterApp(mEntry)).isTrue(); + } + + @Test + public void testAppsExceptGamesFilterAcceptsAudio() { + mEntry.info.category = ApplicationInfo.CATEGORY_AUDIO; + + assertThat(ApplicationsState.FILTER_APPS_EXCEPT_GAMES.filterApp(mEntry)).isTrue(); + } + @Test public void testDownloadAndLauncherAndInstantAcceptsCorrectApps() { // should include instant apps