Make sendHint private in platform

 * Convert PerformanceHintManager sendHint to a private API
 * Have HWUI depend on private implementation

Bug: b/261640114
Test: atest PerformanceHintNativeTestCases
Test: atest FrameworksCoreTests:android.os.PerformanceHintManagerTest

Change-Id: Ic65eef1fbd1c26040e86ddf3cf7c59581fee4374
diff --git a/core/api/current.txt b/core/api/current.txt
index f26f8399..2e5c866 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -32329,12 +32329,7 @@
   public static class PerformanceHintManager.Session implements java.io.Closeable {
     method public void close();
     method public void reportActualWorkDuration(long);
-    method public void sendHint(int);
     method public void updateTargetWorkDuration(long);
-    field public static final int CPU_LOAD_DOWN = 1; // 0x1
-    field public static final int CPU_LOAD_RESET = 2; // 0x2
-    field public static final int CPU_LOAD_RESUME = 3; // 0x3
-    field public static final int CPU_LOAD_UP = 0; // 0x0
   }
 
   public final class PersistableBundle extends android.os.BaseBundle implements java.lang.Cloneable android.os.Parcelable {
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 002032a..1f294e0 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1835,6 +1835,14 @@
     method public static java.io.File getFile(java.io.FileDescriptor) throws java.io.IOException;
   }
 
+  public static class PerformanceHintManager.Session implements java.io.Closeable {
+    method public void sendHint(int);
+    field public static final int CPU_LOAD_DOWN = 1; // 0x1
+    field public static final int CPU_LOAD_RESET = 2; // 0x2
+    field public static final int CPU_LOAD_RESUME = 3; // 0x3
+    field public static final int CPU_LOAD_UP = 0; // 0x0
+  }
+
   public final class PowerManager {
     method public boolean areAutoPowerSaveModesEnabled();
     method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_LOW_POWER_STANDBY, android.Manifest.permission.DEVICE_POWER}) public void forceLowPowerStandbyActive(boolean);
diff --git a/core/java/android/os/PerformanceHintManager.java b/core/java/android/os/PerformanceHintManager.java
index 86135bc..85d6d83 100644
--- a/core/java/android/os/PerformanceHintManager.java
+++ b/core/java/android/os/PerformanceHintManager.java
@@ -20,6 +20,7 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.SystemService;
+import android.annotation.TestApi;
 import android.content.Context;
 
 import com.android.internal.util.Preconditions;
@@ -113,24 +114,36 @@
         * This hint indicates a sudden increase in CPU workload intensity. It means
         * that this hint session needs extra CPU resources immediately to meet the
         * target duration for the current work cycle.
+        *
+        * @hide
         */
+        @TestApi
         public static final int CPU_LOAD_UP = 0;
         /**
         * This hint indicates a decrease in CPU workload intensity. It means that
         * this hint session can reduce CPU resources and still meet the target duration.
+        *
+        * @hide
         */
+        @TestApi
         public static final int CPU_LOAD_DOWN = 1;
-        /*
+        /**
         * This hint indicates an upcoming CPU workload that is completely changed and
         * unknown. It means that the hint session should reset CPU resources to a known
         * baseline to prepare for an arbitrary load, and must wake up if inactive.
+        *
+        * @hide
         */
+        @TestApi
         public static final int CPU_LOAD_RESET = 2;
-        /*
+        /**
         * This hint indicates that the most recent CPU workload is resuming after a
         * period of inactivity. It means that the hint session should allocate similar
         * CPU resources to what was used previously, and must wake up if inactive.
+        *
+        * @hide
         */
+        @TestApi
         public static final int CPU_LOAD_RESUME = 3;
 
         /** @hide */
@@ -196,7 +209,10 @@
          * Sends performance hints to inform the hint session of changes in the workload.
          *
          * @param hint The hint to send to the session.
+         *
+         * @hide
          */
+        @TestApi
         public void sendHint(@Hint int hint) {
             Preconditions.checkArgumentNonNegative(hint, "the hint ID should be at least"
                     + " zero.");
diff --git a/libs/hwui/renderthread/HintSessionWrapper.cpp b/libs/hwui/renderthread/HintSessionWrapper.cpp
index edacef0..94c9d94 100644
--- a/libs/hwui/renderthread/HintSessionWrapper.cpp
+++ b/libs/hwui/renderthread/HintSessionWrapper.cpp
@@ -17,6 +17,7 @@
 #include "HintSessionWrapper.h"
 
 #include <dlfcn.h>
+#include <private/performance_hint_private.h>
 #include <utils/Log.h>
 
 #include <vector>
diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt
index 9b0f020..4e6a0c5 100644
--- a/native/android/libandroid.map.txt
+++ b/native/android/libandroid.map.txt
@@ -330,7 +330,6 @@
     APerformanceHint_updateTargetWorkDuration; # introduced=Tiramisu
     APerformanceHint_reportActualWorkDuration; # introduced=Tiramisu
     APerformanceHint_closeSession; # introduced=Tiramisu
-    APerformanceHint_sendHint; # introduced=UpsideDownCake
   local:
     *;
 };
@@ -338,6 +337,7 @@
 LIBANDROID_PLATFORM {
   global:
     APerformanceHint_setIHintManagerForTesting;
+    APerformanceHint_sendHint;
     extern "C++" {
         ASurfaceControl_registerSurfaceStatsListener*;
         ASurfaceControl_unregisterSurfaceStatsListener*;
diff --git a/native/android/performance_hint.cpp b/native/android/performance_hint.cpp
index 40eb507..95b7513 100644
--- a/native/android/performance_hint.cpp
+++ b/native/android/performance_hint.cpp
@@ -263,14 +263,14 @@
     return session->reportActualWorkDuration(actualDurationNanos);
 }
 
-int APerformanceHint_sendHint(APerformanceHintSession* session, int32_t hint) {
-    return session->sendHint(hint);
-}
-
 void APerformanceHint_closeSession(APerformanceHintSession* session) {
     delete session;
 }
 
+int APerformanceHint_sendHint(void* session, int32_t hint) {
+    return reinterpret_cast<APerformanceHintSession*>(session)->sendHint(hint);
+}
+
 void APerformanceHint_setIHintManagerForTesting(void* iManager) {
     delete gHintManagerForTesting;
     gHintManagerForTesting = nullptr;