summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-12-03 02:19:03 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-12-03 02:19:03 +0000
commitbeed0e8077e95a4444bc244f08b28ba26e3f0aa3 (patch)
tree5adc01ce9805861cdfdac8b728109ba65236e52b
parent1d5b180a15dbfa780f96bade2f2a44cc1fd3b8d2 (diff)
parent83d1eda1c805c145d74f3e8197c10be6fae894f6 (diff)
Merge "Skip calling adpf session if it's null" into main
-rw-r--r--core/java/android/window/SystemPerformanceHinter.java6
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/performance/PerfHintController.kt12
2 files changed, 11 insertions, 7 deletions
diff --git a/core/java/android/window/SystemPerformanceHinter.java b/core/java/android/window/SystemPerformanceHinter.java
index cc2329fc47cb..f8899c5764aa 100644
--- a/core/java/android/window/SystemPerformanceHinter.java
+++ b/core/java/android/window/SystemPerformanceHinter.java
@@ -163,7 +163,6 @@ public class SystemPerformanceHinter {
// The active sessions
private final ArrayList<HighPerfSession> mActiveSessions = new ArrayList<>();
private final SurfaceControl.Transaction mTransaction;
- private final PerformanceHintManager mPerfHintManager;
private @Nullable PerformanceHintManager.Session mAdpfSession;
private @Nullable DisplayRootProvider mDisplayRootProvider;
@@ -184,7 +183,6 @@ public class SystemPerformanceHinter {
@Nullable DisplayRootProvider displayRootProvider,
@Nullable Supplier<SurfaceControl.Transaction> transactionSupplier) {
mDisplayRootProvider = displayRootProvider;
- mPerfHintManager = context.getSystemService(PerformanceHintManager.class);
mTransaction = transactionSupplier != null
? transactionSupplier.get()
: new SurfaceControl.Transaction();
@@ -273,7 +271,7 @@ public class SystemPerformanceHinter {
asyncTraceBegin(HINT_SF_EARLY_WAKEUP, Display.INVALID_DISPLAY);
}
}
- if (nowEnabled(oldGlobalFlags, newGlobalFlags, HINT_ADPF)) {
+ if (mAdpfSession != null && nowEnabled(oldGlobalFlags, newGlobalFlags, HINT_ADPF)) {
mAdpfSession.sendHint(PerformanceHintManager.Session.CPU_LOAD_UP);
if (isTraceEnabled) {
asyncTraceBegin(HINT_ADPF, Display.INVALID_DISPLAY);
@@ -323,7 +321,7 @@ public class SystemPerformanceHinter {
asyncTraceEnd(HINT_SF_EARLY_WAKEUP);
}
}
- if (nowDisabled(oldGlobalFlags, newGlobalFlags, HINT_ADPF)) {
+ if (mAdpfSession != null && nowDisabled(oldGlobalFlags, newGlobalFlags, HINT_ADPF)) {
mAdpfSession.sendHint(PerformanceHintManager.Session.CPU_LOAD_RESET);
if (isTraceEnabled) {
asyncTraceEnd(HINT_ADPF);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/performance/PerfHintController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/performance/PerfHintController.kt
index f7977f88006e..c655d86c3ece 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/performance/PerfHintController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/performance/PerfHintController.kt
@@ -45,9 +45,15 @@ class PerfHintController(private val mContext: Context,
private fun onInit() {
mShellCommandHandler.addDumpCallback(this::dump, this)
val perfHintMgr = mContext.getSystemService(PerformanceHintManager::class.java)
- val adpfSession = perfHintMgr!!.createHintSession(intArrayOf(Process.myTid()),
- TimeUnit.SECONDS.toNanos(1))
- hinter.setAdpfSession(adpfSession)
+ if (perfHintMgr != null) {
+ val adpfSession = perfHintMgr.createHintSession(
+ intArrayOf(Process.myTid()),
+ TimeUnit.SECONDS.toNanos(1)
+ )
+ if (adpfSession != null) {
+ hinter.setAdpfSession(adpfSession)
+ }
+ }
}
fun dump(pw: PrintWriter, prefix: String?) {