Search code examples
androidsecurityfocusdetectionfocus-stealing

how to detect and prevent focus stealing in android app


Q1: Is it possible to detect if another Android App is stealing the focus of your own App?

Q2: Is it possible to prevent another Android App from stealing the focus of your own App?

I only see the audio focus "take over" within the docs, but not the screen focus "take over": http://developer.android.com/training/managing-audio/audio-focus.html

See here why I ask these questions: http://blog.spiderlabs.com/2011/09/google-android-focus-stealing-vulnerabiltiy-demo.html


Solution

  • AFAIK, that post (and accompanying sophomoric video) is referring to the tapjacking attack, which was fixed in Android 4.0.3 (and possibly in Android 3.x).

    On Android 1.x/2.x, you cannot detect when another app has a window in front of yours and therefore may be stealing input. For Android 2.3, you can add android:filterTouchesWhenObscured="true" to a widget or container, which will prevent the affected widgets from receiving the touch events that had first been intercepted by the other app. This is not a perfect solution, but may be useful for critical fields like passwords.