Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db02e05a authored by Kunal Malhotra's avatar Kunal Malhotra Committed by Automerger Merge Worker
Browse files

Merge "Adding in hook to FGS metrics module in MediaSessionRecord." into...

Merge "Adding in hook to FGS metrics module in MediaSessionRecord." into udc-dev am: bb99a72e am: 160f8991

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21529443



Change-Id: I12a75ec2a977c4f2b3168570527ec8b58fe6a1ab
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a26ee43b 160f8991
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -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 {