Merge "Load resources for the correct user" into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
be47828fbc
@@ -1740,6 +1740,11 @@ public final class ActivityThread {
|
||||
|
||||
public final LoadedApk getPackageInfo(String packageName, CompatibilityInfo compatInfo,
|
||||
int flags) {
|
||||
return getPackageInfo(packageName, compatInfo, flags, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
public final LoadedApk getPackageInfo(String packageName, CompatibilityInfo compatInfo,
|
||||
int flags, int userId) {
|
||||
synchronized (mPackages) {
|
||||
WeakReference<LoadedApk> ref;
|
||||
if ((flags&Context.CONTEXT_INCLUDE_CODE) != 0) {
|
||||
@@ -1768,7 +1773,7 @@ public final class ActivityThread {
|
||||
ApplicationInfo ai = null;
|
||||
try {
|
||||
ai = getPackageManager().getApplicationInfo(packageName,
|
||||
PackageManager.GET_SHARED_LIBRARY_FILES, UserHandle.myUserId());
|
||||
PackageManager.GET_SHARED_LIBRARY_FILES, userId);
|
||||
} catch (RemoteException e) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@@ -759,6 +759,21 @@ final class ApplicationPackageManager extends PackageManager {
|
||||
getApplicationInfo(appPackageName, 0));
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
|
||||
throws NameNotFoundException {
|
||||
try {
|
||||
ApplicationInfo ai = mPM.getApplicationInfo(appPackageName, 0, userId);
|
||||
if (ai != null) {
|
||||
return getResourcesForApplication(ai);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException("Package manager has died", e);
|
||||
}
|
||||
throw new NameNotFoundException("Package " + appPackageName + " doesn't exist");
|
||||
}
|
||||
|
||||
int mCachedSafeMode = -1;
|
||||
@Override public boolean isSafeMode() {
|
||||
try {
|
||||
|
||||
@@ -1707,7 +1707,8 @@ class ContextImpl extends Context {
|
||||
}
|
||||
|
||||
LoadedApk pi =
|
||||
mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(), flags);
|
||||
mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(), flags,
|
||||
user.getIdentifier());
|
||||
if (pi != null) {
|
||||
ContextImpl c = new ContextImpl();
|
||||
c.mRestricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
|
||||
|
||||
@@ -2341,6 +2341,10 @@ public abstract class PackageManager {
|
||||
public abstract Resources getResourcesForApplication(String appPackageName)
|
||||
throws NameNotFoundException;
|
||||
|
||||
/** @hide */
|
||||
public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
|
||||
throws NameNotFoundException;
|
||||
|
||||
/**
|
||||
* Retrieve overall information about an application package defined
|
||||
* in a package archive file
|
||||
|
||||
@@ -18,18 +18,21 @@ package com.android.internal.statusbar;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.UserHandle;
|
||||
|
||||
public class StatusBarIcon implements Parcelable {
|
||||
public String iconPackage;
|
||||
public UserHandle user;
|
||||
public int iconId;
|
||||
public int iconLevel;
|
||||
public boolean visible = true;
|
||||
public int number;
|
||||
public CharSequence contentDescription;
|
||||
|
||||
public StatusBarIcon(String iconPackage, int iconId, int iconLevel, int number,
|
||||
public StatusBarIcon(String iconPackage, UserHandle user, int iconId, int iconLevel, int number,
|
||||
CharSequence contentDescription) {
|
||||
this.iconPackage = iconPackage;
|
||||
this.user = user;
|
||||
this.iconId = iconId;
|
||||
this.iconLevel = iconLevel;
|
||||
this.number = number;
|
||||
@@ -38,15 +41,16 @@ public class StatusBarIcon implements Parcelable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StatusBarIcon(pkg=" + this.iconPackage + " id=0x" + Integer.toHexString(this.iconId)
|
||||
return "StatusBarIcon(pkg=" + this.iconPackage + "user=" + user.getIdentifier()
|
||||
+ " id=0x" + Integer.toHexString(this.iconId)
|
||||
+ " level=" + this.iconLevel + " visible=" + visible
|
||||
+ " num=" + this.number + " )";
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusBarIcon clone() {
|
||||
StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel,
|
||||
this.number, this.contentDescription);
|
||||
StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.user, this.iconId,
|
||||
this.iconLevel, this.number, this.contentDescription);
|
||||
that.visible = this.visible;
|
||||
return that;
|
||||
}
|
||||
@@ -60,6 +64,7 @@ public class StatusBarIcon implements Parcelable {
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
this.iconPackage = in.readString();
|
||||
this.user = (UserHandle) in.readParcelable(null);
|
||||
this.iconId = in.readInt();
|
||||
this.iconLevel = in.readInt();
|
||||
this.visible = in.readInt() != 0;
|
||||
@@ -69,6 +74,7 @@ public class StatusBarIcon implements Parcelable {
|
||||
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeString(this.iconPackage);
|
||||
out.writeParcelable(this.user, 0);
|
||||
out.writeInt(this.iconId);
|
||||
out.writeInt(this.iconLevel);
|
||||
out.writeInt(this.visible ? 1 : 0);
|
||||
|
||||
@@ -860,6 +860,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
|
||||
final StatusBarIcon ic = new StatusBarIcon(notification.pkg,
|
||||
notification.user,
|
||||
notification.notification.icon,
|
||||
notification.notification.iconLevel,
|
||||
notification.notification.number,
|
||||
@@ -1012,6 +1013,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
}
|
||||
// Update the icon.
|
||||
final StatusBarIcon ic = new StatusBarIcon(notification.pkg,
|
||||
notification.user,
|
||||
notification.notification.icon, notification.notification.iconLevel,
|
||||
notification.notification.number,
|
||||
notification.notification.tickerText);
|
||||
|
||||
@@ -165,7 +165,8 @@ public class StatusBarIconView extends AnimatedImageView {
|
||||
|
||||
if (icon.iconPackage != null) {
|
||||
try {
|
||||
r = context.getPackageManager().getResourcesForApplication(icon.iconPackage);
|
||||
r = context.getPackageManager().getResourcesForApplicationAsUser(icon.iconPackage,
|
||||
icon.user.getIdentifier());
|
||||
} catch (PackageManager.NameNotFoundException ex) {
|
||||
Slog.e(TAG, "Icon package not found: " + icon.iconPackage);
|
||||
return null;
|
||||
|
||||
@@ -192,7 +192,7 @@ public abstract class Ticker {
|
||||
}
|
||||
|
||||
final Drawable icon = StatusBarIconView.getIcon(mContext,
|
||||
new StatusBarIcon(n.pkg, n.notification.icon, n.notification.iconLevel, 0,
|
||||
new StatusBarIcon(n.pkg, n.user, n.notification.icon, n.notification.iconLevel, 0,
|
||||
n.notification.tickerText));
|
||||
final Segment newSegment = new Segment(n, icon, n.notification.tickerText);
|
||||
|
||||
|
||||
@@ -288,7 +288,8 @@ public class TabletTicker
|
||||
} else if (n.tickerText != null) {
|
||||
group = (ViewGroup)inflater.inflate(R.layout.system_bar_ticker_compat, mWindow, false);
|
||||
final Drawable icon = StatusBarIconView.getIcon(mContext,
|
||||
new StatusBarIcon(notification.pkg, n.icon, n.iconLevel, 0, n.tickerText));
|
||||
new StatusBarIcon(notification.pkg, notification.user, n.icon, n.iconLevel, 0,
|
||||
n.tickerText));
|
||||
ImageView iv = (ImageView)group.findViewById(iconId);
|
||||
iv.setImageDrawable(icon);
|
||||
iv.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -657,13 +657,13 @@ class AppWidgetServiceImpl {
|
||||
}
|
||||
final ComponentName componentName = intent.getComponent();
|
||||
try {
|
||||
final ServiceInfo si = mContext.getPackageManager().getServiceInfo(componentName,
|
||||
PackageManager.GET_PERMISSIONS);
|
||||
final ServiceInfo si = AppGlobals.getPackageManager().getServiceInfo(componentName,
|
||||
PackageManager.GET_PERMISSIONS, mUserId);
|
||||
if (!android.Manifest.permission.BIND_REMOTEVIEWS.equals(si.permission)) {
|
||||
throw new SecurityException("Selected service does not require "
|
||||
+ android.Manifest.permission.BIND_REMOTEVIEWS + ": " + componentName);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
} catch (RemoteException e) {
|
||||
throw new IllegalArgumentException("Unknown component " + componentName);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.internal.statusbar.IStatusBar;
|
||||
@@ -179,7 +180,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
throw new SecurityException("invalid status bar icon slot: " + slot);
|
||||
}
|
||||
|
||||
StatusBarIcon icon = new StatusBarIcon(iconPackage, iconId, iconLevel, 0,
|
||||
StatusBarIcon icon = new StatusBarIcon(iconPackage, UserHandle.OWNER, iconId,
|
||||
iconLevel, 0,
|
||||
contentDescription);
|
||||
//Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon);
|
||||
mIcons.setIcon(index, icon);
|
||||
|
||||
@@ -40,6 +40,7 @@ import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.content.pm.VerificationParams;
|
||||
import android.content.pm.VerifierDeviceIdentity;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -371,6 +372,12 @@ public class MockPackageManager extends PackageManager {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public Resources getResourcesForApplicationAsUser(String appPackageName, int userId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
Reference in New Issue
Block a user