From 654444a7994cf65365b16d2bd3a8d0094fb57359 Mon Sep 17 00:00:00 2001 From: Austin Borger Date: Thu, 30 Mar 2023 18:36:26 -0700 Subject: [PATCH] GameManagerService: Use the default UidObserver implementation. A class which overrides IUidObserver.Stub with empty callback implementations was added in change I2ff1e868586861e4dcd6586ad22139ba84eaf39c to simplify BroadcastQueue interface complexity. Using this default implementation will mean less churn when new callbacks are added to IUidObserver, or existing callback method signatures are changed. Bug: 274486653 Test: Presubmit, smoke test on cuttlefish. Change-Id: Ief2d65e23e0967f6d4d9812af41f433dede9af3d --- services/art-profile | 8 ++++---- .../server/app/GameManagerService.java | 20 ++++--------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/services/art-profile b/services/art-profile index c2ef53cb3caaf..64c7f3d249c7c 100644 --- a/services/art-profile +++ b/services/art-profile @@ -2371,10 +2371,10 @@ HSPLcom/android/server/am/UserController;->unsafeConvertIncomingUser(I)I HSPLcom/android/server/am/UserController;->updateStartedUserArrayLU()V HSPLcom/android/server/am/UserState;->(Landroid/os/UserHandle;)V HSPLcom/android/server/app/GameManagerService$LocalService;->getResolutionScalingFactor(Ljava/lang/String;I)F -HSPLcom/android/server/app/GameManagerService$UidObserver$$ExternalSyntheticLambda0;->(Lcom/android/server/app/GameManagerService$UidObserver;I)V -HSPLcom/android/server/app/GameManagerService$UidObserver$$ExternalSyntheticLambda0;->test(Ljava/lang/Object;)Z -HSPLcom/android/server/app/GameManagerService$UidObserver;->disableGameMode(I)V+]Ljava/util/Set;Ljava/util/HashSet;]Landroid/os/PowerManagerInternal;Lcom/android/server/power/PowerManagerService$LocalService; -HSPLcom/android/server/app/GameManagerService$UidObserver;->onUidStateChanged(IIJI)V+]Lcom/android/server/app/GameManagerService$UidObserver;Lcom/android/server/app/GameManagerService$UidObserver;]Ljava/util/stream/Stream;Ljava/util/stream/ReferencePipeline$Head;]Landroid/content/Context;Landroid/app/ContextImpl;]Landroid/content/pm/PackageManager;Landroid/app/ApplicationPackageManager;]Landroid/os/PowerManagerInternal;Lcom/android/server/power/PowerManagerService$LocalService;]Ljava/util/Set;Ljava/util/HashSet; +HSPLcom/android/server/app/GameManagerService$MyUidObserver$$ExternalSyntheticLambda0;->(Lcom/android/server/app/GameManagerService$MyUidObserver;I)V +HSPLcom/android/server/app/GameManagerService$MyUidObserver$$ExternalSyntheticLambda0;->test(Ljava/lang/Object;)Z +HSPLcom/android/server/app/GameManagerService$MyUidObserver;->disableGameMode(I)V+]Ljava/util/Set;Ljava/util/HashSet;]Landroid/os/PowerManagerInternal;Lcom/android/server/power/PowerManagerService$LocalService; +HSPLcom/android/server/app/GameManagerService$MyUidObserver;->onUidStateChanged(IIJI)V+]Lcom/android/server/app/GameManagerService$MyUidObserver;Lcom/android/server/app/GameManagerService$MyUidObserver;]Ljava/util/stream/Stream;Ljava/util/stream/ReferencePipeline$Head;]Landroid/content/Context;Landroid/app/ContextImpl;]Landroid/content/pm/PackageManager;Landroid/app/ApplicationPackageManager;]Landroid/os/PowerManagerInternal;Lcom/android/server/power/PowerManagerService$LocalService;]Ljava/util/Set;Ljava/util/HashSet; HSPLcom/android/server/app/GameManagerService;->-$$Nest$fgetmContext(Lcom/android/server/app/GameManagerService;)Landroid/content/Context; HSPLcom/android/server/app/GameManagerService;->-$$Nest$fgetmForegroundGameUids(Lcom/android/server/app/GameManagerService;)Ljava/util/Set; HSPLcom/android/server/app/GameManagerService;->-$$Nest$fgetmUidObserverLock(Lcom/android/server/app/GameManagerService;)Ljava/lang/Object; diff --git a/services/core/java/com/android/server/app/GameManagerService.java b/services/core/java/com/android/server/app/GameManagerService.java index 893c8b5d26984..d369af608d31e 100644 --- a/services/core/java/com/android/server/app/GameManagerService.java +++ b/services/core/java/com/android/server/app/GameManagerService.java @@ -40,8 +40,8 @@ import android.app.GameModeInfo; import android.app.GameState; import android.app.IGameManagerService; import android.app.IGameModeListener; -import android.app.IUidObserver; import android.app.StatsManager; +import android.app.UidObserver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -169,7 +169,7 @@ public final class GameManagerService extends IGameManagerService.Stub { private final Object mUidObserverLock = new Object(); @VisibleForTesting @Nullable - final UidObserver mUidObserver; + final MyUidObserver mUidObserver; @GuardedBy("mUidObserverLock") private final Set mForegroundGameUids = new HashSet<>(); @@ -209,7 +209,7 @@ public final class GameManagerService extends IGameManagerService.Stub { } else { mGameServiceController = null; } - mUidObserver = new UidObserver(); + mUidObserver = new MyUidObserver(); try { ActivityManager.getService().registerUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE, @@ -2143,10 +2143,7 @@ public final class GameManagerService extends IGameManagerService.Stub { */ private static native void nativeSetOverrideFrameRate(int uid, float frameRate); - final class UidObserver extends IUidObserver.Stub { - @Override - public void onUidIdle(int uid, boolean disabled) {} - + final class MyUidObserver extends UidObserver { @Override public void onUidGone(int uid, boolean disabled) { synchronized (mUidObserverLock) { @@ -2154,9 +2151,6 @@ public final class GameManagerService extends IGameManagerService.Stub { } } - @Override - public void onUidActive(int uid) {} - @Override public void onUidStateChanged(int uid, int procState, long procStateSeq, int capability) { synchronized (mUidObserverLock) { @@ -2197,11 +2191,5 @@ public final class GameManagerService extends IGameManagerService.Stub { mPowerManagerInternal.setPowerMode(Mode.GAME, false); } } - - @Override - public void onUidCachedChanged(int uid, boolean cached) {} - - @Override - public void onUidProcAdjChanged(int uid) {} } }