auto import from //depot/cupcake/@136745

This commit is contained in:
The Android Open Source Project
2009-03-05 20:00:43 -08:00
parent 53b4045212
commit f5b4b98fad
11 changed files with 204 additions and 6 deletions

View File

@@ -11823,6 +11823,56 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
}
public boolean profileControl(String process, boolean start,
String path) throws RemoteException {
synchronized (this) {
// note: hijacking SET_ACTIVITY_WATCHER, but should be changed to
// its own permission.
if (checkCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires permission "
+ android.Manifest.permission.SET_ACTIVITY_WATCHER);
}
ProcessRecord proc = null;
try {
int pid = Integer.parseInt(process);
synchronized (mPidsSelfLocked) {
proc = mPidsSelfLocked.get(pid);
}
} catch (NumberFormatException e) {
}
if (proc == null) {
HashMap<String, SparseArray<ProcessRecord>> all
= mProcessNames.getMap();
SparseArray<ProcessRecord> procs = all.get(process);
if (procs != null && procs.size() > 0) {
proc = procs.valueAt(0);
}
}
if (proc == null || proc.thread == null) {
throw new IllegalArgumentException("Unknown process: " + process);
}
boolean isSecure = "1".equals(SystemProperties.get(SYSTEM_SECURE, "0"));
if (isSecure) {
if ((proc.info.flags&ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
throw new SecurityException("Process not debuggable: " + proc);
}
}
try {
proc.thread.profilerControl(start, path);
return true;
} catch (RemoteException e) {
throw new IllegalStateException("Process disappeared");
}
}
}
/** In this method we try to acquire our lock to make sure that we have not deadlocked */
public void monitor() {
synchronized (this) { }