Report video battery on/off from mediaserver

    We can't track video stats accurately if it's reported from
    app side MediaCodec. If the app dies, video stats get stuck
    in On state forever. This can be easily triggered by forcefully
    kill and app that uses MediaCodec from app side (instead of
    through mediaserver's Recorder or Player service), eg.
    launch GoogleCamera app and switch to Video tab, and kill it
    from adb shell.

    In order to track MediaCodec usage from apps we need to move
    the battery stats reporting from MediaCodec into ResourceManager.

bug: 138381810
test:
1. test if app uses MediaCodec directly and it dies off, the video
   off is received: launch GoogleCamera app, swipe to Video tab,
   "dumpsys batterystats --history" and see +video; now adb shell
   kill GoogleCamera, dumpsys should show -video.
2. test app that uses MediaCodec through mediaserver: use Chrome
   (which uses MediaPlayer) to play some website with video, kills
   Chrome from adb shell, and check -video is received.
   In anycase it shouldn't stuck in On state.
3. ResourceManagerService_test

Change-Id: I164b31681c4e72e8cce02342641dbec14b8df374
(cherry picked from commit 47db2ff19c3ceb2d3b39ff9315a463984e55dec1)
diff --git a/services/mediaresourcemanager/ResourceManagerService.h b/services/mediaresourcemanager/ResourceManagerService.h
index 82d2a0b..741ef73 100644
--- a/services/mediaresourcemanager/ResourceManagerService.h
+++ b/services/mediaresourcemanager/ResourceManagerService.h
@@ -35,10 +35,12 @@
 
 struct ResourceInfo {
     int64_t clientId;
+    uid_t uid;
     sp<IResourceManagerClient> client;
     sp<IBinder::DeathRecipient> deathNotifier;
     Vector<MediaResource> resources;
     bool cpuBoost;
+    bool batteryNoted;
 };
 
 typedef Vector<ResourceInfo> ResourceInfos;
@@ -61,6 +63,7 @@
 
     virtual void addResource(
             int pid,
+            int uid,
             int64_t clientId,
             const sp<IResourceManagerClient> client,
             const Vector<MediaResource> &resources);