Merge "Fix notifications that are sent for USER_ALL." into nyc-dev
This commit is contained in:
@@ -1955,9 +1955,16 @@ public class Notification implements Parcelable
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static void addFieldsFromContext(Context context, Notification notification) {
|
public static void addFieldsFromContext(Context context, Notification notification) {
|
||||||
notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO,
|
addFieldsFromContext(context.getApplicationInfo(), context.getUserId(), notification);
|
||||||
context.getApplicationInfo());
|
}
|
||||||
notification.extras.putInt(EXTRA_ORIGINATING_USERID, context.getUserId());
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static void addFieldsFromContext(ApplicationInfo ai, int userId,
|
||||||
|
Notification notification) {
|
||||||
|
notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, ai);
|
||||||
|
notification.extras.putInt(EXTRA_ORIGINATING_USERID, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2459,12 +2459,10 @@ public class NotificationManagerService extends SystemService {
|
|||||||
|
|
||||||
// Fix the notification as best we can.
|
// Fix the notification as best we can.
|
||||||
try {
|
try {
|
||||||
if (!"android".equals(pkg) && !"system".equals(pkg)) {
|
final ApplicationInfo ai = getContext().getPackageManager().getApplicationInfoAsUser(
|
||||||
Notification.addFieldsFromContext(getContext().createApplicationContext(
|
pkg, PackageManager.MATCH_DEBUG_TRIAGED_MISSING,
|
||||||
getContext().getPackageManager().getApplicationInfoAsUser(
|
(userId == UserHandle.USER_ALL) ? UserHandle.USER_SYSTEM : userId);
|
||||||
pkg, PackageManager.MATCH_UNINSTALLED_PACKAGES, userId),
|
Notification.addFieldsFromContext(ai, userId, notification);
|
||||||
Context.CONTEXT_RESTRICTED), notification);
|
|
||||||
}
|
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Slog.e(TAG, "Cannot create a context for sending app", e);
|
Slog.e(TAG, "Cannot create a context for sending app", e);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user