From 7e65c3fab5417c9dec410956a5bba0ef468f781d Mon Sep 17 00:00:00 2001 From: Hui Yu Date: Tue, 16 Apr 2019 17:03:16 -0700 Subject: [PATCH] Dump stacktrace of native process when timeout. When task in SystemServerInitThreadPool timeouts, in addition to dumping stacktrace of system_process, also dump stacktrace of interested native processes. Add android.hardware.biometrics.face@1.0::IBiometricsFace to the list of native processes. Bug: 128928718, 130427743 Test: Force a task to sleep for 30 seconds, the anr file generated has stacktrace of native processes. Change-Id: Ia702eb495aa3c3e5703de103f824a5417fbbbf4a --- .../server/SystemServerInitThreadPool.java | 4 +-- .../java/com/android/server/Watchdog.java | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/services/core/java/com/android/server/SystemServerInitThreadPool.java b/services/core/java/com/android/server/SystemServerInitThreadPool.java index 6bb3200f7cc10..1ce655618028b 100644 --- a/services/core/java/com/android/server/SystemServerInitThreadPool.java +++ b/services/core/java/com/android/server/SystemServerInitThreadPool.java @@ -120,7 +120,7 @@ public class SystemServerInitThreadPool { private static void dumpStackTraces() { final ArrayList pids = new ArrayList<>(); pids.add(Process.myPid()); - ActivityManagerService.dumpStackTraces( - pids, null, null, null); + ActivityManagerService.dumpStackTraces(pids, null, null, + Watchdog.getInterestingNativePids()); } } diff --git a/services/core/java/com/android/server/Watchdog.java b/services/core/java/com/android/server/Watchdog.java index afcf954371ccc..cc3b43adcacd0 100644 --- a/services/core/java/com/android/server/Watchdog.java +++ b/services/core/java/com/android/server/Watchdog.java @@ -101,17 +101,18 @@ public class Watchdog extends Thread { }; public static final List HAL_INTERFACES_OF_INTEREST = Arrays.asList( - "android.hardware.audio@2.0::IDevicesFactory", - "android.hardware.audio@4.0::IDevicesFactory", - "android.hardware.bluetooth@1.0::IBluetoothHci", - "android.hardware.camera.provider@2.4::ICameraProvider", - "android.hardware.graphics.allocator@2.0::IAllocator", - "android.hardware.graphics.composer@2.1::IComposer", - "android.hardware.health@2.0::IHealth", - "android.hardware.media.omx@1.0::IOmx", - "android.hardware.media.omx@1.0::IOmxStore", - "android.hardware.sensors@1.0::ISensors", - "android.hardware.vr@1.0::IVr" + "android.hardware.audio@2.0::IDevicesFactory", + "android.hardware.audio@4.0::IDevicesFactory", + "android.hardware.bluetooth@1.0::IBluetoothHci", + "android.hardware.camera.provider@2.4::ICameraProvider", + "android.hardware.graphics.allocator@2.0::IAllocator", + "android.hardware.graphics.composer@2.1::IComposer", + "android.hardware.health@2.0::IHealth", + "android.hardware.media.omx@1.0::IOmx", + "android.hardware.media.omx@1.0::IOmxStore", + "android.hardware.sensors@1.0::ISensors", + "android.hardware.vr@1.0::IVr", + "android.hardware.biometrics.face@1.0::IBiometricsFace" ); static Watchdog sWatchdog; @@ -396,7 +397,7 @@ public class Watchdog extends Thread { return builder.toString(); } - private ArrayList getInterestingHalPids() { + private static ArrayList getInterestingHalPids() { try { IServiceManager serviceManager = IServiceManager.getService(); ArrayList dump = @@ -419,7 +420,7 @@ public class Watchdog extends Thread { } } - private ArrayList getInterestingNativePids() { + static ArrayList getInterestingNativePids() { ArrayList pids = getInterestingHalPids(); int[] nativePids = Process.getPidsForCommands(NATIVE_STACKS_OF_INTEREST);