RM6785: power-libperfmgr: ADPF: support sending power hint

Send a hint only when the system can support the hint.

Bug: 243025173
Test: PtsUiBench & CUJ
Change-Id: If56d0c22f8dd61f5fe27ba79f08f2963269abe41
Merged-In: If56d0c22f8dd61f5fe27ba79f08f2963269abe41
diff --git a/aidl/power-libperfmgr/PowerHintSession.cpp b/aidl/power-libperfmgr/PowerHintSession.cpp
index 856fe6d..a6b57e4 100644
--- a/aidl/power-libperfmgr/PowerHintSession.cpp
+++ b/aidl/power-libperfmgr/PowerHintSession.cpp
@@ -179,6 +179,15 @@
     }
 }
 
+void PowerHintSession::tryToSendPowerHint(std::string hint) {
+    if (!mSupportedHints[hint].has_value()) {
+        mSupportedHints[hint] = HintManager::GetInstance()->IsHintSupported(hint);
+    }
+    if (mSupportedHints[hint].value()) {
+        HintManager::GetInstance()->DoHint(hint);
+    }
+}
+
 int PowerHintSession::setSessionUclampMin(int32_t min) {
     {
         std::lock_guard<std::mutex> guard(mSessionLock);
diff --git a/aidl/power-libperfmgr/PowerHintSession.h b/aidl/power-libperfmgr/PowerHintSession.h
index 864d28f..2a10b34 100644
--- a/aidl/power-libperfmgr/PowerHintSession.h
+++ b/aidl/power-libperfmgr/PowerHintSession.h
@@ -120,6 +120,7 @@
   private:
     void updateUniveralBoostMode();
     int setSessionUclampMin(int32_t min);
+    void tryToSendPowerHint(std::string hint);
     std::string getIdString() const;
     AppHintDesc *mDescriptor = nullptr;
     sp<StaleTimerHandler> mStaleTimerHandler;
@@ -132,6 +133,9 @@
     int64_t mLastStartedTimeNs;
     int64_t mLastDurationNs;
     int64_t mWorkPeriodNs;
+
+    // To cache the status of whether ADPF hints are supported.
+    std::unordered_map<std::string, std::optional<bool>> mSupportedHints;
 };
 
 }  // namespace pixel