diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-09-23 17:08:57 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2012-09-24 10:55:46 -0700 |
commit | 50cdf7c3069eb2cf82acbad73c322b7a5f3af4b1 (patch) | |
tree | af1acc3ce0293d1ed797ecf0b7210464eb76e67c | |
parent | 6b3292ce5b3908c7433503f64c852cf2b27718ed (diff) | |
download | frameworks_base-50cdf7c3069eb2cf82acbad73c322b7a5f3af4b1.zip frameworks_base-50cdf7c3069eb2cf82acbad73c322b7a5f3af4b1.tar.gz frameworks_base-50cdf7c3069eb2cf82acbad73c322b7a5f3af4b1.tar.bz2 |
Fix issue #7214090: Need to be able to post notifications to all users
Also fix a bunch of system services that should be doing this. And
while doing that, found I needed to fix PendingIntent to evaluate
USER_CURRENT at the point of sending, not creation.
Note that this may end up with us having some notification shown to
non-primary users that lead to settings UI that should only be for
the primary user (such as the vpn notification). I'm not sure what
to do about this, maybe we need a different UI to come up there or
something, but showing the actual notification for those users at
least seems less broken than not telling them at all.
Change-Id: Iffc51e2d7c847e3d05064d292ab93937646a1ab7
17 files changed, 125 insertions, 65 deletions
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java index 9caf84f..fc569e0 100644 --- a/core/java/android/accounts/AccountManagerService.java +++ b/core/java/android/accounts/AccountManagerService.java @@ -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); } } } @@ -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(); @@ -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) { @@ -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; @@ -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); } @@ -2289,7 +2295,8 @@ public class AccountManagerService } finally { db.endTransaction(); } - cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid)); + cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), + new UserHandle(accounts.userId)); } } @@ -2323,7 +2330,8 @@ public class AccountManagerService } finally { db.endTransaction(); } - cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid)); + cancelNotification(getCredentialPermissionNotificationId(account, authTokenType, uid), + new UserHandle(accounts.userId)); } } diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java index 8fb6948..9d57467 100644 --- a/core/java/android/app/PendingIntent.java +++ b/core/java/android/app/PendingIntent.java @@ -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) { @@ -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(); diff --git a/core/java/com/android/internal/statusbar/StatusBarNotification.java b/core/java/com/android/internal/statusbar/StatusBarNotification.java index f9a38a5..a91aa3c 100644 --- a/core/java/com/android/internal/statusbar/StatusBarNotification.java +++ b/core/java/com/android/internal/statusbar/StatusBarNotification.java @@ -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) { @@ -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(); } } diff --git a/core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java b/core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java index 33a73b5..1d7576f 100644 --- a/core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java +++ b/core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java @@ -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; @@ -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) { } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index ecb8fed..dab6306 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -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) { diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java index 7dff549..c55b5bc 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java +++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java @@ -25,6 +25,7 @@ import android.content.res.Resources; import android.os.Environment; import android.os.Handler; import android.os.HandlerThread; +import android.os.UserHandle; import android.os.storage.StorageEventListener; import android.os.storage.StorageManager; import android.provider.Settings; @@ -311,7 +312,8 @@ public class StorageNotification extends StorageEventListener { mUsbStorageNotification.tickerText = title; if (pi == null) { Intent intent = new Intent(); - pi = PendingIntent.getBroadcast(mContext, 0, intent, 0); + pi = PendingIntent.getBroadcastAsUser(mContext, 0, intent, 0, + UserHandle.CURRENT); } mUsbStorageNotification.setLatestEventInfo(mContext, title, message, pi); @@ -336,9 +338,10 @@ public class StorageNotification extends StorageEventListener { final int notificationId = mUsbStorageNotification.icon; if (visible) { - notificationManager.notify(notificationId, mUsbStorageNotification); + notificationManager.notifyAsUser(null, notificationId, mUsbStorageNotification, + UserHandle.ALL); } else { - notificationManager.cancel(notificationId); + notificationManager.cancelAsUser(null, notificationId, UserHandle.ALL); } } @@ -398,7 +401,8 @@ public class StorageNotification extends StorageEventListener { mMediaStorageNotification.tickerText = title; if (pi == null) { Intent intent = new Intent(); - pi = PendingIntent.getBroadcast(mContext, 0, intent, 0); + pi = PendingIntent.getBroadcastAsUser(mContext, 0, intent, 0, + UserHandle.CURRENT); } mMediaStorageNotification.icon = icon; @@ -407,9 +411,10 @@ public class StorageNotification extends StorageEventListener { final int notificationId = mMediaStorageNotification.icon; if (visible) { - notificationManager.notify(notificationId, mMediaStorageNotification); + notificationManager.notifyAsUser(null, notificationId, + mMediaStorageNotification, UserHandle.ALL); } else { - notificationManager.cancel(notificationId); + notificationManager.cancelAsUser(null, notificationId, UserHandle.ALL); } } } diff --git a/services/java/com/android/server/DeviceStorageMonitorService.java b/services/java/com/android/server/DeviceStorageMonitorService.java index c919595..750a2fb 100644 --- a/services/java/com/android/server/DeviceStorageMonitorService.java +++ b/services/java/com/android/server/DeviceStorageMonitorService.java @@ -396,13 +396,15 @@ public class DeviceStorageMonitorService extends Binder { com.android.internal.R.string.low_internal_storage_view_title); CharSequence details = mContext.getText( com.android.internal.R.string.low_internal_storage_view_text); - PendingIntent intent = PendingIntent.getActivity(mContext, 0, lowMemIntent, 0); + PendingIntent intent = PendingIntent.getActivityAsUser(mContext, 0, lowMemIntent, 0, + null, UserHandle.CURRENT); Notification notification = new Notification(); notification.icon = com.android.internal.R.drawable.stat_notify_disk_full; notification.tickerText = title; notification.flags |= Notification.FLAG_NO_CLEAR; notification.setLatestEventInfo(mContext, title, details, intent); - mNotificationMgr.notify(LOW_MEMORY_NOTIFICATION_ID, notification); + mNotificationMgr.notifyAsUser(null, LOW_MEMORY_NOTIFICATION_ID, notification, + UserHandle.ALL); mContext.sendStickyBroadcast(mStorageLowIntent); } @@ -415,7 +417,7 @@ public class DeviceStorageMonitorService extends Binder { (NotificationManager)mContext.getSystemService( Context.NOTIFICATION_SERVICE); //cancel notification since memory has been freed - mNotificationMgr.cancel(LOW_MEMORY_NOTIFICATION_ID); + mNotificationMgr.cancelAsUser(null, LOW_MEMORY_NOTIFICATION_ID, UserHandle.ALL); mContext.removeStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL); mContext.sendBroadcastAsUser(mStorageOkIntent, UserHandle.ALL); diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index 71e6e66..bab4f7a 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -53,7 +53,6 @@ import android.os.ServiceManager; import android.os.UserHandle; import android.os.Vibrator; import android.provider.Settings; -import android.service.dreams.IDreamManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.AtomicFile; @@ -890,7 +889,7 @@ public class NotificationManagerService extends INotificationManager.Stub final boolean isSystemNotification = ("android".equals(pkg)); userId = ActivityManager.handleIncomingUser(callingPid, - callingUid, userId, false, true, "enqueueNotification", pkg); + callingUid, userId, true, true, "enqueueNotification", pkg); // Limit the number of notifications that any given package except the android // package can enqueue. Prevents DOS attacks and deals with leaks. @@ -900,7 +899,7 @@ public class NotificationManagerService extends INotificationManager.Stub final int N = mNotificationList.size(); for (int i=0; i<N; i++) { final NotificationRecord r = mNotificationList.get(i); - if (r.pkg.equals(pkg)) { + if (r.pkg.equals(pkg) && r.userId == userId) { count++; if (count >= MAX_PACKAGE_NOTIFICATIONS) { Slog.e(TAG, "Package has already posted " + count @@ -1261,7 +1260,7 @@ public class NotificationManagerService extends INotificationManager.Stub public void cancelNotificationWithTag(String pkg, String tag, int id, int userId) { checkCallerIsSystemOrSameApp(pkg); userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), - Binder.getCallingUid(), userId, false, true, "cancelNotificationWithTag", pkg); + Binder.getCallingUid(), userId, true, true, "cancelNotificationWithTag", pkg); // Don't allow client applications to cancel foreground service notis. cancelNotification(pkg, tag, id, 0, Binder.getCallingUid() == Process.SYSTEM_UID diff --git a/services/java/com/android/server/ThrottleService.java b/services/java/com/android/server/ThrottleService.java index 49f39fe..f36d73a 100644 --- a/services/java/com/android/server/ThrottleService.java +++ b/services/java/com/android/server/ThrottleService.java @@ -670,7 +670,8 @@ public class ThrottleService extends IThrottleManager.Stub { intent.setClassName("com.android.phone", "com.android.phone.DataUsage"); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); - PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0); + PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0, intent, 0, + null, UserHandle.CURRENT); Resources r = Resources.getSystem(); CharSequence title = r.getText(titleInt); @@ -686,7 +687,8 @@ public class ThrottleService extends IThrottleManager.Stub { mThrottlingNotification.tickerText = title; mThrottlingNotification.setLatestEventInfo(mContext, title, message, pi); - mNotificationManager.notify(mThrottlingNotification.icon, mThrottlingNotification); + mNotificationManager.notifyAsUser(null, mThrottlingNotification.icon, + mThrottlingNotification, UserHandle.ALL); } @@ -701,7 +703,8 @@ public class ThrottleService extends IThrottleManager.Stub { Intent broadcast = new Intent(ThrottleManager.THROTTLE_ACTION); broadcast.putExtra(ThrottleManager.EXTRA_THROTTLE_LEVEL, -1); mContext.sendStickyBroadcastAsUser(broadcast, UserHandle.ALL); - mNotificationManager.cancel(R.drawable.stat_sys_throttled); + mNotificationManager.cancelAsUser(null, R.drawable.stat_sys_throttled, + UserHandle.ALL); mWarningNotificationSent = false; } } diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java index 3e83baa..85a6e41 100644 --- a/services/java/com/android/server/UiModeManagerService.java +++ b/services/java/com/android/server/UiModeManagerService.java @@ -521,10 +521,13 @@ class UiModeManagerService extends IUiModeManager.Stub { mContext, mContext.getString(R.string.car_mode_disable_notification_title), mContext.getString(R.string.car_mode_disable_notification_message), - PendingIntent.getActivity(mContext, 0, carModeOffIntent, 0)); - mNotificationManager.notify(0, n); + PendingIntent.getActivityAsUser(mContext, 0, carModeOffIntent, 0, + null, UserHandle.CURRENT)); + mNotificationManager.notifyAsUser(null, + R.string.car_mode_disable_notification_title, n, UserHandle.ALL); } else { - mNotificationManager.cancel(0); + mNotificationManager.cancelAsUser(null, + R.string.car_mode_disable_notification_title, UserHandle.ALL); } } } diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index 5c38e63..024c8fd 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -1766,8 +1766,9 @@ public class WifiService extends IWifiManager.Stub { mNotification.when = 0; mNotification.icon = ICON_NETWORKS_AVAILABLE; mNotification.flags = Notification.FLAG_AUTO_CANCEL; - mNotification.contentIntent = PendingIntent.getActivity(mContext, 0, - new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK), 0); + mNotification.contentIntent = PendingIntent.getActivityAsUser(mContext, 0, + new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK), 0, + null, UserHandle.CURRENT); } CharSequence title = mContext.getResources().getQuantityText( @@ -1779,9 +1780,10 @@ public class WifiService extends IWifiManager.Stub { mNotificationRepeatTime = System.currentTimeMillis() + NOTIFICATION_REPEAT_DELAY_MS; - notificationManager.notify(ICON_NETWORKS_AVAILABLE, mNotification); + notificationManager.notifyAsUser(null, ICON_NETWORKS_AVAILABLE, mNotification, + UserHandle.ALL); } else { - notificationManager.cancel(ICON_NETWORKS_AVAILABLE); + notificationManager.cancelAsUser(null, ICON_NETWORKS_AVAILABLE, UserHandle.ALL); } mNotificationShown = visible; diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index a6f2974..a21f6d5 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -4595,8 +4595,16 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized(this) { int callingUid = Binder.getCallingUid(); + int origUserId = userId; userId = handleIncomingUserLocked(Binder.getCallingPid(), callingUid, userId, - false, true, "getIntentSender", null); + type == ActivityManager.INTENT_SENDER_BROADCAST, true, + "getIntentSender", null); + if (origUserId == UserHandle.USER_CURRENT) { + // We don't want to evaluate this until the pending intent is + // actually executed. However, we do want to always do the + // security checking for it above. + userId = UserHandle.USER_CURRENT; + } try { if (callingUid != 0 && callingUid != Process.SYSTEM_UID) { int uid = AppGlobals.getPackageManager() @@ -14303,6 +14311,10 @@ public final class ActivityManagerService extends ActivityManagerNative } } + int getCurrentUserIdLocked() { + return mCurrentUserId; + } + @Override public boolean isUserRunning(int userId) { if (checkCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java index c61f13c..8ee303f 100644 --- a/services/java/com/android/server/am/PendingIntentRecord.java +++ b/services/java/com/android/server/am/PendingIntentRecord.java @@ -25,6 +25,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; +import android.os.UserHandle; import android.util.Slog; import java.io.PrintWriter; @@ -220,6 +221,10 @@ class PendingIntentRecord extends IIntentSender.Stub { final long origId = Binder.clearCallingIdentity(); boolean sendFinish = finishedReceiver != null; + int userId = key.userId; + if (userId == UserHandle.USER_CURRENT) { + userId = owner.getCurrentUserIdLocked(); + } switch (key.type) { case ActivityManager.INTENT_SENDER_ACTIVITY: if (options == null) { @@ -242,10 +247,10 @@ class PendingIntentRecord extends IIntentSender.Stub { allIntents[allIntents.length-1] = finalIntent; allResolvedTypes[allResolvedTypes.length-1] = resolvedType; owner.startActivitiesInPackage(uid, allIntents, - allResolvedTypes, resultTo, options, key.userId); + allResolvedTypes, resultTo, options, userId); } else { owner.startActivityInPackage(uid, finalIntent, resolvedType, - resultTo, resultWho, requestCode, 0, options, key.userId); + resultTo, resultWho, requestCode, 0, options, userId); } } catch (RuntimeException e) { Slog.w(ActivityManagerService.TAG, @@ -263,7 +268,7 @@ class PendingIntentRecord extends IIntentSender.Stub { owner.broadcastIntentInPackage(key.packageName, uid, finalIntent, resolvedType, finishedReceiver, code, null, null, - requiredPermission, (finishedReceiver != null), false, key.userId); + requiredPermission, (finishedReceiver != null), false, userId); sendFinish = false; } catch (RuntimeException e) { Slog.w(ActivityManagerService.TAG, @@ -273,7 +278,7 @@ class PendingIntentRecord extends IIntentSender.Stub { case ActivityManager.INTENT_SENDER_SERVICE: try { owner.startServiceInPackage(uid, - finalIntent, resolvedType, key.userId); + finalIntent, resolvedType, userId); } catch (RuntimeException e) { Slog.w(ActivityManagerService.TAG, "Unable to send startService intent", e); diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java index 79fb458..d8f3546 100644 --- a/services/java/com/android/server/connectivity/Tethering.java +++ b/services/java/com/android/server/connectivity/Tethering.java @@ -461,7 +461,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub { intent.setClassName("com.android.settings", "com.android.settings.TetherSettings"); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); - PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0); + PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0, intent, 0, + null, UserHandle.CURRENT); Resources r = Resources.getSystem(); CharSequence title = r.getText(com.android.internal.R.string.tethered_notification_title); @@ -478,14 +479,16 @@ public class Tethering extends INetworkManagementEventObserver.Stub { mTetheredNotification.tickerText = title; mTetheredNotification.setLatestEventInfo(mContext, title, message, pi); - notificationManager.notify(mTetheredNotification.icon, mTetheredNotification); + notificationManager.notifyAsUser(null, mTetheredNotification.icon, + mTetheredNotification, UserHandle.ALL); } private void clearTetheredNotification() { NotificationManager notificationManager = (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null && mTetheredNotification != null) { - notificationManager.cancel(mTetheredNotification.icon); + notificationManager.cancelAsUser(null, mTetheredNotification.icon, + UserHandle.ALL); mTetheredNotification = null; } } diff --git a/services/java/com/android/server/connectivity/Vpn.java b/services/java/com/android/server/connectivity/Vpn.java index b3cbb84..03ff21f 100644 --- a/services/java/com/android/server/connectivity/Vpn.java +++ b/services/java/com/android/server/connectivity/Vpn.java @@ -50,6 +50,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemService; +import android.os.UserHandle; import android.security.Credentials; import android.security.KeyStore; import android.util.Log; @@ -421,7 +422,7 @@ public class Vpn extends BaseNetworkStateTracker { .setDefaults(0) .setOngoing(true) .build(); - nm.notify(R.drawable.vpn_connected, notification); + nm.notifyAsUser(null, R.drawable.vpn_connected, notification, UserHandle.ALL); } } @@ -433,7 +434,7 @@ public class Vpn extends BaseNetworkStateTracker { mContext.getSystemService(Context.NOTIFICATION_SERVICE); if (nm != null) { - nm.cancel(R.drawable.vpn_connected); + nm.cancelAsUser(null, R.drawable.vpn_connected, UserHandle.ALL); } } diff --git a/services/java/com/android/server/input/InputManagerService.java b/services/java/com/android/server/input/InputManagerService.java index 3709314..948c0e0 100644 --- a/services/java/com/android/server/input/InputManagerService.java +++ b/services/java/com/android/server/input/InputManagerService.java @@ -58,6 +58,7 @@ import android.os.Message; import android.os.MessageQueue; import android.os.Process; import android.os.RemoteException; +import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.util.Log; @@ -660,7 +661,8 @@ public class InputManagerService extends IInputManager.Stub intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); - mKeyboardLayoutIntent = PendingIntent.getActivity(mContext, 0, intent, 0); + mKeyboardLayoutIntent = PendingIntent.getActivityAsUser(mContext, 0, + intent, 0, null, UserHandle.CURRENT); } Resources r = mContext.getResources(); @@ -673,8 +675,9 @@ public class InputManagerService extends IInputManager.Stub .setSmallIcon(R.drawable.ic_settings_language) .setPriority(Notification.PRIORITY_LOW) .build(); - mNotificationManager.notify(R.string.select_keyboard_layout_notification_title, - notification); + mNotificationManager.notifyAsUser(null, + R.string.select_keyboard_layout_notification_title, + notification, UserHandle.ALL); mKeyboardLayoutNotificationShown = true; } } @@ -683,7 +686,9 @@ public class InputManagerService extends IInputManager.Stub private void hideMissingKeyboardLayoutNotification() { if (mKeyboardLayoutNotificationShown) { mKeyboardLayoutNotificationShown = false; - mNotificationManager.cancel(R.string.select_keyboard_layout_notification_title); + mNotificationManager.cancelAsUser(null, + R.string.select_keyboard_layout_notification_title, + UserHandle.ALL); } } diff --git a/services/java/com/android/server/usb/UsbDeviceManager.java b/services/java/com/android/server/usb/UsbDeviceManager.java index 392d5e7..8f13501 100644 --- a/services/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/java/com/android/server/usb/UsbDeviceManager.java @@ -667,7 +667,8 @@ public class UsbDeviceManager { if (id != mUsbNotificationId) { // clear notification if title needs changing if (mUsbNotificationId != 0) { - mNotificationManager.cancel(mUsbNotificationId); + mNotificationManager.cancelAsUser(null, mUsbNotificationId, + UserHandle.ALL); mUsbNotificationId = 0; } if (id != 0) { @@ -688,10 +689,11 @@ public class UsbDeviceManager { Intent intent = Intent.makeRestartActivityTask( new ComponentName("com.android.settings", "com.android.settings.UsbSettings")); - PendingIntent pi = PendingIntent.getActivity(mContext, 0, - intent, 0); + PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0, + intent, 0, null, UserHandle.CURRENT); notification.setLatestEventInfo(mContext, title, message, pi); - mNotificationManager.notify(id, notification); + mNotificationManager.notifyAsUser(null, id, notification, + UserHandle.ALL); mUsbNotificationId = id; } } @@ -722,15 +724,16 @@ public class UsbDeviceManager { Intent intent = Intent.makeRestartActivityTask( new ComponentName("com.android.settings", "com.android.settings.DevelopmentSettings")); - PendingIntent pi = PendingIntent.getActivity(mContext, 0, - intent, 0); + PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0, + intent, 0, null, UserHandle.CURRENT); notification.setLatestEventInfo(mContext, title, message, pi); mAdbNotificationShown = true; - mNotificationManager.notify(id, notification); + mNotificationManager.notifyAsUser(null, id, notification, + UserHandle.ALL); } } else if (mAdbNotificationShown) { mAdbNotificationShown = false; - mNotificationManager.cancel(id); + mNotificationManager.cancelAsUser(null, id, UserHandle.ALL); } } |