Loading core/java/android/app/Notification.java +4 −3 Original line number Diff line number Diff line Loading @@ -2577,7 +2577,8 @@ public class Notification implements Parcelable private RemoteViews applyStandardTemplate(int resId, boolean fitIn1U) { Bitmap profileIcon = getProfileBadge(); RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(), resId); RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(), mOriginatingUserId, resId); boolean showLine3 = false; boolean showLine2 = false; Loading Loading @@ -4576,8 +4577,8 @@ public class Notification implements Parcelable super(parcel); } public BuilderRemoteViews(String packageName, int layoutId) { super(packageName, layoutId); public BuilderRemoteViews(String packageName, int userId, int layoutId) { super(packageName, userId, layoutId); } @Override Loading core/java/android/widget/RemoteViews.java +57 −32 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.widget; import android.app.ActivityOptions; import android.app.ActivityThread; import android.app.Application; import android.app.PendingIntent; import android.appwidget.AppWidgetHostView; import android.content.Context; Loading Loading @@ -80,12 +81,6 @@ public class RemoteViews implements Parcelable, Filter { */ private ApplicationInfo mApplication; /** * The package name of the package containing the layout * resource. (Added to the parcel) */ private final String mPackage; /** * The resource ID of the layout file. (Added to the parcel) */ Loading Loading @@ -1635,11 +1630,34 @@ public class RemoteViews implements Parcelable, Filter { * @param layoutId The id of the layout resource */ public RemoteViews(String packageName, int layoutId) { mPackage = packageName; this(getApplicationInfo(packageName, UserHandle.myUserId()), layoutId); } /** * Create a new RemoteViews object that will display the views contained * in the specified layout file. * * @param packageName Name of the package that contains the layout resource. * @param userId The user under which the package is running. * @param layoutId The id of the layout resource. * * @hide */ public RemoteViews(String packageName, int userId, int layoutId) { this(getApplicationInfo(packageName, userId), layoutId); } /** * Create a new RemoteViews object that will display the views contained * in the specified layout file. * * @param application The application whose content is shown by the views. * @param layoutId The id of the layout resource. */ private RemoteViews(ApplicationInfo application, int layoutId) { mApplication = application; mLayoutId = layoutId; mBitmapCache = new BitmapCache(); mApplication = ActivityThread.currentApplication().getApplicationInfo(); // setup the memory usage statistics mMemoryUsageCounter = new MemoryUsageCounter(); recalculateMemoryUsage(); Loading @@ -1660,10 +1678,11 @@ public class RemoteViews implements Parcelable, Filter { if (landscape == null || portrait == null) { throw new RuntimeException("Both RemoteViews must be non-null"); } if (landscape.getPackage().compareTo(portrait.getPackage()) != 0) { throw new RuntimeException("Both RemoteViews must share the same package"); if (landscape.mApplication.uid != portrait.mApplication.uid || !landscape.mApplication.packageName.equals(portrait.mApplication.packageName)) { throw new RuntimeException("Both RemoteViews must share the same package and user"); } mPackage = portrait.getPackage(); mApplication = portrait.mApplication; mLayoutId = portrait.getLayoutId(); mLandscape = landscape; Loading Loading @@ -1700,7 +1719,7 @@ public class RemoteViews implements Parcelable, Filter { } if (mode == MODE_NORMAL) { mPackage = parcel.readString(); mApplication = parcel.readParcelable(null); mLayoutId = parcel.readInt(); mIsWidgetCollectionChild = parcel.readInt() == 1; Loading Loading @@ -1764,12 +1783,10 @@ public class RemoteViews implements Parcelable, Filter { // MODE_HAS_LANDSCAPE_AND_PORTRAIT mLandscape = new RemoteViews(parcel, mBitmapCache); mPortrait = new RemoteViews(parcel, mBitmapCache); mPackage = mPortrait.getPackage(); mApplication = mPortrait.mApplication; mLayoutId = mPortrait.getLayoutId(); } mApplication = parcel.readParcelable(null); // setup the memory usage statistics mMemoryUsageCounter = new MemoryUsageCounter(); recalculateMemoryUsage(); Loading @@ -1786,7 +1803,7 @@ public class RemoteViews implements Parcelable, Filter { } public String getPackage() { return mPackage; return mApplication.packageName; } /** Loading Loading @@ -2565,19 +2582,7 @@ public class RemoteViews implements Parcelable, Filter { return context.createApplicationContext(mApplication, Context.CONTEXT_RESTRICTED); } catch (NameNotFoundException e) { Log.e(LOG_TAG, "Package name " + mPackage + " not found"); } } if (mPackage != null) { if (context.getPackageName().equals(mPackage)) { return context; } try { return context.createPackageContext( mPackage, Context.CONTEXT_RESTRICTED); } catch (NameNotFoundException e) { Log.e(LOG_TAG, "Package name " + mPackage + " not found"); Log.e(LOG_TAG, "Package name " + mApplication.packageName + " not found"); } } Loading Loading @@ -2614,7 +2619,7 @@ public class RemoteViews implements Parcelable, Filter { if (mIsRoot) { mBitmapCache.writeBitmapsToParcel(dest, flags); } dest.writeString(mPackage); dest.writeParcelable(mApplication, flags); dest.writeInt(mLayoutId); dest.writeInt(mIsWidgetCollectionChild ? 1 : 0); int count; Loading @@ -2638,8 +2643,28 @@ public class RemoteViews implements Parcelable, Filter { mLandscape.writeToParcel(dest, flags); mPortrait.writeToParcel(dest, flags); } } private static ApplicationInfo getApplicationInfo(String packageName, int userId) { // Get the application for the passed in package and user. Application application = ActivityThread.currentApplication(); if (application == null) { throw new IllegalStateException("Cannot create remote views out of an aplication."); } ApplicationInfo applicationInfo = application.getApplicationInfo(); if (UserHandle.getUserId(applicationInfo.uid) != userId || !applicationInfo.packageName.equals(packageName)) { try { Context context = application.getApplicationContext().createPackageContextAsUser( packageName, 0, new UserHandle(userId)); applicationInfo = context.getApplicationInfo(); } catch (NameNotFoundException nnfe) { throw new IllegalArgumentException("No such package " + packageName); } } dest.writeParcelable(mApplication, 0); return applicationInfo; } /** Loading Loading
core/java/android/app/Notification.java +4 −3 Original line number Diff line number Diff line Loading @@ -2577,7 +2577,8 @@ public class Notification implements Parcelable private RemoteViews applyStandardTemplate(int resId, boolean fitIn1U) { Bitmap profileIcon = getProfileBadge(); RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(), resId); RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(), mOriginatingUserId, resId); boolean showLine3 = false; boolean showLine2 = false; Loading Loading @@ -4576,8 +4577,8 @@ public class Notification implements Parcelable super(parcel); } public BuilderRemoteViews(String packageName, int layoutId) { super(packageName, layoutId); public BuilderRemoteViews(String packageName, int userId, int layoutId) { super(packageName, userId, layoutId); } @Override Loading
core/java/android/widget/RemoteViews.java +57 −32 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.widget; import android.app.ActivityOptions; import android.app.ActivityThread; import android.app.Application; import android.app.PendingIntent; import android.appwidget.AppWidgetHostView; import android.content.Context; Loading Loading @@ -80,12 +81,6 @@ public class RemoteViews implements Parcelable, Filter { */ private ApplicationInfo mApplication; /** * The package name of the package containing the layout * resource. (Added to the parcel) */ private final String mPackage; /** * The resource ID of the layout file. (Added to the parcel) */ Loading Loading @@ -1635,11 +1630,34 @@ public class RemoteViews implements Parcelable, Filter { * @param layoutId The id of the layout resource */ public RemoteViews(String packageName, int layoutId) { mPackage = packageName; this(getApplicationInfo(packageName, UserHandle.myUserId()), layoutId); } /** * Create a new RemoteViews object that will display the views contained * in the specified layout file. * * @param packageName Name of the package that contains the layout resource. * @param userId The user under which the package is running. * @param layoutId The id of the layout resource. * * @hide */ public RemoteViews(String packageName, int userId, int layoutId) { this(getApplicationInfo(packageName, userId), layoutId); } /** * Create a new RemoteViews object that will display the views contained * in the specified layout file. * * @param application The application whose content is shown by the views. * @param layoutId The id of the layout resource. */ private RemoteViews(ApplicationInfo application, int layoutId) { mApplication = application; mLayoutId = layoutId; mBitmapCache = new BitmapCache(); mApplication = ActivityThread.currentApplication().getApplicationInfo(); // setup the memory usage statistics mMemoryUsageCounter = new MemoryUsageCounter(); recalculateMemoryUsage(); Loading @@ -1660,10 +1678,11 @@ public class RemoteViews implements Parcelable, Filter { if (landscape == null || portrait == null) { throw new RuntimeException("Both RemoteViews must be non-null"); } if (landscape.getPackage().compareTo(portrait.getPackage()) != 0) { throw new RuntimeException("Both RemoteViews must share the same package"); if (landscape.mApplication.uid != portrait.mApplication.uid || !landscape.mApplication.packageName.equals(portrait.mApplication.packageName)) { throw new RuntimeException("Both RemoteViews must share the same package and user"); } mPackage = portrait.getPackage(); mApplication = portrait.mApplication; mLayoutId = portrait.getLayoutId(); mLandscape = landscape; Loading Loading @@ -1700,7 +1719,7 @@ public class RemoteViews implements Parcelable, Filter { } if (mode == MODE_NORMAL) { mPackage = parcel.readString(); mApplication = parcel.readParcelable(null); mLayoutId = parcel.readInt(); mIsWidgetCollectionChild = parcel.readInt() == 1; Loading Loading @@ -1764,12 +1783,10 @@ public class RemoteViews implements Parcelable, Filter { // MODE_HAS_LANDSCAPE_AND_PORTRAIT mLandscape = new RemoteViews(parcel, mBitmapCache); mPortrait = new RemoteViews(parcel, mBitmapCache); mPackage = mPortrait.getPackage(); mApplication = mPortrait.mApplication; mLayoutId = mPortrait.getLayoutId(); } mApplication = parcel.readParcelable(null); // setup the memory usage statistics mMemoryUsageCounter = new MemoryUsageCounter(); recalculateMemoryUsage(); Loading @@ -1786,7 +1803,7 @@ public class RemoteViews implements Parcelable, Filter { } public String getPackage() { return mPackage; return mApplication.packageName; } /** Loading Loading @@ -2565,19 +2582,7 @@ public class RemoteViews implements Parcelable, Filter { return context.createApplicationContext(mApplication, Context.CONTEXT_RESTRICTED); } catch (NameNotFoundException e) { Log.e(LOG_TAG, "Package name " + mPackage + " not found"); } } if (mPackage != null) { if (context.getPackageName().equals(mPackage)) { return context; } try { return context.createPackageContext( mPackage, Context.CONTEXT_RESTRICTED); } catch (NameNotFoundException e) { Log.e(LOG_TAG, "Package name " + mPackage + " not found"); Log.e(LOG_TAG, "Package name " + mApplication.packageName + " not found"); } } Loading Loading @@ -2614,7 +2619,7 @@ public class RemoteViews implements Parcelable, Filter { if (mIsRoot) { mBitmapCache.writeBitmapsToParcel(dest, flags); } dest.writeString(mPackage); dest.writeParcelable(mApplication, flags); dest.writeInt(mLayoutId); dest.writeInt(mIsWidgetCollectionChild ? 1 : 0); int count; Loading @@ -2638,8 +2643,28 @@ public class RemoteViews implements Parcelable, Filter { mLandscape.writeToParcel(dest, flags); mPortrait.writeToParcel(dest, flags); } } private static ApplicationInfo getApplicationInfo(String packageName, int userId) { // Get the application for the passed in package and user. Application application = ActivityThread.currentApplication(); if (application == null) { throw new IllegalStateException("Cannot create remote views out of an aplication."); } ApplicationInfo applicationInfo = application.getApplicationInfo(); if (UserHandle.getUserId(applicationInfo.uid) != userId || !applicationInfo.packageName.equals(packageName)) { try { Context context = application.getApplicationContext().createPackageContextAsUser( packageName, 0, new UserHandle(userId)); applicationInfo = context.getApplicationInfo(); } catch (NameNotFoundException nnfe) { throw new IllegalArgumentException("No such package " + packageName); } } dest.writeParcelable(mApplication, 0); return applicationInfo; } /** Loading