Loading core/java/android/accounts/AccountManagerService.java +23 −15 Original line number Diff line number Diff line Loading @@ -647,16 +647,17 @@ public class AccountManagerService if (response == null) throw new IllegalArgumentException("response is null"); if (account == null) throw new IllegalArgumentException("account is null"); checkManageAccountsPermission(); UserHandle user = Binder.getCallingUserHandle(); UserAccounts accounts = getUserAccountsForCaller(); long identityToken = clearCallingIdentity(); cancelNotification(getSigninRequiredNotificationId(accounts, account)); cancelNotification(getSigninRequiredNotificationId(accounts, account), user); synchronized(accounts.credentialsPermissionNotificationIds) { for (Pair<Pair<Account, String>, Integer> pair: accounts.credentialsPermissionNotificationIds.keySet()) { if (account.equals(pair.first.first)) { int id = accounts.credentialsPermissionNotificationIds.get(pair); cancelNotification(id); cancelNotification(id, user); } } } Loading Loading @@ -789,7 +790,8 @@ public class AccountManagerService if (account == null || type == null) { return false; } cancelNotification(getSigninRequiredNotificationId(accounts, account)); cancelNotification(getSigninRequiredNotificationId(accounts, account), new UserHandle(accounts.userId)); synchronized (accounts.cacheLock) { final SQLiteDatabase db = accounts.openHelper.getWritableDatabase(); db.beginTransaction(); Loading Loading @@ -1173,11 +1175,12 @@ public class AccountManagerService title = titleAndSubtitle.substring(0, index); subtitle = titleAndSubtitle.substring(index + 1); } UserHandle user = new UserHandle(userId); n.setLatestEventInfo(mContext, title, subtitle, PendingIntent.getActivityAsUser(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(userId))); installNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), n); PendingIntent.FLAG_CANCEL_CURRENT, null, user)); installNotification(getCredentialPermissionNotificationId( account, authTokenType, uid), n, user); } String getAccountLabel(String accountType) { Loading Loading @@ -1763,7 +1766,8 @@ public class AccountManagerService String accountType = result.getString(AccountManager.KEY_ACCOUNT_TYPE); if (!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(accountType)) { Account account = new Account(accountName, accountType); cancelNotification(getSigninRequiredNotificationId(mAccounts, account)); cancelNotification(getSigninRequiredNotificationId(mAccounts, account), new UserHandle(mAccounts.userId)); } } IAccountManagerResponse response; Loading Loading @@ -2101,30 +2105,32 @@ public class AccountManagerService intent.addCategory(String.valueOf(notificationId)); Notification n = new Notification(android.R.drawable.stat_sys_warning, null, 0 /* when */); UserHandle user = new UserHandle(userId); final String notificationTitleFormat = mContext.getText(R.string.notification_title).toString(); n.setLatestEventInfo(mContext, String.format(notificationTitleFormat, account.name), message, PendingIntent.getActivityAsUser( mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(userId))); installNotification(notificationId, n); null, user)); installNotification(notificationId, n, user); } } finally { restoreCallingIdentity(identityToken); } } protected void installNotification(final int notificationId, final Notification n) { protected void installNotification(final int notificationId, final Notification n, UserHandle user) { ((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(notificationId, n); .notifyAsUser(null, notificationId, n, user); } protected void cancelNotification(int id) { protected void cancelNotification(int id, UserHandle user) { long identityToken = clearCallingIdentity(); try { ((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE)) .cancel(id); .cancelAsUser(null, id, user); } finally { restoreCallingIdentity(identityToken); } Loading Loading @@ -2289,7 +2295,8 @@ public class AccountManagerService } finally { db.endTransaction(); } cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid)); cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), new UserHandle(accounts.userId)); } } Loading Loading @@ -2323,7 +2330,8 @@ public class AccountManagerService } finally { db.endTransaction(); } cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid)); cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), new UserHandle(accounts.userId)); } } Loading core/java/android/app/PendingIntent.java +7 −1 Original line number Diff line number Diff line Loading @@ -265,6 +265,8 @@ public final class PendingIntent implements Parcelable { /** * @hide * Note that UserHandle.CURRENT will be interpreted at the time the * activity is started, not when the pending intent is created. */ public static PendingIntent getActivityAsUser(Context context, int requestCode, Intent intent, int flags, Bundle options, UserHandle user) { Loading Loading @@ -417,7 +419,11 @@ public final class PendingIntent implements Parcelable { new UserHandle(UserHandle.myUserId())); } /** @hide */ /** * @hide * Note that UserHandle.CURRENT will be interpreted at the time the * broadcast is sent, not when the pending intent is created. */ public static PendingIntent getBroadcastAsUser(Context context, int requestCode, Intent intent, int flags, UserHandle userHandle) { String packageName = context.getPackageName(); Loading core/java/com/android/internal/statusbar/StatusBarNotification.java +2 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ public class StatusBarNotification implements Parcelable { public final int score; public final UserHandle user; /** This is temporarily needed for the JB MR1 PDK. */ @Deprecated public StatusBarNotification(String pkg, int id, String tag, int uid, int initialPid, int score, Notification notification) { Loading Loading @@ -143,6 +144,6 @@ public class StatusBarNotification implements Parcelable { /** Returns a userHandle for the instance of the app that posted this notification. */ public int getUserId() { return UserHandle.getUserId(this.uid); return this.user.getIdentifier(); } } core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.pm.RegisteredServicesCache.ServiceInfo; import android.content.pm.RegisteredServicesCacheListener; import android.os.Bundle; import android.os.Handler; import android.os.UserHandle; import android.test.AndroidTestCase; import android.test.IsolatedContext; import android.test.RenamingDelegatingContext; Loading Loading @@ -243,11 +244,11 @@ public class AccountManagerServiceTest extends AndroidTestCase { } @Override protected void installNotification(final int notificationId, final Notification n) { protected void installNotification(final int notificationId, final Notification n, UserHandle user) { } @Override protected void cancelNotification(final int id) { protected void cancelNotification(final int id, UserHandle user) { } } } packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +2 −1 Original line number Diff line number Diff line Loading @@ -293,7 +293,8 @@ public abstract class BaseStatusBar extends SystemUI implements Slog.v(TAG, String.format("%s: current userid: %d, notification userid: %d", n, thisUserId, notificationUserId)); } return thisUserId == notificationUserId; return notificationUserId == UserHandle.USER_ALL || thisUserId == notificationUserId; } protected View updateNotificationVetoButton(View row, StatusBarNotification n) { Loading Loading
core/java/android/accounts/AccountManagerService.java +23 −15 Original line number Diff line number Diff line Loading @@ -647,16 +647,17 @@ public class AccountManagerService if (response == null) throw new IllegalArgumentException("response is null"); if (account == null) throw new IllegalArgumentException("account is null"); checkManageAccountsPermission(); UserHandle user = Binder.getCallingUserHandle(); UserAccounts accounts = getUserAccountsForCaller(); long identityToken = clearCallingIdentity(); cancelNotification(getSigninRequiredNotificationId(accounts, account)); cancelNotification(getSigninRequiredNotificationId(accounts, account), user); synchronized(accounts.credentialsPermissionNotificationIds) { for (Pair<Pair<Account, String>, Integer> pair: accounts.credentialsPermissionNotificationIds.keySet()) { if (account.equals(pair.first.first)) { int id = accounts.credentialsPermissionNotificationIds.get(pair); cancelNotification(id); cancelNotification(id, user); } } } Loading Loading @@ -789,7 +790,8 @@ public class AccountManagerService if (account == null || type == null) { return false; } cancelNotification(getSigninRequiredNotificationId(accounts, account)); cancelNotification(getSigninRequiredNotificationId(accounts, account), new UserHandle(accounts.userId)); synchronized (accounts.cacheLock) { final SQLiteDatabase db = accounts.openHelper.getWritableDatabase(); db.beginTransaction(); Loading Loading @@ -1173,11 +1175,12 @@ public class AccountManagerService title = titleAndSubtitle.substring(0, index); subtitle = titleAndSubtitle.substring(index + 1); } UserHandle user = new UserHandle(userId); n.setLatestEventInfo(mContext, title, subtitle, PendingIntent.getActivityAsUser(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(userId))); installNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), n); PendingIntent.FLAG_CANCEL_CURRENT, null, user)); installNotification(getCredentialPermissionNotificationId( account, authTokenType, uid), n, user); } String getAccountLabel(String accountType) { Loading Loading @@ -1763,7 +1766,8 @@ public class AccountManagerService String accountType = result.getString(AccountManager.KEY_ACCOUNT_TYPE); if (!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(accountType)) { Account account = new Account(accountName, accountType); cancelNotification(getSigninRequiredNotificationId(mAccounts, account)); cancelNotification(getSigninRequiredNotificationId(mAccounts, account), new UserHandle(mAccounts.userId)); } } IAccountManagerResponse response; Loading Loading @@ -2101,30 +2105,32 @@ public class AccountManagerService intent.addCategory(String.valueOf(notificationId)); Notification n = new Notification(android.R.drawable.stat_sys_warning, null, 0 /* when */); UserHandle user = new UserHandle(userId); final String notificationTitleFormat = mContext.getText(R.string.notification_title).toString(); n.setLatestEventInfo(mContext, String.format(notificationTitleFormat, account.name), message, PendingIntent.getActivityAsUser( mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(userId))); installNotification(notificationId, n); null, user)); installNotification(notificationId, n, user); } } finally { restoreCallingIdentity(identityToken); } } protected void installNotification(final int notificationId, final Notification n) { protected void installNotification(final int notificationId, final Notification n, UserHandle user) { ((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(notificationId, n); .notifyAsUser(null, notificationId, n, user); } protected void cancelNotification(int id) { protected void cancelNotification(int id, UserHandle user) { long identityToken = clearCallingIdentity(); try { ((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE)) .cancel(id); .cancelAsUser(null, id, user); } finally { restoreCallingIdentity(identityToken); } Loading Loading @@ -2289,7 +2295,8 @@ public class AccountManagerService } finally { db.endTransaction(); } cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid)); cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), new UserHandle(accounts.userId)); } } Loading Loading @@ -2323,7 +2330,8 @@ public class AccountManagerService } finally { db.endTransaction(); } cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid)); cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), new UserHandle(accounts.userId)); } } Loading
core/java/android/app/PendingIntent.java +7 −1 Original line number Diff line number Diff line Loading @@ -265,6 +265,8 @@ public final class PendingIntent implements Parcelable { /** * @hide * Note that UserHandle.CURRENT will be interpreted at the time the * activity is started, not when the pending intent is created. */ public static PendingIntent getActivityAsUser(Context context, int requestCode, Intent intent, int flags, Bundle options, UserHandle user) { Loading Loading @@ -417,7 +419,11 @@ public final class PendingIntent implements Parcelable { new UserHandle(UserHandle.myUserId())); } /** @hide */ /** * @hide * Note that UserHandle.CURRENT will be interpreted at the time the * broadcast is sent, not when the pending intent is created. */ public static PendingIntent getBroadcastAsUser(Context context, int requestCode, Intent intent, int flags, UserHandle userHandle) { String packageName = context.getPackageName(); Loading
core/java/com/android/internal/statusbar/StatusBarNotification.java +2 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ public class StatusBarNotification implements Parcelable { public final int score; public final UserHandle user; /** This is temporarily needed for the JB MR1 PDK. */ @Deprecated public StatusBarNotification(String pkg, int id, String tag, int uid, int initialPid, int score, Notification notification) { Loading Loading @@ -143,6 +144,6 @@ public class StatusBarNotification implements Parcelable { /** Returns a userHandle for the instance of the app that posted this notification. */ public int getUserId() { return UserHandle.getUserId(this.uid); return this.user.getIdentifier(); } }
core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.pm.RegisteredServicesCache.ServiceInfo; import android.content.pm.RegisteredServicesCacheListener; import android.os.Bundle; import android.os.Handler; import android.os.UserHandle; import android.test.AndroidTestCase; import android.test.IsolatedContext; import android.test.RenamingDelegatingContext; Loading Loading @@ -243,11 +244,11 @@ public class AccountManagerServiceTest extends AndroidTestCase { } @Override protected void installNotification(final int notificationId, final Notification n) { protected void installNotification(final int notificationId, final Notification n, UserHandle user) { } @Override protected void cancelNotification(final int id) { protected void cancelNotification(final int id, UserHandle user) { } } }
packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +2 −1 Original line number Diff line number Diff line Loading @@ -293,7 +293,8 @@ public abstract class BaseStatusBar extends SystemUI implements Slog.v(TAG, String.format("%s: current userid: %d, notification userid: %d", n, thisUserId, notificationUserId)); } return thisUserId == notificationUserId; return notificationUserId == UserHandle.USER_ALL || thisUserId == notificationUserId; } protected View updateNotificationVetoButton(View row, StatusBarNotification n) { Loading