summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pascal Muetschard <pmuetschard@google.com> 2022-08-23 12:40:59 +0200
committer Pascal Muetschard <pmuetschard@google.com> 2022-08-23 17:40:56 +0200
commit51f38fb6f3858b1431eb63586079a4550795721c (patch)
treea71f0435a7e2c1e8d9ced6272c9c7803de369221
parentacf735b3abaa513e3b8846750a3d864d6a00b787 (diff)
Check the DeviceConfig permission early.
This causes the permission error to be thrown from the thread that creates the JankMonitor rather than some background thread. This makes it easier to debug the permission error and can prevent crashes due to unhandled exceptions from background threads. Change-Id: I942c705342962ce6e15ae5cd6041dc85f6f83a95
-rw-r--r--core/java/com/android/internal/jank/InteractionJankMonitor.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/java/com/android/internal/jank/InteractionJankMonitor.java b/core/java/com/android/internal/jank/InteractionJankMonitor.java
index 72de78c148f8..6e8a0c734cac 100644
--- a/core/java/com/android/internal/jank/InteractionJankMonitor.java
+++ b/core/java/com/android/internal/jank/InteractionJankMonitor.java
@@ -87,6 +87,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.UiThread;
import android.annotation.WorkerThread;
+import android.app.ActivityThread;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
@@ -402,6 +403,11 @@ public class InteractionJankMonitor {
*/
@VisibleForTesting
public InteractionJankMonitor(@NonNull HandlerThread worker) {
+ // Check permission early.
+ DeviceConfig.enforceReadPermission(
+ ActivityThread.currentApplication().getApplicationContext(),
+ DeviceConfig.NAMESPACE_INTERACTION_JANK_MONITOR);
+
mRunningTrackers = new SparseArray<>();
mTimeoutActions = new SparseArray<>();
mWorker = worker;