Send cached target duration when creating sessions

This fixes an issue where the default target duration was being sent
when re-creating sessions, after the true target duration was already
known. This caused the wrong value in PowerHAL, and no corrective update
was sent because the cached value never changed.

Bug: 301806277
Test: hwuitest
Change-Id: I80d90e855fce92264d8341aad78b19dc547b65f4
Merged-In: I80d90e855fce92264d8341aad78b19dc547b65f4
diff --git a/libs/hwui/renderthread/HintSessionWrapper.cpp b/libs/hwui/renderthread/HintSessionWrapper.cpp
index d1ebe6d..565da52 100644
--- a/libs/hwui/renderthread/HintSessionWrapper.cpp
+++ b/libs/hwui/renderthread/HintSessionWrapper.cpp
@@ -72,6 +72,7 @@
         mSessionValid = true;
         mHintSession = nullptr;
     }
+    mResetsSinceLastReport = 0;
 }
 
 bool HintSessionWrapper::init() {
@@ -111,10 +112,10 @@
 
     // Use a placeholder target value to initialize,
     // this will always be replaced elsewhere before it gets used
-    int64_t defaultTargetDurationNanos = 16666667;
+    int64_t targetDurationNanos =
+            mLastTargetWorkDuration == 0 ? kDefaultTargetDuration : mLastTargetWorkDuration;
     mHintSessionFuture = CommonPool::async([=, this, tids = std::move(tids)] {
-        return mBinding->createSession(manager, tids.data(), tids.size(),
-                                       defaultTargetDurationNanos);
+        return mBinding->createSession(manager, tids.data(), tids.size(), targetDurationNanos);
     });
     return false;
 }