Loading core/java/android/app/Notification.java +27 −16 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.Bitmap; import android.graphics.Canvas; Loading Loading @@ -824,6 +823,13 @@ public class Notification implements Parcelable */ public static final String EXTRA_COMPACT_ACTIONS = "android.compactActions"; /** * {@link #extras} key: the user that built the notification. * * @hide */ public static final String EXTRA_ORIGINATING_USERID = "android.originatingUserId"; /** * Value for {@link #EXTRA_AS_HEADS_UP} that indicates this notification should not be * displayed in the heads up space. Loading Loading @@ -1807,12 +1813,10 @@ public class Notification implements Parcelable = "android.rebuild.hudViewActionCount"; /** * The ApplicationInfo of the package that created the notification, used to create * a context to rebuild the notification via a Builder. * @hide * The package name of the context used to create the notification via a Builder. */ private static final String EXTRA_REBUILD_CONTEXT_APPLICATION_INFO = "android.rebuild.applicationInfo"; private static final String EXTRA_REBUILD_CONTEXT_PACKAGE = "android.rebuild.contextPackage"; // Whether to enable stripping (at post time) & rebuilding (at listener receive time) of // memory intensive resources. Loading Loading @@ -1862,6 +1866,11 @@ public class Notification implements Parcelable private ArrayList<String> mPeople; private int mColor = COLOR_DEFAULT; /** * The user that built the notification originally. */ private int mOriginatingUserId; /** * Contains extras related to rebuilding during the build phase. */ Loading Loading @@ -2582,7 +2591,7 @@ public class Notification implements Parcelable // Note: This assumes that the current user can read the profile badge of the // originating user. UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); return userManager.getBadgeForUser(new UserHandle(mContext.getUserId()), 0); return userManager.getBadgeForUser(new UserHandle(mOriginatingUserId), 0); } private Bitmap getProfileBadge() { Loading Loading @@ -2661,7 +2670,8 @@ public class Notification implements Parcelable * @param hasProgress whether the progress bar should be shown and set */ private RemoteViews applyStandardTemplate(int resId, boolean hasProgress) { RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId); RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(), mOriginatingUserId, resId); resetStandardTemplate(contentView); Loading Loading @@ -3053,8 +3063,8 @@ public class Notification implements Parcelable */ public void populateExtras(Bundle extras) { // Store original information used in the construction of this object extras.putParcelable(EXTRA_REBUILD_CONTEXT_APPLICATION_INFO, mContext.getApplicationInfo()); extras.putInt(EXTRA_ORIGINATING_USERID, mOriginatingUserId); extras.putString(EXTRA_REBUILD_CONTEXT_PACKAGE, mContext.getPackageName()); extras.putCharSequence(EXTRA_TITLE, mContentTitle); extras.putCharSequence(EXTRA_TEXT, mContentText); extras.putCharSequence(EXTRA_SUB_TEXT, mSubText); Loading Loading @@ -3142,14 +3152,13 @@ public class Notification implements Parcelable extras.remove(EXTRA_NEEDS_REBUILD); // Re-create notification context so we can access app resources. ApplicationInfo applicationInfo = extras.getParcelable( EXTRA_REBUILD_CONTEXT_APPLICATION_INFO); String packageName = extras.getString(EXTRA_REBUILD_CONTEXT_PACKAGE); Context builderContext; try { builderContext = context.createApplicationContext(applicationInfo, builderContext = context.createPackageContext(packageName, Context.CONTEXT_RESTRICTED); } catch (NameNotFoundException e) { Log.e(TAG, "ApplicationInfo " + applicationInfo + " not found"); Log.e(TAG, "Package name " + packageName + " not found"); builderContext = context; // try with our context } Loading Loading @@ -3284,6 +3293,7 @@ public class Notification implements Parcelable // Extras. Bundle extras = n.extras; mOriginatingUserId = extras.getInt(EXTRA_ORIGINATING_USERID); mContentTitle = extras.getCharSequence(EXTRA_TITLE); mContentText = extras.getCharSequence(EXTRA_TEXT); mSubText = extras.getCharSequence(EXTRA_SUB_TEXT); Loading Loading @@ -3316,6 +3326,7 @@ public class Notification implements Parcelable * object. */ public Notification build() { mOriginatingUserId = mContext.getUserId(); mHasThreeLines = hasThreeLines(); Notification n = buildUnstyled(); Loading Loading @@ -4815,8 +4826,8 @@ public class Notification implements Parcelable super(parcel); } public BuilderRemoteViews(ApplicationInfo appInfo, int layoutId) { super(appInfo, layoutId); public BuilderRemoteViews(String packageName, int userId, int layoutId) { super(packageName, userId, layoutId); } @Override Loading core/java/android/text/format/DateFormat.java +4 −17 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.text.format; import android.content.Context; import android.os.UserHandle; import android.provider.Settings; import android.text.SpannableStringBuilder; import android.text.Spanned; Loading Loading @@ -129,14 +128,8 @@ public class DateFormat { * @return true if 24 hour time format is selected, false otherwise. */ public static boolean is24HourFormat(Context context) { // This method is called by View classes that can be used by RemoteViews // and rendered in another user. The context therefore may reference // a user that would require interact accross users to access. So // use the user id we are running as. // This is the case when we have widgets from a user profile added // to the homescreen. String value = Settings.System.getStringForUser(context.getContentResolver(), Settings.System.TIME_12_24, UserHandle.myUserId()); String value = Settings.System.getString(context.getContentResolver(), Settings.System.TIME_12_24); if (value == null) { Locale locale = context.getResources().getConfiguration().locale; Loading Loading @@ -234,14 +227,8 @@ public class DateFormat { * @return the {@link java.text.DateFormat} object that properly formats the date. */ public static java.text.DateFormat getDateFormat(Context context) { // This method is called by View classes that can be used by RemoteViews // and rendered in another user. The context therefore may reference // a user that would require interact accross users to access. So // use the user id we are running as. // This is the case when we have widgets from a user profile added // to the homescreen. String value = Settings.System.getStringForUser(context.getContentResolver(), Settings.System.DATE_FORMAT, UserHandle.myUserId()); String value = Settings.System.getString(context.getContentResolver(), Settings.System.DATE_FORMAT); return getDateFormatForSetting(context, value); } Loading core/java/android/widget/DateTimeView.java +4 −22 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.util.Log; import android.provider.Settings; import android.widget.TextView; import android.widget.RemoteViews.RemoteView; import android.os.UserHandle; import java.text.DateFormat; import java.text.SimpleDateFormat; Loading Loading @@ -191,15 +190,8 @@ public class DateTimeView extends TextView { } private DateFormat getDateFormat() { // OK, this is gross but needed. This class is supported by the // remote views mechanism and as a part of that the remote views // can be inflated by a context for another user without the app // having interact users permission - just for loading resources. // For example, when adding widgets from a user profile to the // home screen. Therefore, we access settings as the user the app // is running as not the one the context is for. String format = Settings.System.getStringForUser(getContext().getContentResolver(), Settings.System.DATE_FORMAT, UserHandle.myUserId()); String format = Settings.System.getString(getContext().getContentResolver(), Settings.System.DATE_FORMAT); if (format == null || "".equals(format)) { return DateFormat.getDateInstance(DateFormat.SHORT); } else { Loading @@ -220,20 +212,10 @@ public class DateTimeView extends TextView { filter.addAction(Intent.ACTION_TIME_CHANGED); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); // OK, this is gross but needed. This class is supported by the // remote views mechanism and as a part of that the remote views // can be inflated by a context for another user without the app // having interact users permission - just for loading resources. // For example, when adding widgets from a user profile to the // home screen. Therefore, we register the receiver and content // observer as the user the app is running as not the one the context is for. context.registerReceiverAsUser(mBroadcastReceiver, android.os.Process.myUserHandle(), filter, null, null); context.registerReceiver(mBroadcastReceiver, filter); Uri uri = Settings.System.getUriFor(Settings.System.DATE_FORMAT); context.getContentResolver().registerContentObserver(uri, true, mContentObserver, UserHandle.myUserId()); context.getContentResolver().registerContentObserver(uri, true, mContentObserver); } private void unregisterReceivers() { Loading core/java/android/widget/RemoteViews.java +1 −3 Original line number Diff line number Diff line Loading @@ -1653,10 +1653,8 @@ public class RemoteViews implements Parcelable, Filter { * * @param application The application whose content is shown by the views. * @param layoutId The id of the layout resource. * * @hide */ protected RemoteViews(ApplicationInfo application, int layoutId) { private RemoteViews(ApplicationInfo application, int layoutId) { mApplication = application; mLayoutId = layoutId; mBitmapCache = new BitmapCache(); Loading core/java/android/widget/TextClock.java +2 −19 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.text.format.DateFormat; import android.util.AttributeSet; Loading Loading @@ -496,28 +495,12 @@ public class TextClock extends TextView { filter.addAction(Intent.ACTION_TIME_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); // OK, this is gross but needed. This class is supported by the // remote views mechanism and as a part of that the remote views // can be inflated by a context for another user without the app // having interact users permission - just for loading resources. // For example, when adding widgets from a user profile to the // home screen. Therefore, we register the receiver as the user // the app is running as not the one the context is for. getContext().registerReceiverAsUser(mIntentReceiver, android.os.Process.myUserHandle(), filter, null, getHandler()); getContext().registerReceiver(mIntentReceiver, filter, null, getHandler()); } private void registerObserver() { final ContentResolver resolver = getContext().getContentResolver(); // OK, this is gross but needed. This class is supported by the // remote views mechanism and as a part of that the remote views // can be inflated by a context for another user without the app // having interact users permission - just for loading resources. // For example, when adding widgets from a user profile to the // home screen. Therefore, we register the content observer // as the user the app is running as not the one the context is for. resolver.registerContentObserver(Settings.System.CONTENT_URI, true, mFormatChangeObserver, UserHandle.myUserId()); resolver.registerContentObserver(Settings.System.CONTENT_URI, true, mFormatChangeObserver); } private void unregisterReceiver() { Loading Loading
core/java/android/app/Notification.java +27 −16 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.Bitmap; import android.graphics.Canvas; Loading Loading @@ -824,6 +823,13 @@ public class Notification implements Parcelable */ public static final String EXTRA_COMPACT_ACTIONS = "android.compactActions"; /** * {@link #extras} key: the user that built the notification. * * @hide */ public static final String EXTRA_ORIGINATING_USERID = "android.originatingUserId"; /** * Value for {@link #EXTRA_AS_HEADS_UP} that indicates this notification should not be * displayed in the heads up space. Loading Loading @@ -1807,12 +1813,10 @@ public class Notification implements Parcelable = "android.rebuild.hudViewActionCount"; /** * The ApplicationInfo of the package that created the notification, used to create * a context to rebuild the notification via a Builder. * @hide * The package name of the context used to create the notification via a Builder. */ private static final String EXTRA_REBUILD_CONTEXT_APPLICATION_INFO = "android.rebuild.applicationInfo"; private static final String EXTRA_REBUILD_CONTEXT_PACKAGE = "android.rebuild.contextPackage"; // Whether to enable stripping (at post time) & rebuilding (at listener receive time) of // memory intensive resources. Loading Loading @@ -1862,6 +1866,11 @@ public class Notification implements Parcelable private ArrayList<String> mPeople; private int mColor = COLOR_DEFAULT; /** * The user that built the notification originally. */ private int mOriginatingUserId; /** * Contains extras related to rebuilding during the build phase. */ Loading Loading @@ -2582,7 +2591,7 @@ public class Notification implements Parcelable // Note: This assumes that the current user can read the profile badge of the // originating user. UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); return userManager.getBadgeForUser(new UserHandle(mContext.getUserId()), 0); return userManager.getBadgeForUser(new UserHandle(mOriginatingUserId), 0); } private Bitmap getProfileBadge() { Loading Loading @@ -2661,7 +2670,8 @@ public class Notification implements Parcelable * @param hasProgress whether the progress bar should be shown and set */ private RemoteViews applyStandardTemplate(int resId, boolean hasProgress) { RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId); RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(), mOriginatingUserId, resId); resetStandardTemplate(contentView); Loading Loading @@ -3053,8 +3063,8 @@ public class Notification implements Parcelable */ public void populateExtras(Bundle extras) { // Store original information used in the construction of this object extras.putParcelable(EXTRA_REBUILD_CONTEXT_APPLICATION_INFO, mContext.getApplicationInfo()); extras.putInt(EXTRA_ORIGINATING_USERID, mOriginatingUserId); extras.putString(EXTRA_REBUILD_CONTEXT_PACKAGE, mContext.getPackageName()); extras.putCharSequence(EXTRA_TITLE, mContentTitle); extras.putCharSequence(EXTRA_TEXT, mContentText); extras.putCharSequence(EXTRA_SUB_TEXT, mSubText); Loading Loading @@ -3142,14 +3152,13 @@ public class Notification implements Parcelable extras.remove(EXTRA_NEEDS_REBUILD); // Re-create notification context so we can access app resources. ApplicationInfo applicationInfo = extras.getParcelable( EXTRA_REBUILD_CONTEXT_APPLICATION_INFO); String packageName = extras.getString(EXTRA_REBUILD_CONTEXT_PACKAGE); Context builderContext; try { builderContext = context.createApplicationContext(applicationInfo, builderContext = context.createPackageContext(packageName, Context.CONTEXT_RESTRICTED); } catch (NameNotFoundException e) { Log.e(TAG, "ApplicationInfo " + applicationInfo + " not found"); Log.e(TAG, "Package name " + packageName + " not found"); builderContext = context; // try with our context } Loading Loading @@ -3284,6 +3293,7 @@ public class Notification implements Parcelable // Extras. Bundle extras = n.extras; mOriginatingUserId = extras.getInt(EXTRA_ORIGINATING_USERID); mContentTitle = extras.getCharSequence(EXTRA_TITLE); mContentText = extras.getCharSequence(EXTRA_TEXT); mSubText = extras.getCharSequence(EXTRA_SUB_TEXT); Loading Loading @@ -3316,6 +3326,7 @@ public class Notification implements Parcelable * object. */ public Notification build() { mOriginatingUserId = mContext.getUserId(); mHasThreeLines = hasThreeLines(); Notification n = buildUnstyled(); Loading Loading @@ -4815,8 +4826,8 @@ public class Notification implements Parcelable super(parcel); } public BuilderRemoteViews(ApplicationInfo appInfo, int layoutId) { super(appInfo, layoutId); public BuilderRemoteViews(String packageName, int userId, int layoutId) { super(packageName, userId, layoutId); } @Override Loading
core/java/android/text/format/DateFormat.java +4 −17 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.text.format; import android.content.Context; import android.os.UserHandle; import android.provider.Settings; import android.text.SpannableStringBuilder; import android.text.Spanned; Loading Loading @@ -129,14 +128,8 @@ public class DateFormat { * @return true if 24 hour time format is selected, false otherwise. */ public static boolean is24HourFormat(Context context) { // This method is called by View classes that can be used by RemoteViews // and rendered in another user. The context therefore may reference // a user that would require interact accross users to access. So // use the user id we are running as. // This is the case when we have widgets from a user profile added // to the homescreen. String value = Settings.System.getStringForUser(context.getContentResolver(), Settings.System.TIME_12_24, UserHandle.myUserId()); String value = Settings.System.getString(context.getContentResolver(), Settings.System.TIME_12_24); if (value == null) { Locale locale = context.getResources().getConfiguration().locale; Loading Loading @@ -234,14 +227,8 @@ public class DateFormat { * @return the {@link java.text.DateFormat} object that properly formats the date. */ public static java.text.DateFormat getDateFormat(Context context) { // This method is called by View classes that can be used by RemoteViews // and rendered in another user. The context therefore may reference // a user that would require interact accross users to access. So // use the user id we are running as. // This is the case when we have widgets from a user profile added // to the homescreen. String value = Settings.System.getStringForUser(context.getContentResolver(), Settings.System.DATE_FORMAT, UserHandle.myUserId()); String value = Settings.System.getString(context.getContentResolver(), Settings.System.DATE_FORMAT); return getDateFormatForSetting(context, value); } Loading
core/java/android/widget/DateTimeView.java +4 −22 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.util.Log; import android.provider.Settings; import android.widget.TextView; import android.widget.RemoteViews.RemoteView; import android.os.UserHandle; import java.text.DateFormat; import java.text.SimpleDateFormat; Loading Loading @@ -191,15 +190,8 @@ public class DateTimeView extends TextView { } private DateFormat getDateFormat() { // OK, this is gross but needed. This class is supported by the // remote views mechanism and as a part of that the remote views // can be inflated by a context for another user without the app // having interact users permission - just for loading resources. // For example, when adding widgets from a user profile to the // home screen. Therefore, we access settings as the user the app // is running as not the one the context is for. String format = Settings.System.getStringForUser(getContext().getContentResolver(), Settings.System.DATE_FORMAT, UserHandle.myUserId()); String format = Settings.System.getString(getContext().getContentResolver(), Settings.System.DATE_FORMAT); if (format == null || "".equals(format)) { return DateFormat.getDateInstance(DateFormat.SHORT); } else { Loading @@ -220,20 +212,10 @@ public class DateTimeView extends TextView { filter.addAction(Intent.ACTION_TIME_CHANGED); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); // OK, this is gross but needed. This class is supported by the // remote views mechanism and as a part of that the remote views // can be inflated by a context for another user without the app // having interact users permission - just for loading resources. // For example, when adding widgets from a user profile to the // home screen. Therefore, we register the receiver and content // observer as the user the app is running as not the one the context is for. context.registerReceiverAsUser(mBroadcastReceiver, android.os.Process.myUserHandle(), filter, null, null); context.registerReceiver(mBroadcastReceiver, filter); Uri uri = Settings.System.getUriFor(Settings.System.DATE_FORMAT); context.getContentResolver().registerContentObserver(uri, true, mContentObserver, UserHandle.myUserId()); context.getContentResolver().registerContentObserver(uri, true, mContentObserver); } private void unregisterReceivers() { Loading
core/java/android/widget/RemoteViews.java +1 −3 Original line number Diff line number Diff line Loading @@ -1653,10 +1653,8 @@ public class RemoteViews implements Parcelable, Filter { * * @param application The application whose content is shown by the views. * @param layoutId The id of the layout resource. * * @hide */ protected RemoteViews(ApplicationInfo application, int layoutId) { private RemoteViews(ApplicationInfo application, int layoutId) { mApplication = application; mLayoutId = layoutId; mBitmapCache = new BitmapCache(); Loading
core/java/android/widget/TextClock.java +2 −19 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.text.format.DateFormat; import android.util.AttributeSet; Loading Loading @@ -496,28 +495,12 @@ public class TextClock extends TextView { filter.addAction(Intent.ACTION_TIME_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); // OK, this is gross but needed. This class is supported by the // remote views mechanism and as a part of that the remote views // can be inflated by a context for another user without the app // having interact users permission - just for loading resources. // For example, when adding widgets from a user profile to the // home screen. Therefore, we register the receiver as the user // the app is running as not the one the context is for. getContext().registerReceiverAsUser(mIntentReceiver, android.os.Process.myUserHandle(), filter, null, getHandler()); getContext().registerReceiver(mIntentReceiver, filter, null, getHandler()); } private void registerObserver() { final ContentResolver resolver = getContext().getContentResolver(); // OK, this is gross but needed. This class is supported by the // remote views mechanism and as a part of that the remote views // can be inflated by a context for another user without the app // having interact users permission - just for loading resources. // For example, when adding widgets from a user profile to the // home screen. Therefore, we register the content observer // as the user the app is running as not the one the context is for. resolver.registerContentObserver(Settings.System.CONTENT_URI, true, mFormatChangeObserver, UserHandle.myUserId()); resolver.registerContentObserver(Settings.System.CONTENT_URI, true, mFormatChangeObserver); } private void unregisterReceiver() { Loading