How to protect sensitive-action confirmation in Android and test the interface
Confirmation of a sensitive action deserves testing as a separate user journey: what the person intends to authorize, which screen they see, and where they enter their credentials. This testing requires a distinction between protecting window content and restricting application overlays displayed over it. We will explain the purpose and limitations of the available measures and suggest a testing sequence using a fictional example, with no real operations or anyone else's data. The supplied documentation excerpts do not describe rejecting taps on obscured elements; the proposed test criteria do not imply that Android automatically provides this behavior.
Define the action and the trust boundary
Start with a specific task, such as confirming a change to settings that control access to sensitive information. Android documentation addresses protecting window content with FLAG_SECURE and restricting application overlays with HIDE_OVERLAY_WINDOWS separately. The following testing sequence is an editorial proposal based on that distinction, rather than a documented procedure: describe the expected user journey from reviewing changes to completing confirmation, including the outcome of the tap.
For the proposed test, draw the trust boundary between your application's interface and overlays from other applications. Consider them separately when evaluating the scenario. A protective setting alone is insufficient grounds to declare the confirmation secure: according to the documentation, FLAG_SECURE cannot be considered reliable protection against overlay attacks. Test the behavior of the selected screen and record the limits of the test.
Do not substitute FLAG_SECURE for overlay protection
FLAG_SECURE prevents screenshots and the display of the window on a non-secure display. That is a useful purpose, but the documentation explicitly states that this approach cannot be considered reliable protection against overlay attacks. Having the flag enabled should therefore not close out the task of testing confirmation of a sensitive action.
There is also a separate limitation: in some cases, FLAG_SECURE does not correctly detect whether screen recording is taking place. Keep these issues separate in requirements and reports. Screenshot testing addresses one aspect of behavior, while overlay testing addresses another. A successful observation in one test cannot automatically be applied to other scenarios.
Consider HIDE_OVERLAY_WINDOWS for Android 12
The HIDE_OVERLAY_WINDOWS permission was introduced in Android 12. It allows an application to opt out of having application overlays drawn over it. This scope is narrower than all windows from other applications. To enable this permission, the documentation instructs developers to add HIDE_OVERLAY_WINDOWS to the project manifest. This is the measure to consider separately when addressing restrictions on such overlays.
Begin implementation by checking the manifest and identifying the screens that require this behavior. Then test the result on the selected test configuration. Do not assume that capabilities introduced in Android 12 apply to earlier versions without separate confirmation: the supplied information is insufficient to describe equivalent protection for those versions.
Connect the credential request to sensitive information
When an application requests credentials to access sensitive information, the documentation recommends a PIN, password, pattern, or biometrics. Compare this recommendation with your scenario: whether access to such information is required, where the request occurs, and which option the product provides.
Do not present the choice of authentication method as proof of overlay protection. It is a separate decision that needs to be considered alongside window behavior. In the implementation task, explicitly distinguish credential requests, overlay restrictions, and protection of screen content so that each measure has a clear purpose and its own test criterion.
Fictional example: changing access in the “Mockup” application
Imagine a completely fictional application called “Mockup,” where a test user changes access settings for a demonstration archive. All records are synthetic, the password is for training purposes, and there are no real documents. This example uses the distinction in the documentation: FLAG_SECURE protects window content but is not considered reliable protection against overlays; HIDE_OVERLAY_WINDOWS applies to application overlays. The example's conditions and the criteria below are editorial proposals, not material taken from Android documentation.
The team defines two separate criteria for its product. When the confirmation element is obscured, a test tap must not change access: the state of the demonstration archive is checked, rather than just the visibility of the window. After the overlay is closed, the settings must remain unchanged until a new explicit confirmation, and a subsequent deliberate tap must complete the action according to the product requirements. If the overlay is not displayed, that is recorded separately: this result alone does not test tap handling when an overlay is present. This is a fictional example of requirements, not a promise of Android behavior or an account of a real incident.
Run the test in your own test environment
The documentation instructs developers to add HIDE_OVERLAY_WINDOWS to the manifest and limits the purpose of this measure to application overlays. To test the result, we propose the following editorial plan: use your own test build, a device or emulator owned by the team, and training data only. To observe overlays, use a test tool prepared by the team in advance. Do not reproduce other parties' authentication screens or collect real credentials. Limit testing to the agreed application scenario.
First, complete the confirmation without an overlay and record the baseline behavior and the final state of the test data. Then repeat the journey with a controlled overlay: record its visibility, the result of the test tap, and the state of the data separately. Close the overlay and check how the scenario resumes against the criteria in the fictional example. Separately test the build after the manifest change. Record the Android version, build settings, sequence of actions, and result of each observation. The supplied excerpts do not describe a mechanism for rejecting interactions with obscured elements; selecting and justifying such a mechanism requires relevant primary documentation. Observations from this test do not establish the security of the entire application.
Set priorities and state the limitations
The first priority is to correct the mistaken expectation that FLAG_SECURE reliably addresses overlays. Next, consider HIDE_OVERLAY_WINDOWS for Android 12 and test the actual behavior of the relevant screen with respect to application overlays. Separately, check the credential request for access to sensitive information against the recommendation to use a PIN, password, pattern, or biometrics.
Finish with a list of tested configurations and outstanding questions. These measures and observations do not justify promises of complete security or protection on every device. If your product has a website or web component, you can start with a free audit of it from CheckMyApp. That audit covers the web product; conclusions about Android interface behavior require separate testing.