Add resource observer service

Add resource observer service so that clients can
register listeners to receive resource status change.

This is needed by transcoding service to properly
handle media resource lost. Resource lost itself is
detected by exceptions on MediaCodec, however in
order to resume the service, a notification from
ResourceManager is needed.

Note that the observer service is built as a separate
service so that client can access it without requesting
full resourcemanager service. It also allows us to
list the observer service interface as a stable interface
without having to lock down resourcemanager interface.

bug: 168307955
bug: 154733526

test:
- unit testing in this CL;
- manually tested using the service from media.transcoding
  and got codec updates and "adb shell dumpsys"

Change-Id: I8028c605600a40c1aa2c89850ef877a5bf1d0c09
diff --git a/services/mediaresourcemanager/ResourceManagerService.h b/services/mediaresourcemanager/ResourceManagerService.h
index 49c247e..2b3dab3 100644
--- a/services/mediaresourcemanager/ResourceManagerService.h
+++ b/services/mediaresourcemanager/ResourceManagerService.h
@@ -33,6 +33,7 @@
 
 class DeathNotifier;
 class ResourceManagerService;
+class ResourceObserverService;
 class ServiceLog;
 struct ProcessInfoInterface;
 
@@ -95,6 +96,8 @@
             const sp<ProcessInfoInterface> &processInfo,
             const sp<SystemCallbackInterface> &systemResource);
     virtual ~ResourceManagerService();
+    void setObserverService(
+            const std::shared_ptr<ResourceObserverService>& observerService);
 
     // IResourceManagerService interface
     Status config(const std::vector<MediaResourcePolicyParcel>& policies) override;
@@ -180,6 +183,7 @@
     int32_t mCpuBoostCount;
     ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
     std::map<int, int> mOverridePidMap;
+    std::shared_ptr<ResourceObserverService> mObserverService;
 };
 
 // ----------------------------------------------------------------------------