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