diff options
-rw-r--r-- | core/java/android/window/SystemPerformanceHinter.java | 6 | ||||
-rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/performance/PerfHintController.kt | 12 |
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?) { |