Make SF Hint Session safety margin adjustable with a debug prop

Bug: 271016792
Test: manual
Change-Id: I59615b90dc109285cd681b89ff80a569037c2992
diff --git a/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp b/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
index f05223c..36f71bb 100644
--- a/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
+++ b/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
@@ -219,7 +219,7 @@
         std::lock_guard lock(mPowerHalMutex);
         HalWrapper* const halWrapper = getPowerHal();
         if (halWrapper != nullptr) {
-            halWrapper->sendActualWorkDuration(*actualDuration + kTargetSafetyMargin,
+            halWrapper->sendActualWorkDuration(*actualDuration + sTargetSafetyMargin,
                                                TimePoint::now());
         }
     }
@@ -232,12 +232,11 @@
     }
 
     const std::optional<Duration> predictedDuration = estimateWorkDuration(true);
-
     if (predictedDuration.has_value()) {
         std::lock_guard lock(mPowerHalMutex);
         HalWrapper* const halWrapper = getPowerHal();
         if (halWrapper != nullptr) {
-            halWrapper->sendActualWorkDuration(*predictedDuration + kTargetSafetyMargin,
+            halWrapper->sendActualWorkDuration(*predictedDuration + sTargetSafetyMargin,
                                                TimePoint::now());
         }
     }
@@ -812,6 +811,10 @@
 const bool AidlPowerHalWrapper::sTraceHintSessionData =
         base::GetBoolProperty(std::string("debug.sf.trace_hint_sessions"), false);
 
+const Duration PowerAdvisor::sTargetSafetyMargin = std::chrono::microseconds(
+        base::GetIntProperty<int64_t>("debug.sf.hint_margin_us",
+                                      ticks<std::micro>(PowerAdvisor::kDefaultTargetSafetyMargin)));
+
 PowerAdvisor::HalWrapper* PowerAdvisor::getPowerHal() {
     if (!mHasHal) {
         return nullptr;