Merge "startProcessLocked: Inherit debuggable flag for SDK sandbox" into tm-dev
This commit is contained in:
@@ -1719,7 +1719,13 @@ public final class ProcessList {
|
||||
uid = 0;
|
||||
}
|
||||
int runtimeFlags = 0;
|
||||
if ((app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
|
||||
|
||||
boolean debuggableFlag = (app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
|
||||
if (!debuggableFlag && app.isSdkSandbox) {
|
||||
debuggableFlag = isAppForSdkSandboxDebuggable(app);
|
||||
}
|
||||
|
||||
if (debuggableFlag) {
|
||||
runtimeFlags |= Zygote.DEBUG_ENABLE_JDWP;
|
||||
runtimeFlags |= Zygote.DEBUG_JAVA_DEBUGGABLE;
|
||||
// Also turn on CheckJNI for debuggable apps. It's quite
|
||||
@@ -1884,6 +1890,25 @@ public final class ProcessList {
|
||||
}
|
||||
}
|
||||
|
||||
/** Return true if the client app for the SDK sandbox process is debuggable. */
|
||||
private boolean isAppForSdkSandboxDebuggable(ProcessRecord sandboxProcess) {
|
||||
// TODO (b/221004701) use client app process name
|
||||
final int appUid = Process.toAppUid(sandboxProcess.uid);
|
||||
IPackageManager pm = mService.getPackageManager();
|
||||
try {
|
||||
String[] packages = pm.getPackagesForUid(appUid);
|
||||
for (String aPackage : packages) {
|
||||
ApplicationInfo i = pm.getApplicationInfo(aPackage, 0, sandboxProcess.userId);
|
||||
if ((i.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
// shouldn't happen
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@GuardedBy("mService")
|
||||
boolean startProcessLocked(HostingRecord hostingRecord, String entryPoint, ProcessRecord app,
|
||||
int uid, int[] gids, int runtimeFlags, int zygotePolicyFlags, int mountExternal,
|
||||
|
||||
@@ -79,6 +79,7 @@ class ProcessRecord implements WindowProcessListener {
|
||||
volatile ApplicationInfo info; // all about the first app in the process
|
||||
final ProcessInfo processInfo; // if non-null, process-specific manifest info
|
||||
final boolean isolated; // true if this is a special isolated process
|
||||
public final boolean isSdkSandbox; // true if this is an SDK sandbox process
|
||||
final boolean appZygote; // true if this is forked from the app zygote
|
||||
final int uid; // uid of process; may be different from 'info' if isolated
|
||||
final int userId; // user of process.
|
||||
@@ -523,6 +524,7 @@ class ProcessRecord implements WindowProcessListener {
|
||||
}
|
||||
processInfo = procInfo;
|
||||
isolated = Process.isIsolated(_uid);
|
||||
isSdkSandbox = Process.isSdkSandboxUid(_uid);
|
||||
appZygote = (UserHandle.getAppId(_uid) >= Process.FIRST_APP_ZYGOTE_ISOLATED_UID
|
||||
&& UserHandle.getAppId(_uid) <= Process.LAST_APP_ZYGOTE_ISOLATED_UID);
|
||||
uid = _uid;
|
||||
|
||||
Reference in New Issue
Block a user