Merge "WatchDog: support dumping AIDL HALs" am: 4c0600b406
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1564415 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I1fa34ec1480e4ea584b4e5dc5c528d4168120d26
This commit is contained in:
@@ -287,6 +287,20 @@ public final class ServiceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get service debug info.
|
||||||
|
* @return an array of information for each service (like listServices, but with PIDs)
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static ServiceDebugInfo[] getServiceDebugInfo() {
|
||||||
|
try {
|
||||||
|
return getIServiceManager().getServiceDebugInfo();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "error in getServiceDebugInfo", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is only intended to be called when the process is first being brought
|
* This is only intended to be called when the process is first being brought
|
||||||
* up and bound by the activity manager. There is only one thread in the process
|
* up and bound by the activity manager. There is only one thread in the process
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ class ServiceManagerProxy implements IServiceManager {
|
|||||||
throw new RemoteException();
|
throw new RemoteException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServiceDebugInfo[] getServiceDebugInfo() throws RemoteException {
|
||||||
|
return mServiceManager.getServiceDebugInfo();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as mServiceManager but used by apps.
|
* Same as mServiceManager but used by apps.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import android.os.IPowerManager;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.ServiceDebugInfo;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
@@ -135,6 +136,11 @@ public class Watchdog extends Thread {
|
|||||||
"android.system.suspend@1.0::ISystemSuspend"
|
"android.system.suspend@1.0::ISystemSuspend"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static final String[] AIDL_INTERFACE_PREFIXES_OF_INTEREST = new String[] {
|
||||||
|
"android.hardware.light.ILights/",
|
||||||
|
"android.hardware.power.stats.IPowerStats/",
|
||||||
|
};
|
||||||
|
|
||||||
private static Watchdog sWatchdog;
|
private static Watchdog sWatchdog;
|
||||||
|
|
||||||
/* This handler will be used to post message back onto the main thread */
|
/* This handler will be used to post message back onto the main thread */
|
||||||
@@ -515,12 +521,11 @@ public class Watchdog extends Thread {
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<Integer> getInterestingHalPids() {
|
private static void addInterestingHidlPids(HashSet<Integer> pids) {
|
||||||
try {
|
try {
|
||||||
IServiceManager serviceManager = IServiceManager.getService();
|
IServiceManager serviceManager = IServiceManager.getService();
|
||||||
ArrayList<IServiceManager.InstanceDebugInfo> dump =
|
ArrayList<IServiceManager.InstanceDebugInfo> dump =
|
||||||
serviceManager.debugDump();
|
serviceManager.debugDump();
|
||||||
HashSet<Integer> pids = new HashSet<>();
|
|
||||||
for (IServiceManager.InstanceDebugInfo info : dump) {
|
for (IServiceManager.InstanceDebugInfo info : dump) {
|
||||||
if (info.pid == IServiceManager.PidConstant.NO_PID) {
|
if (info.pid == IServiceManager.PidConstant.NO_PID) {
|
||||||
continue;
|
continue;
|
||||||
@@ -532,24 +537,37 @@ public class Watchdog extends Thread {
|
|||||||
|
|
||||||
pids.add(info.pid);
|
pids.add(info.pid);
|
||||||
}
|
}
|
||||||
return new ArrayList<Integer>(pids);
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
return new ArrayList<Integer>();
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addInterestingAidlPids(HashSet<Integer> pids) {
|
||||||
|
ServiceDebugInfo[] infos = ServiceManager.getServiceDebugInfo();
|
||||||
|
if (infos == null) return;
|
||||||
|
|
||||||
|
for (ServiceDebugInfo info : infos) {
|
||||||
|
for (String prefix : AIDL_INTERFACE_PREFIXES_OF_INTEREST) {
|
||||||
|
if (info.name.startsWith(prefix)) {
|
||||||
|
pids.add(info.debugPid);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArrayList<Integer> getInterestingNativePids() {
|
static ArrayList<Integer> getInterestingNativePids() {
|
||||||
ArrayList<Integer> pids = getInterestingHalPids();
|
HashSet<Integer> pids = new HashSet<>();
|
||||||
|
addInterestingAidlPids(pids);
|
||||||
|
addInterestingHidlPids(pids);
|
||||||
|
|
||||||
int[] nativePids = Process.getPidsForCommands(NATIVE_STACKS_OF_INTEREST);
|
int[] nativePids = Process.getPidsForCommands(NATIVE_STACKS_OF_INTEREST);
|
||||||
if (nativePids != null) {
|
if (nativePids != null) {
|
||||||
pids.ensureCapacity(pids.size() + nativePids.length);
|
|
||||||
for (int i : nativePids) {
|
for (int i : nativePids) {
|
||||||
pids.add(i);
|
pids.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pids;
|
return new ArrayList<Integer>(pids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user