Ensure ApplicationInfo is for correct user for system/android package.

createPackageContextAsUser shortcuts creating the context for
system and android packages, however it should still make sure
the ApplicationInfo for the package is for the correct user.

Bug: 17002733

Change-Id: Ie10008449f13a4464a9797937c4413d6aa119fbe
This commit is contained in:
Kenny Guy
2014-09-05 16:30:38 +01:00
parent fdd04d42d2
commit 6df8d523b2

View File

@@ -2121,7 +2121,9 @@ class ContextImpl extends Context {
public Context createPackageContextAsUser(String packageName, int flags, UserHandle user)
throws NameNotFoundException {
final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
if (packageName.equals("system") || packageName.equals("android")) {
if ((packageName.equals("system") || packageName.equals("android"))
&& user.getIdentifier() == UserHandle.getUserId(
mPackageInfo.getApplicationInfo().uid)) {
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
user, restricted, mDisplay, mOverrideConfiguration);
}