From d61ee31779c33588fd27327d60485037f255cc46 Mon Sep 17 00:00:00 2001 From: Andy Yu Date: Tue, 25 Jan 2022 21:27:35 -0800 Subject: [PATCH] Add dumpsys to GameManagerService Implement dump() for GameManagerService that enables output information to dumpsys. Currently there is only one option that outputs all installed games' configurations. Bug: b/204322735 Test: m && flash adb shell dumpsys game Change-Id: I017238969c3d7680cebcd6da5fb8a8e175c844fd --- .../server/app/GameManagerService.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/app/GameManagerService.java b/services/core/java/com/android/server/app/GameManagerService.java index 417ebcdbcef22..b27b565f1d7b6 100644 --- a/services/core/java/com/android/server/app/GameManagerService.java +++ b/services/core/java/com/android/server/app/GameManagerService.java @@ -86,6 +86,7 @@ import com.android.server.SystemService.TargetUser; import com.android.server.app.GameManagerService.GamePackageConfiguration.GameModeConfiguration; import java.io.FileDescriptor; +import java.io.PrintWriter; import java.util.List; /** @@ -148,6 +149,29 @@ public final class GameManagerService extends IGameManagerService.Stub { new GameManagerShellCommand().exec(this, in, out, err, args, callback, result); } + @Override + public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { + if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) + != PackageManager.PERMISSION_GRANTED) { + writer.println("Permission Denial: can't dump GameManagerService from from pid=" + + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + + " without permission " + android.Manifest.permission.DUMP); + return; + } + if (args == null || args.length == 0) { + writer.println("*Dump GameManagerService*"); + dumpAllGameConfigs(writer); + } + } + + private void dumpAllGameConfigs(PrintWriter pw) { + final int userId = ActivityManager.getCurrentUser(); + String[] packageList = getInstalledGamePackageNames(userId); + for (final String packageName : packageList) { + pw.println(getInterventionList(packageName)); + } + } + class SettingsHandler extends Handler { SettingsHandler(Looper looper) { @@ -1236,8 +1260,7 @@ public final class GameManagerService extends IGameManagerService.Stub { .append(packageName); return listStrSb.toString(); } - listStrSb.append("\nPackage name: ") - .append(packageName) + listStrSb.append("\n") .append(packageConfig.toString()); return listStrSb.toString(); }