From fd82752694e8d02d075036175a0b622654bd60f0 Mon Sep 17 00:00:00 2001 From: Daniel Nishi Date: Fri, 10 Mar 2017 15:05:12 -0800 Subject: [PATCH] Count legacy games as games in Storage view. The old Games flag was being ignored for categorization. This caused the very few games which used the flag to be miscategorized as "Other apps." Change-Id: Ib8650d1c43579bc1698576c09c884e5a7bc4626d Fixes: 36109122 Test: Settings robotest --- .../deviceinfo/storage/StorageAsyncLoader.java | 5 +++++ .../deviceinfo/storage/StorageAsyncLoaderTest.java | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java index f54c685730d..5176e099b90 100644 --- a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java +++ b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java @@ -98,6 +98,11 @@ public class StorageAsyncLoader result.musicAppsSize += attributedAppSizeInBytes; break; default: + // The deprecated game flag does not set the category. + if ((app.flags & ApplicationInfo.FLAG_IS_GAME) != 0) { + result.gamesSize += attributedAppSizeInBytes; + break; + } result.otherAppsSize += attributedAppSizeInBytes; break; } diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java index 10ba293d457..c83a5940135 100644 --- a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java +++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java @@ -104,6 +104,19 @@ public class StorageAsyncLoaderTest { assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(0); } + @Test + public void testLegacyGamesAreFiltered() throws Exception { + ApplicationInfo info = + addPackage(PACKAGE_NAME_1, 0, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED); + info.flags = ApplicationInfo.FLAG_IS_GAME; + + SparseArray result = mLoader.loadInBackground(); + + assertThat(result.size()).isEqualTo(1); + assertThat(result.get(PRIMARY_USER_ID).gamesSize).isEqualTo(11L); + assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(0); + } + @Test public void testCacheIsIgnored() throws Exception { addPackage(PACKAGE_NAME_1, 100, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED);