OSDN Git Service

Prevent apps to overlay other apps via toast windows
authorSvetoslav Ganov <svetoslavganov@google.com>
Tue, 2 Aug 2016 02:16:43 +0000 (19:16 -0700)
committerSvetoslav Ganov <svetoslavganov@google.com>
Fri, 2 Sep 2016 21:00:07 +0000 (14:00 -0700)
commitaa07653d2eea38a7a5bda5944c8a353586916ae9
treed2bcefb934b43f202c8809dd2d35d68bdbbdafdf
parent041d39d7448b3ffbc6311dd65395ec18a351f238
Prevent apps to overlay other apps via toast windows

It was possible for apps to put toast type windows
that overlay other apps which toast winodws aren't
removed after a timeout.

Now for apps targeting SDK greater than N MR1 to add a
toast window one needs to have a special token. The token
is added by the notificatoion manager service only for
the lifetime of the shown toast and is then removed
including all windows associated with this token. This
prevents apps to add arbitrary toast windows.

Since legacy apps may rely on the ability to directly
add toasts we mitigate by allowing these apps to still
add such windows for unlimited duration if this app is
the currently focused one, i.e. the user interacts with
it then it can overlay itself, otherwise we make sure
these toast windows are removed after a timeout like
a toast would be.

We don't allow more that one toast window per UID being
added at a time which prevents 1) legacy apps to put the
same toast after a timeout to go around our new policy
of hiding toasts after a while; 2) modern apps to reuse
the passed token to add more than one window; Note that
the notification manager shows toasts one at a time.

bug:30150688

Change-Id: Ia1dae626bd9e22541be46edb072aa288eb1ae414
core/java/android/app/ITransientNotification.aidl
core/java/android/view/SurfaceView.java
core/java/android/view/WindowManager.java
core/java/android/widget/Toast.java
services/core/java/com/android/server/notification/NotificationManagerService.java
services/core/java/com/android/server/policy/PhoneWindowManager.java
services/core/java/com/android/server/wm/DisplayContent.java
services/core/java/com/android/server/wm/WindowManagerService.java
services/core/java/com/android/server/wm/WindowState.java