Loading services/core/java/com/android/server/accounts/AccountManagerService.java +16 −5 Original line number Diff line number Diff line Loading @@ -1700,9 +1700,10 @@ public class AccountManagerService subtitle = titleAndSubtitle.substring(index + 1); } UserHandle user = new UserHandle(userId); n.color = mContext.getResources().getColor( Context contextForUser = getContextForUser(user); n.color = contextForUser.getResources().getColor( com.android.internal.R.color.system_notification_accent_color); n.setLatestEventInfo(mContext, title, subtitle, n.setLatestEventInfo(contextForUser, title, subtitle, PendingIntent.getActivityAsUser(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, user)); installNotification(getCredentialPermissionNotificationId( Loading Loading @@ -2968,11 +2969,12 @@ public class AccountManagerService Notification n = new Notification(android.R.drawable.stat_sys_warning, null, 0 /* when */); UserHandle user = new UserHandle(userId); Context contextForUser = getContextForUser(user); final String notificationTitleFormat = mContext.getText(R.string.notification_title).toString(); n.color = mContext.getResources().getColor( contextForUser.getText(R.string.notification_title).toString(); n.color = contextForUser.getResources().getColor( com.android.internal.R.color.system_notification_accent_color); n.setLatestEventInfo(mContext, n.setLatestEventInfo(contextForUser, String.format(notificationTitleFormat, account.name), message, PendingIntent.getActivityAsUser( mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, Loading Loading @@ -3478,4 +3480,13 @@ public class AccountManagerService } return authTokensForAccount; } private Context getContextForUser(UserHandle user) { try { return mContext.createPackageContextAsUser(mContext.getPackageName(), 0, user); } catch (NameNotFoundException e) { // Default to mContext, not finding the package system is running as is unlikely. return mContext; } } } services/core/java/com/android/server/content/SyncManager.java +17 −5 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.content.SyncStatusInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ProviderInfo; import android.content.pm.RegisteredServicesCache; import android.content.pm.RegisteredServicesCacheListener; Loading Loading @@ -3098,26 +3099,28 @@ public class SyncManager { return; } UserHandle user = new UserHandle(userId); final PendingIntent pendingIntent = PendingIntent .getActivityAsUser(mContext, 0, clickIntent, PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(userId)); PendingIntent.FLAG_CANCEL_CURRENT, null, user); CharSequence tooManyDeletesDescFormat = mContext.getResources().getText( R.string.contentServiceTooManyDeletesNotificationDesc); Context contextForUser = getContextForUser(user); Notification notification = new Notification(R.drawable.stat_notify_sync_error, mContext.getString(R.string.contentServiceSync), System.currentTimeMillis()); notification.color = mContext.getResources().getColor( notification.color = contextForUser.getResources().getColor( com.android.internal.R.color.system_notification_accent_color); notification.setLatestEventInfo(mContext, mContext.getString(R.string.contentServiceSyncNotificationTitle), notification.setLatestEventInfo(contextForUser, contextForUser.getString(R.string.contentServiceSyncNotificationTitle), String.format(tooManyDeletesDescFormat.toString(), authorityName), pendingIntent); notification.flags |= Notification.FLAG_ONGOING_EVENT; mNotificationMgr.notifyAsUser(null, account.hashCode() ^ authority.hashCode(), notification, new UserHandle(userId)); notification, user); } /** Loading Loading @@ -3305,4 +3308,13 @@ public class SyncManager { return mTable.size(); } } private Context getContextForUser(UserHandle user) { try { return mContext.createPackageContextAsUser(mContext.getPackageName(), 0, user); } catch (NameNotFoundException e) { // Default to mContext, not finding the package system is running as is unlikely. return mContext; } } } services/print/java/com/android/server/print/PrintManagerService.java +9 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.UserInfo; Loading Loading @@ -730,7 +731,14 @@ public final class PrintManagerService extends SystemService { PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT, null, userHandle); Notification.Builder builder = new Notification.Builder(mContext) Context builderContext = mContext; try { builderContext = mContext.createPackageContextAsUser(mContext.getPackageName(), 0, userHandle); } catch (NameNotFoundException e) { // Ignore can't find the package the system is running as. } Notification.Builder builder = new Notification.Builder(builderContext) .setSmallIcon(R.drawable.ic_print) .setContentTitle(mContext.getString(R.string.print_service_installed_title, label)) Loading Loading
services/core/java/com/android/server/accounts/AccountManagerService.java +16 −5 Original line number Diff line number Diff line Loading @@ -1700,9 +1700,10 @@ public class AccountManagerService subtitle = titleAndSubtitle.substring(index + 1); } UserHandle user = new UserHandle(userId); n.color = mContext.getResources().getColor( Context contextForUser = getContextForUser(user); n.color = contextForUser.getResources().getColor( com.android.internal.R.color.system_notification_accent_color); n.setLatestEventInfo(mContext, title, subtitle, n.setLatestEventInfo(contextForUser, title, subtitle, PendingIntent.getActivityAsUser(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, user)); installNotification(getCredentialPermissionNotificationId( Loading Loading @@ -2968,11 +2969,12 @@ public class AccountManagerService Notification n = new Notification(android.R.drawable.stat_sys_warning, null, 0 /* when */); UserHandle user = new UserHandle(userId); Context contextForUser = getContextForUser(user); final String notificationTitleFormat = mContext.getText(R.string.notification_title).toString(); n.color = mContext.getResources().getColor( contextForUser.getText(R.string.notification_title).toString(); n.color = contextForUser.getResources().getColor( com.android.internal.R.color.system_notification_accent_color); n.setLatestEventInfo(mContext, n.setLatestEventInfo(contextForUser, String.format(notificationTitleFormat, account.name), message, PendingIntent.getActivityAsUser( mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, Loading Loading @@ -3478,4 +3480,13 @@ public class AccountManagerService } return authTokensForAccount; } private Context getContextForUser(UserHandle user) { try { return mContext.createPackageContextAsUser(mContext.getPackageName(), 0, user); } catch (NameNotFoundException e) { // Default to mContext, not finding the package system is running as is unlikely. return mContext; } } }
services/core/java/com/android/server/content/SyncManager.java +17 −5 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.content.SyncStatusInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ProviderInfo; import android.content.pm.RegisteredServicesCache; import android.content.pm.RegisteredServicesCacheListener; Loading Loading @@ -3098,26 +3099,28 @@ public class SyncManager { return; } UserHandle user = new UserHandle(userId); final PendingIntent pendingIntent = PendingIntent .getActivityAsUser(mContext, 0, clickIntent, PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(userId)); PendingIntent.FLAG_CANCEL_CURRENT, null, user); CharSequence tooManyDeletesDescFormat = mContext.getResources().getText( R.string.contentServiceTooManyDeletesNotificationDesc); Context contextForUser = getContextForUser(user); Notification notification = new Notification(R.drawable.stat_notify_sync_error, mContext.getString(R.string.contentServiceSync), System.currentTimeMillis()); notification.color = mContext.getResources().getColor( notification.color = contextForUser.getResources().getColor( com.android.internal.R.color.system_notification_accent_color); notification.setLatestEventInfo(mContext, mContext.getString(R.string.contentServiceSyncNotificationTitle), notification.setLatestEventInfo(contextForUser, contextForUser.getString(R.string.contentServiceSyncNotificationTitle), String.format(tooManyDeletesDescFormat.toString(), authorityName), pendingIntent); notification.flags |= Notification.FLAG_ONGOING_EVENT; mNotificationMgr.notifyAsUser(null, account.hashCode() ^ authority.hashCode(), notification, new UserHandle(userId)); notification, user); } /** Loading Loading @@ -3305,4 +3308,13 @@ public class SyncManager { return mTable.size(); } } private Context getContextForUser(UserHandle user) { try { return mContext.createPackageContextAsUser(mContext.getPackageName(), 0, user); } catch (NameNotFoundException e) { // Default to mContext, not finding the package system is running as is unlikely. return mContext; } } }
services/print/java/com/android/server/print/PrintManagerService.java +9 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.UserInfo; Loading Loading @@ -730,7 +731,14 @@ public final class PrintManagerService extends SystemService { PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT, null, userHandle); Notification.Builder builder = new Notification.Builder(mContext) Context builderContext = mContext; try { builderContext = mContext.createPackageContextAsUser(mContext.getPackageName(), 0, userHandle); } catch (NameNotFoundException e) { // Ignore can't find the package the system is running as. } Notification.Builder builder = new Notification.Builder(builderContext) .setSmallIcon(R.drawable.ic_print) .setContentTitle(mContext.getString(R.string.print_service_installed_title, label)) Loading