diff options
author | Jeff Chang <chengjeff@google.com> | 2018-08-17 01:14:51 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-08-17 01:14:51 +0000 |
commit | 9744262ffa4effba26000ee182cc299fe7df84b2 (patch) | |
tree | 3412a57ee007ae31215b8242dbc9b9d77052d463 | |
parent | e5d363d85bb8afa077ba43c4908fc72a0886d5c8 (diff) | |
parent | 48ecef4bfb9db6328076ae159cab5c6720b1fc7e (diff) |
Merge "Support the toast Window to show on the secondary display."
-rw-r--r-- | config/hiddenapi-light-greylist.txt | 2 | ||||
-rw-r--r-- | config/hiddenapi-p-light-greylist.txt | 2 | ||||
-rw-r--r-- | core/java/android/app/INotificationManager.aidl | 2 | ||||
-rw-r--r-- | core/java/android/widget/Toast.java | 3 | ||||
-rw-r--r-- | services/art-profile | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/notification/NotificationManagerService.java | 39 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 2 |
7 files changed, 28 insertions, 24 deletions
diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt index 528c4dffa523..bbc91d2ebe62 100644 --- a/config/hiddenapi-light-greylist.txt +++ b/config/hiddenapi-light-greylist.txt @@ -177,7 +177,7 @@ Landroid/app/INotificationManager;->areNotificationsEnabledForPackage(Ljava/lang Landroid/app/INotificationManager;->cancelAllNotifications(Ljava/lang/String;I)V Landroid/app/INotificationManager;->cancelNotificationWithTag(Ljava/lang/String;Ljava/lang/String;II)V Landroid/app/INotificationManager;->cancelToast(Ljava/lang/String;Landroid/app/ITransientNotification;)V -Landroid/app/INotificationManager;->enqueueToast(Ljava/lang/String;Landroid/app/ITransientNotification;I)V +Landroid/app/INotificationManager;->enqueueToast(Ljava/lang/String;Landroid/app/ITransientNotification;II)V Landroid/app/INotificationManager;->getActiveNotifications(Ljava/lang/String;)[Landroid/service/notification/StatusBarNotification; Landroid/app/INotificationManager;->getHistoricalNotifications(Ljava/lang/String;I)[Landroid/service/notification/StatusBarNotification; Landroid/app/INotificationManager;->getZenMode()I diff --git a/config/hiddenapi-p-light-greylist.txt b/config/hiddenapi-p-light-greylist.txt index e360879ddc7b..e26a4c79320b 100644 --- a/config/hiddenapi-p-light-greylist.txt +++ b/config/hiddenapi-p-light-greylist.txt @@ -534,7 +534,7 @@ Landroid/app/INotificationManager$Stub;->asInterface(Landroid/os/IBinder;)Landro Landroid/app/INotificationManager;->cancelAllNotifications(Ljava/lang/String;I)V Landroid/app/INotificationManager;->cancelNotificationWithTag(Ljava/lang/String;Ljava/lang/String;II)V Landroid/app/INotificationManager;->cancelToast(Ljava/lang/String;Landroid/app/ITransientNotification;)V -Landroid/app/INotificationManager;->enqueueToast(Ljava/lang/String;Landroid/app/ITransientNotification;I)V +Landroid/app/INotificationManager;->enqueueToast(Ljava/lang/String;Landroid/app/ITransientNotification;II)V Landroid/app/IProcessObserver$Stub;-><init>()V Landroid/app/ISearchManager$Stub$Proxy;->getGlobalSearchActivity()Landroid/content/ComponentName; Landroid/app/ISearchManager$Stub$Proxy;->getWebSearchActivity()Landroid/content/ComponentName; diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl index cd127102f83b..3171e3e3b992 100644 --- a/core/java/android/app/INotificationManager.aidl +++ b/core/java/android/app/INotificationManager.aidl @@ -43,7 +43,7 @@ interface INotificationManager void cancelAllNotifications(String pkg, int userId); void clearData(String pkg, int uid, boolean fromApp); - void enqueueToast(String pkg, ITransientNotification callback, int duration); + void enqueueToast(String pkg, ITransientNotification callback, int duration, int displayId); void cancelToast(String pkg, ITransientNotification callback); void finishToken(String pkg, ITransientNotification callback); diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java index d74a60e483e5..7f481e3e681c 100644 --- a/core/java/android/widget/Toast.java +++ b/core/java/android/widget/Toast.java @@ -133,9 +133,10 @@ public class Toast { String pkg = mContext.getOpPackageName(); TN tn = mTN; tn.mNextView = mNextView; + final int displayId = mContext.getDisplay().getDisplayId(); try { - service.enqueueToast(pkg, tn, mDuration); + service.enqueueToast(pkg, tn, mDuration, displayId); } catch (RemoteException e) { // Empty } diff --git a/services/art-profile b/services/art-profile index cbc00ea53427..3c60eee4a2a9 100644 --- a/services/art-profile +++ b/services/art-profile @@ -13303,7 +13303,7 @@ PLcom/android/server/notification/NotificationManagerService$10;->createNotifica PLcom/android/server/notification/NotificationManagerService$10;->deleteNotificationChannel(Ljava/lang/String;Ljava/lang/String;)V PLcom/android/server/notification/NotificationManagerService$10;->enforcePolicyAccess(ILjava/lang/String;)V PLcom/android/server/notification/NotificationManagerService$10;->enforceSystemOrSystemUI(Ljava/lang/String;)V -PLcom/android/server/notification/NotificationManagerService$10;->enqueueToast(Ljava/lang/String;Landroid/app/ITransientNotification;I)V +PLcom/android/server/notification/NotificationManagerService$10;->enqueueToast(Ljava/lang/String;Landroid/app/ITransientNotification;II)V PLcom/android/server/notification/NotificationManagerService$10;->finishToken(Ljava/lang/String;Landroid/app/ITransientNotification;)V PLcom/android/server/notification/NotificationManagerService$10;->getAppActiveNotifications(Ljava/lang/String;I)Landroid/content/pm/ParceledListSlice; PLcom/android/server/notification/NotificationManagerService$10;->getBackupPayload(I)[B diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index b1b4c4fc9d3f..f0743192d65e 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -628,15 +628,17 @@ public class NotificationManagerService extends SystemService { final String pkg; final ITransientNotification callback; int duration; + int displayId; Binder token; ToastRecord(int pid, String pkg, ITransientNotification callback, int duration, - Binder token) { + Binder token, int displayId) { this.pid = pid; this.pkg = pkg; this.callback = callback; this.duration = duration; this.token = token; + this.displayId = displayId; } void update(int duration) { @@ -1986,11 +1988,12 @@ public class NotificationManagerService extends SystemService { // ============================================================================ @Override - public void enqueueToast(String pkg, ITransientNotification callback, int duration) + public void enqueueToast(String pkg, ITransientNotification callback, int duration, + int displayId) { if (DBG) { Slog.i(TAG, "enqueueToast pkg=" + pkg + " callback=" + callback - + " duration=" + duration); + + " duration=" + duration + " displayId=" + displayId); } if (pkg == null || callback == null) { @@ -2042,8 +2045,9 @@ public class NotificationManagerService extends SystemService { } Binder token = new Binder(); - mWindowManagerInternal.addWindowToken(token, TYPE_TOAST, DEFAULT_DISPLAY); - record = new ToastRecord(callingPid, pkg, callback, duration, token); + mWindowManagerInternal.addWindowToken(token, TYPE_TOAST, displayId); + record = new ToastRecord(callingPid, pkg, callback, duration, token, + displayId); mToastQueue.add(record); index = mToastQueue.size() - 1; keepProcessAliveIfNeededLocked(callingPid); @@ -2094,7 +2098,7 @@ public class NotificationManagerService extends SystemService { int index = indexOfToastLocked(pkg, callback); if (index >= 0) { ToastRecord record = mToastQueue.get(index); - finishTokenLocked(record.token); + finishTokenLocked(record.token, record.displayId); } else { Slog.w(TAG, "Toast already killed. pkg=" + pkg + " callback=" + callback); @@ -5231,13 +5235,13 @@ public class NotificationManagerService extends SystemService { ToastRecord lastToast = mToastQueue.remove(index); mWindowManagerInternal.removeWindowToken(lastToast.token, false /* removeWindows */, - DEFAULT_DISPLAY); + lastToast.displayId); // We passed 'false' for 'removeWindows' so that the client has time to stop // rendering (as hide above is a one-way message), otherwise we could crash // a client which was actively using a surface made from the token. However // we need to schedule a timeout to make sure the token is eventually killed // one way or another. - scheduleKillTokenTimeout(lastToast.token); + scheduleKillTokenTimeout(lastToast); keepProcessAliveIfNeededLocked(record.pid); if (mToastQueue.size() > 0) { @@ -5248,14 +5252,13 @@ public class NotificationManagerService extends SystemService { } } - void finishTokenLocked(IBinder t) { + void finishTokenLocked(IBinder t, int displayId) { mHandler.removeCallbacksAndMessages(t); // We pass 'true' for 'removeWindows' to let the WindowManager destroy any // remaining surfaces as either the client has called finishToken indicating // it has successfully removed the views, or the client has timed out // at which point anything goes. - mWindowManagerInternal.removeWindowToken(t, true /* removeWindows */, - DEFAULT_DISPLAY); + mWindowManagerInternal.removeWindowToken(t, true /* removeWindows */, displayId); } @GuardedBy("mToastQueue") @@ -5279,18 +5282,18 @@ public class NotificationManagerService extends SystemService { } @GuardedBy("mToastQueue") - private void scheduleKillTokenTimeout(IBinder token) + private void scheduleKillTokenTimeout(ToastRecord r) { - mHandler.removeCallbacksAndMessages(token); - Message m = Message.obtain(mHandler, MESSAGE_FINISH_TOKEN_TIMEOUT, token); + mHandler.removeCallbacksAndMessages(r); + Message m = Message.obtain(mHandler, MESSAGE_FINISH_TOKEN_TIMEOUT, r); mHandler.sendMessageDelayed(m, FINISH_TOKEN_TIMEOUT); } - private void handleKillTokenTimeout(IBinder token) + private void handleKillTokenTimeout(ToastRecord record) { - if (DBG) Slog.d(TAG, "Kill Token Timeout token=" + token); + if (DBG) Slog.d(TAG, "Kill Token Timeout token=" + record.token); synchronized (mToastQueue) { - finishTokenLocked(token); + finishTokenLocked(record.token, record.displayId); } } @@ -5484,7 +5487,7 @@ public class NotificationManagerService extends SystemService { handleDurationReached((ToastRecord)msg.obj); break; case MESSAGE_FINISH_TOKEN_TIMEOUT: - handleKillTokenTimeout((IBinder)msg.obj); + handleKillTokenTimeout((ToastRecord)msg.obj); break; case MESSAGE_SAVE_POLICY_FILE: handleSavePolicyFile(); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 42d6c8e4cbe7..e18d56485d47 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1365,7 +1365,7 @@ public class WindowManagerService extends IWindowManager.Stub // UID, otherwise we allow unlimited duration. When a UID looses focus we // schedule hiding all of its toast windows. if (type == TYPE_TOAST) { - if (!getDefaultDisplayContentLocked().canAddToastWindowForUid(callingUid)) { + if (!displayContent.canAddToastWindowForUid(callingUid)) { Slog.w(TAG_WM, "Adding more than one toast window for UID at a time."); return WindowManagerGlobal.ADD_DUPLICATE_ADD; } |