diff options
| author | 2023-03-27 18:27:51 +0000 | |
|---|---|---|
| committer | 2023-03-27 18:27:51 +0000 | |
| commit | bb99a72e8cc1c2d97d130df41d7ff50af2f54c4b (patch) | |
| tree | 634e390d956fff109f589e849c8e71671196b9d2 | |
| parent | 5998d94ed8904eb6011d61e069d815f0d0602f76 (diff) | |
| parent | 80d7da2c072b87e8960481d0c28fcf8e04e0ebaa (diff) | |
Merge "Adding in hook to FGS metrics module in MediaSessionRecord." into udc-dev
| -rw-r--r-- | services/core/java/com/android/server/media/MediaSessionRecord.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java index 16155a01d73a..5ea2ca4fc2f2 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecord.java +++ b/services/core/java/com/android/server/media/MediaSessionRecord.java @@ -17,6 +17,8 @@ package com.android.server.media; import android.annotation.Nullable; +import android.app.ActivityManager; +import android.app.ActivityManagerInternal; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; @@ -55,6 +57,8 @@ import android.util.EventLog; import android.util.Log; import android.view.KeyEvent; +import com.android.server.LocalServices; + import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; @@ -422,6 +426,13 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR */ @Override public void close() { + // Log the session's active state + // to measure usage of foreground service resources + int callingUid = Binder.getCallingUid(); + int callingPid = Binder.getCallingPid(); + LocalServices.getService(ActivityManagerInternal.class) + .logFgsApiEnd(ActivityManager.FOREGROUND_SERVICE_API_TYPE_MEDIA_PLAYBACK, + callingUid, callingPid); synchronized (mLock) { if (mDestroyed) { return; @@ -884,8 +895,22 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR @Override public void setActive(boolean active) throws RemoteException { + // Log the session's active state + // to measure usage of foreground service resources + int callingUid = Binder.getCallingUid(); + int callingPid = Binder.getCallingPid(); + if (active) { + LocalServices.getService(ActivityManagerInternal.class) + .logFgsApiBegin(ActivityManager.FOREGROUND_SERVICE_API_TYPE_MEDIA_PLAYBACK, + callingUid, callingPid); + } else { + LocalServices.getService(ActivityManagerInternal.class) + .logFgsApiEnd(ActivityManager.FOREGROUND_SERVICE_API_TYPE_MEDIA_PLAYBACK, + callingUid, callingPid); + } + mIsActive = active; - final long token = Binder.clearCallingIdentity(); + long token = Binder.clearCallingIdentity(); try { mService.onSessionActiveStateChanged(MediaSessionRecord.this); } finally { |