From e2c1f9b78b0df6d1ce945c7b5083aad190a61585 Mon Sep 17 00:00:00 2001 From: Wang Le Date: Wed, 4 May 2016 19:24:35 +0800 Subject: [PATCH] Fix the issue that App crash on startForeground Install single APP in any user space except Owner user, the APP got crash when call startForeground in Service Component with Notification which without SmallIcon. External bug:https://code.google.com/p/android/issues/detail?id=209043 Internal bug: 28602381 Change-Id: I88a3b8afc213cafe0f280f9b44d6acd2ea0df207 Signed-off-by: Wang Le --- services/core/java/com/android/server/am/ServiceRecord.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java index bc297dec834af..0a081e9809ea0 100644 --- a/services/core/java/com/android/server/am/ServiceRecord.java +++ b/services/core/java/com/android/server/am/ServiceRecord.java @@ -441,7 +441,7 @@ final class ServiceRecord extends Binder { Notification localForegroundNoti = _foregroundNoti; try { if (localForegroundNoti.getSmallIcon() == null) { - // It is not correct for the caller to supply a notification + // It is not correct for the caller to not supply a notification // icon, but this used to be able to slip through, so for // those dirty apps we will create a notification clearly // blaming the app. @@ -458,8 +458,8 @@ final class ServiceRecord extends Binder { } Context ctx = null; try { - ctx = ams.mContext.createPackageContext( - appInfo.packageName, 0); + ctx = ams.mContext.createPackageContextAsUser( + appInfo.packageName, 0, new UserHandle(userId)); Notification.Builder notiBuilder = new Notification.Builder(ctx);