Merge "Fix cross user package visibility leakage for queryInstrumentation"

This commit is contained in:
Rhed Jao
2022-05-27 02:39:53 +00:00
committed by Android (Google) Code Review
10 changed files with 61 additions and 51 deletions

View File

@@ -6854,9 +6854,12 @@ public final class ActivityThread extends ClientTransactionHandler
private InstrumentationInfo prepareInstrumentation(AppBindData data) {
final InstrumentationInfo ii;
try {
ii = new ApplicationPackageManager(null, getPackageManager())
.getInstrumentationInfo(data.instrumentationName, 0);
} catch (PackageManager.NameNotFoundException e) {
ii = getPackageManager().getInstrumentationInfoAsUser(data.instrumentationName,
0 /* flags */, UserHandle.myUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
if (ii == null) {
throw new RuntimeException(
"Unable to find instrumentation info for: " + data.instrumentationName);
}

View File

@@ -1695,8 +1695,8 @@ public class ApplicationPackageManager extends PackageManager {
ComponentName className, int flags)
throws NameNotFoundException {
try {
InstrumentationInfo ii = mPM.getInstrumentationInfo(
className, flags);
InstrumentationInfo ii = mPM.getInstrumentationInfoAsUser(
className, flags, getUserId());
if (ii != null) {
return ii;
}
@@ -1713,7 +1713,7 @@ public class ApplicationPackageManager extends PackageManager {
String targetPackage, int flags) {
try {
ParceledListSlice<InstrumentationInfo> parceledList =
mPM.queryInstrumentation(targetPackage, flags);
mPM.queryInstrumentationAsUser(targetPackage, flags, getUserId());
if (parceledList == null) {
return Collections.emptyList();
}