From 5dd487476611ad04aa9160d0d04641f221c55c43 Mon Sep 17 00:00:00 2001 From: Peiyong Lin Date: Wed, 12 May 2021 00:35:47 +0000 Subject: [PATCH] Reduce log spam in GameManagerService. Since it is possible that DeviceConfig returns packages that haven't been installed, the query will fail in those cases. Avoid logging exception in this case. Minor: clean up some logs. Fixes: b/187741764 Test: atest GameManagerServiceTests Change-Id: I08a48da82761b5a902a09f18a8b88eb0281f892b --- .../com/android/server/app/GameManagerService.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/app/GameManagerService.java b/services/core/java/com/android/server/app/GameManagerService.java index d2c6c6c620dd9..76941d3eee894 100644 --- a/services/core/java/com/android/server/app/GameManagerService.java +++ b/services/core/java/com/android/server/app/GameManagerService.java @@ -268,7 +268,8 @@ public final class GameManagerService extends IGameManagerService.Stub { mAllowDownscale = true; } } catch (PackageManager.NameNotFoundException e) { - Slog.e(TAG, "Failed to get package metadata", e); + // Not all packages are installed, hence ignore those that are not installed yet. + Slog.v(TAG, "Failed to get package metadata"); } final String configString = DeviceConfig.getProperty( DeviceConfig.NAMESPACE_GAME_OVERLAY, packageName); @@ -509,9 +510,8 @@ public final class GameManagerService extends IGameManagerService.Stub { final ApplicationInfo applicationInfo = mPackageManager .getApplicationInfoAsUser(packageName, PackageManager.MATCH_ALL, userId); if (applicationInfo.category != ApplicationInfo.CATEGORY_GAME) { - Slog.e(TAG, "Ignoring attempt to get the Game Mode for '" + packageName - + "' which is not categorized as a game: applicationInfo.flags = " - + applicationInfo.flags + ", category = " + applicationInfo.category); + // The game mode for applications that are not identified as game is always + // UNSUPPORTED. See {@link PackageManager#setApplicationCategoryHint(String, int)} return GameManager.GAME_MODE_UNSUPPORTED; } } catch (PackageManager.NameNotFoundException e) { @@ -549,9 +549,8 @@ public final class GameManagerService extends IGameManagerService.Stub { final ApplicationInfo applicationInfo = mPackageManager .getApplicationInfoAsUser(packageName, PackageManager.MATCH_ALL, userId); if (applicationInfo.category != ApplicationInfo.CATEGORY_GAME) { - Slog.e(TAG, "Ignoring attempt to set the Game Mode for '" + packageName - + "' which is not categorized as a game: applicationInfo.flags = " - + applicationInfo.flags + ", category = " + applicationInfo.category); + // Ignore attempt to set the game mode for applications that are not identified + // as game. See {@link PackageManager#setApplicationCategoryHint(String, int)} return; } } catch (PackageManager.NameNotFoundException e) {