There is a way to detect the some app is obscured my app, not by touch

yugico picture yugico · Mar 18, 2015 · Viewed 8.2k times · Source

I know there is a way to detect if some app overlays my app, i.e. touch filtering(flag android:filterTouchesWhenObscured) against hijacking attacks. If you want to create some policy to handle touches you may override the method

public boolean onFilterTouchEventForSecurity(MotionEvent event)

of the View. For example, you want to show some dialog if your app is obscured by an other window. But all of these solutions you can do if a user touches the view. I want to show some dialog when the user opens the app. Is it possible? Also I tried to emulate touch event, but I don't know where I can get MotionEvent.FLAG_WINDOW_IS_OBSCURED and after that to set to motion event flags.

And the second question: is there a way to say what app is obscuring my app? For example, I know there are a lot of apps, such as twilight, that add some filter over your display. They use specific permission (android.permission.SYSTEM_ALERT_WINDOW) to do it.

Thanks.

Answer