OSDN Git Service

Prevent apps to overlay other apps via toast windows
authorSvet Ganov <svetoslavganov@google.com>
Tue, 26 Jul 2016 18:41:42 +0000 (11:41 -0700)
committerSvetoslav Ganov <svetoslavganov@google.com>
Mon, 1 Aug 2016 18:46:02 +0000 (11:46 -0700)
commitdc24f937b031f5f4e153dbfeaa51e96415a09b71
treefdfddcf8359f3931bfd6a118bd6471d844916c79
parent94ae1e739fd84a308609fff3b913d0963900ed6e
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: Icc8f8dbd060762ae1a7b1720e96c5afdb8aff3fd
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/WindowManagerService.java
services/core/java/com/android/server/wm/WindowState.java