LoadedApk: Notify cross-package use only when code is requested.

Cross-package use is quite common when only resources are being
considered. A common example is that any application that declares
itself <searchable /> will see cross package resource only use from
the system_server.

Test: manual instrumentation.
Change-Id: Ic7ad166c71a23c6026f4e12bb52309a50210aaaf
This commit is contained in:
Narayan Kamath
2017-03-15 11:37:32 +00:00
parent a5af24cd02
commit bf07e2a1da

View File

@@ -597,8 +597,7 @@ public final class LoadedApk {
// Avoid the binder call when the package is the current application package.
// The activity manager will perform ensure that dexopt is performed before
// spinning up the process.
if (!Objects.equals(mPackageName, ActivityThread.currentPackageName())) {
VMRuntime.getRuntime().vmInstructionSet();
if (!Objects.equals(mPackageName, ActivityThread.currentPackageName()) && mIncludeCode) {
try {
ActivityThread.getPackageManager().notifyPackageUse(mPackageName,
PackageManager.NOTIFY_PACKAGE_USE_CROSS_PACKAGE);