Use package manager stock flags to pull lib info

In several places activity manager components were not using
the stock package manager flags and as a result were not pulling
the libraries on which the app depended. This leads to subtle
cases were the dependent libs are not present on the classpath
resulting in app crashes.

This is a manual merge of I33cb4464599dd8c1b68f64eb3bb7c470bf27ab97 from
o-wear-dev

Test: Tried to repro original issue
Bug: 73760062
Change-Id: Ia5c9236b330a8595c2c23b39aa73f0a07a277154
This commit is contained in:
Philip P. Moltmann
2018-03-27 12:51:51 -07:00
parent 678c0286be
commit cff8f0f4e7
5 changed files with 20 additions and 11 deletions

View File

@@ -10601,8 +10601,8 @@ public class ActivityManagerService extends IActivityManager.Stub
intent.addFlags(Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS);
}
}
final ActivityInfo ainfo = AppGlobals.getPackageManager().getActivityInfo(comp, 0,
UserHandle.getUserId(callingUid));
final ActivityInfo ainfo = AppGlobals.getPackageManager().getActivityInfo(comp,
STOCK_PM_FLAGS, UserHandle.getUserId(callingUid));
if (ainfo.applicationInfo.uid != callingUid) {
throw new SecurityException(
"Can't add task for another application: target uid="
@@ -21190,7 +21190,7 @@ public class ActivityManagerService extends IActivityManager.Stub
ApplicationInfo aInfo = null;
try {
aInfo = AppGlobals.getPackageManager()
.getApplicationInfo(ssp, 0 /*flags*/, userId);
.getApplicationInfo(ssp, STOCK_PM_FLAGS, userId);
} catch (RemoteException ignore) {}
if (aInfo == null) {
Slog.w(TAG, "Dropping ACTION_PACKAGE_REPLACED for non-existent pkg:"
@@ -21215,7 +21215,7 @@ public class ActivityManagerService extends IActivityManager.Stub
try {
ApplicationInfo ai = AppGlobals.getPackageManager().
getApplicationInfo(ssp, 0, 0);
getApplicationInfo(ssp, STOCK_PM_FLAGS, 0);
mBatteryStatsService.notePackageInstalled(ssp,
ai != null ? ai.versionCode : 0);
} catch (RemoteException e) {

View File

@@ -236,7 +236,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
final IApplicationToken.Stub appToken; // window manager token
AppWindowContainerController mWindowContainerController;
final ActivityInfo info; // all about me
final ApplicationInfo appInfo; // information about activity's app
// TODO: This is duplicated state already contained in info.applicationInfo - remove
ApplicationInfo appInfo; // information about activity's app
final int launchedFromPid; // always the pid who started the activity.
final int launchedFromUid; // always the uid who started the activity.
final String launchedFromPackage; // always the package who started the activity.
@@ -605,6 +606,11 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
}
}
void updateApplicationInfo(ApplicationInfo aInfo) {
appInfo = aInfo;
info.applicationInfo = aInfo;
}
private boolean crossesHorizontalSizeThreshold(int firstDp, int secondDp) {
return crossesSizeThreshold(mHorizontalSizeConfigurations, firstDp, secondDp);
}

View File

@@ -1324,7 +1324,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
final ActivityRecord ar = activities.get(activityNdx);
if ((userId == ar.userId) && packageName.equals(ar.packageName)) {
ar.info.applicationInfo = aInfo;
ar.updateApplicationInfo(aInfo);
}
}
}
@@ -3987,7 +3987,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
} else {
try {
ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo(
destIntent.getComponent(), 0, srec.userId);
destIntent.getComponent(), ActivityManagerService.STOCK_PM_FLAGS,
srec.userId);
// TODO(b/64750076): Check if calling pid should really be -1.
final int res = mService.getActivityStartController()
.obtainStarter(destIntent, "navigateUpTo")

View File

@@ -198,9 +198,10 @@ public class ActivityStartController {
// See if we should be showing the platform update setup UI.
final Intent intent = new Intent(Intent.ACTION_UPGRADE_SETUP);
final List<ResolveInfo> ris = mService.mContext.getPackageManager()
.queryIntentActivities(intent,
PackageManager.MATCH_SYSTEM_ONLY | PackageManager.GET_META_DATA);
final List<ResolveInfo> ris =
mService.mContext.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_SYSTEM_ONLY | PackageManager.GET_META_DATA
| ActivityManagerService.STOCK_PM_FLAGS);
if (!ris.isEmpty()) {
final ResolveInfo ri = ris.get(0);
String vers = ri.activityInfo.metaData != null

View File

@@ -600,7 +600,8 @@ class RecentTasks {
// activities that are fully runnable based on
// current system state.
ai = pm.getActivityInfo(task.realActivity,
PackageManager.MATCH_DEBUG_TRIAGED_MISSING, userId);
PackageManager.MATCH_DEBUG_TRIAGED_MISSING
| ActivityManagerService.STOCK_PM_FLAGS, userId);
} catch (RemoteException e) {
// Will never happen.
continue;