cd /news/ai-agents/how-to-keep-os-ai-agents-out-of-your… · home › topics › ai-agents › article
[ARTICLE · art-174156] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

How to Keep OS AI Agents Out of Your App's Sensitive Screens

A developer-written guide explains how app builders can shield sensitive screens from OS-level AI agents, following Signal's November 20 announcement that it will block screenshots by default in its iOS 27 app and enable Android's Screen security when an AI assistant attempts to read the screen. The piece splits the exposure into three paths — pixel capture, view-hierarchy access via Android's Assist and accessibility APIs, and data that never reaches the screen — and details Android controls such as FLAG_SECURE, which the Assist API documentation says prevents automatically collected screen content from being passed to an assistant unless the window is flagged secure.

recommendation

Apply FLAG_SECURE to every window, including dialogs, in apps handling messages, banking or health data, since Android's Assist API otherwise hands screen content to the active AI assistant.

more in playbook: Securing agents and AI tools
by read11 min views1 publishedNov 22, 2026

End-to-end encryption protects a message on the wire and on disk. It does not protect the message while it sits on the screen. At that point the operating system can see it, and so can any AI agent the operating system lets in.

On November 20, Signal said it would block screenshots in its iOS 27 app by default, and turn on its "Screen security" setting on Android when it detects an AI assistant trying to read the screen. Signal's announcement names Gemini on Android and Siri AI's Onscreen Awareness on iOS, and calls OS-level AI agents "an existential threat" to its mission. TechCrunch covered it the next day, and the Hacker News thread passed 570 points.

Most of the coverage is about Signal. This article is about your app. If you build a banking app, a health app, a password manager, or a chat feature inside a bigger product, the same question applies to you: what can you actually stop, on which platform, and with which API? The answers below come from the official Android, Apple, Microsoft and Electron documentation, and from Signal's own posts.

It helps to split the problem into three paths, because each one needs a different control.

Pixels. The agent takes a screenshot or reads a screen recording, then runs it through a model. Microsoft Recall works this way on Windows: Signal's footnote describes it as capturing the screen every few seconds and pulling text out with OCR (optical character recognition, turning an image of text into real text). Signal says screenshots are "how most agentic systems access data from applications like Signal."

Structure. The agent asks the OS for the view hierarchy (the tree of buttons, labels and text fields) instead of the image. On Android, the Assist API hands the active assistant an AssistStructure with the text and view tree of the current screen. The accessibility API gives a similar tree to any accessibility service the user has turned on. Signal's post names Meta's Muse as an example of a third-party agent that gets in through the deep permissions users grant during setup. In many cases, Signal says, those are accessibility settings, used as "a skeleton key."

Data that never reaches the screen. Notifications, files on disk, and other OS frameworks and APIs. Signal says plainly that screenshot blocking "does not address other more sneaky ways AI agents could potentially access application data, such as retrieving content already present on a user's device via the filesystem."

Screen protection only covers the first path fully, and the second path partly. Keep that in mind as you read the platform sections.

Android gives you the most controls, and they are documented. Here they are in the order you will probably need them.

FLAG_SECURE is a window flag. The Android fraud-prevention guide says it "tells Android not to allow screenshots or to display the window view on a non-secure display (such as Casting the screen)." A screenshot of a secure window comes out blank.

It also matters for assistants. The Assist API guide says the system passes automatically collected screen content to the assistant "unless the current window is flagged as secure."

class ChatActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.setFlags(
            WindowManager.LayoutParams.FLAG_SECURE,
            WindowManager.LayoutParams.FLAG_SECURE
        )
        setContentView(R.layout.activity_chat)
    }
}

Three details from the docs are easy to miss:

FLAG_SECURE explicitly for every window created by the activity, including dialogs," and that "there is no global (app-level) mechanism to exclude all views from the assistant." For a SurfaceView, use setSecure(). onProvideAssistContent() or onProvideAssistData(), it can still hand data to the assistant itself. On a sensitive screen, do not put message text or account numbers into those callbacks. The Android 14 screenshot guide also recommends a setting that lets users switch the flag. Signal does exactly that. To turn it off at runtime, call window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE).

Blocking every screenshot of every screen is heavy. Android 15 (API 35) added View.setContentSensitivity(). The View reference says the system will "hide content drawn by a sensitive view from screen sharing and recording," and that "the window hosting a sensitive view will be marked as secure during an active media projection session."

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
    otpField.setContentSensitivity(View.CONTENT_SENSITIVITY_SENSITIVE)
}

Note the scope: this kicks in during media projection, which means screen sharing and screen recording. It is a lighter option for login and payment forms. It is not a full replacement for FLAG_SECURE when your threat is a screenshot-based assistant.

This is the closest thing Android has to an answer for the "skeleton key" problem. Android 14 (API 34) added View.setAccessibilityDataSensitive(). Per the View reference, it "specifies whether this view should only allow interactions from AccessibilityServices with the AccessibilityServiceInfo.isAccessibilityTool() property set to true."

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
    messageList.setAccessibilityDataSensitive(
        View.ACCESSIBILITY_DATA_SENSITIVE_YES
    )
}

Who gets to set isAccessibilityTool? Google Play's accessibility API policy says: "Only services that are designed to help people with disabilities access their device or otherwise overcome challenges stemming from their disabilities are eligible to declare that they are accessibility tools."

So a screen reader built for people with disabilities can keep working, while a general-purpose service that is not a declared accessibility tool is shut out of that view. Two limits: it only protects the views you mark, and the flag is self-declared. Play's policy says it is set "using the isAccessibilityTool attribute in the service's metadata file," and the check on that claim is Google Play's review, not the API.

Sometimes you want to know when capture happens rather than block it. Android has two callbacks.

Screenshot detection arrived in Android 14. You declare the install-time permission android.permission.DETECT_SCREEN_CAPTURE, then register a callback per activity:

private val screenCaptureCallback = Activity.ScreenCaptureCallback {
    // Warn the user, or tell the other side of the chat.
}

override fun onStart() {
    super.onStart()
    registerScreenCaptureCallback(mainExecutor, screenCaptureCallback)
}

override fun onStop() {
    super.onStop()
    unregisterScreenCaptureCallback(screenCaptureCallback)
}

Read the limits on the screenshot detection page before you rely on it. The callback fires only for screenshots taken with "a specific combination of hardware button presses." It does not fire for ADB or instrumentation test captures. It also does not give you the image. So it tells you about a person pressing buttons, not about an agent grabbing pixels in the background.

Screen recording detection arrived in Android 15. It needs the DETECT_SCREEN_RECORDING permission, and the callback runs whenever your app becomes visible or invisible in a recording:

private val recordingCallback = Consumer<Int> { state ->
    if (state == WindowManager.SCREEN_RECORDING_STATE_VISIBLE) {
        // Hide sensitive content or show a notice.
    }
}

override fun onStart() {
    super.onStart()
    val initialState =
        windowManager.addScreenRecordingCallback(mainExecutor, recordingCallback)
    recordingCallback.accept(initialState)
}

override fun onStop() {
    super.onStop()
    windowManager.removeScreenRecordingCallback(recordingCallback)
}

Signal's footnote explains why it did not simply block screenshots everywhere on Android. Android ships in many vendor versions, and on many of them Signal has no reliable way to detect a screenshot attempt once screenshots are already disabled. Rather than make screenshots silently fail and confuse users, Signal turns on Screen security automatically when it detects an AI assistant trying to access the screen. Signal has not published how that detection works, so do not assume one of the public callbacks above is the whole story.

The documented iOS controls are thinner. In the UIKit APIs covered here, you can learn that capture is happening, but you cannot stop a screenshot.

After a screenshot. UIApplication.userDidTakeScreenshotNotification fires, but Apple's docs say it "posts after the screenshot is taken." Use it to warn or to notify the other party, not to protect anything.

NotificationCenter.default.addObserver(
    forName: UIApplication.userDidTakeScreenshotNotification,
    object: nil,
    queue: .main
) { _ in
    // The screenshot already exists. Warn or log here.
}

During recording or mirroring. The old UIScreen.isCaptured property is marked deprecated as of iOS 27. Apple's docs point to sceneCaptureState, a trait available since iOS 17 that "represents whether a scene is currently being mirrored or recorded." Its values are .active, .inactive and .unspecified. When it turns .active, you can cover sensitive views with a placeholder.

registerForTraitChanges([UITraitSceneCaptureState.self]) { (self: Self, _: UITraitCollection) in
    let captured = self.traitCollection.sceneCaptureState == .active
    self.sensitiveContainer.isHidden = captured
}

Signal does block screenshots in its iOS 27 app, with a "Block Siri AI" setting, but its post does not say which mechanism it uses. If you need the same result, treat it as an open question to test on real devices, not as a documented API.

The user-side switch. Since iOS 27.2 there is a per-app control. The EFF describes it as Settings > Siri > Excluded Apps. Once an app is excluded, "Siri AI cannot access the contents of the app," and even Onscreen Awareness stops working inside it. Neither Signal nor the EFF describes a way for an app to turn this on by itself. What you can do is tell users about it, for example in a privacy section of your settings screen or during onboarding.

Windows. The control is SetWindowDisplayAffinity with WDA_EXCLUDEFROMCAPTURE. The Win32 reference says the window is then shown only on a monitor and "everywhere else, the window does not appear at all." It is supported from Windows 10 version 2004. On older versions it behaves like WDA_MONITOR, which shows the window as empty in captures. Microsoft's Recall admin guide says that with this flag, "the window content won't show up in Recall or any other screenshot application." Signal Desktop has used this approach on Windows 11 by default since 2025, as its Recall post describes.

If your desktop app is built on Electron, you do not need Win32 code. The Electron BrowserWindow docs say win.setContentProtection(true) "prevents the window contents from being captured by other apps," and on Windows it calls SetWindowDisplayAffinity with WDA_EXCLUDEFROMCAPTURE.

const { app, BrowserWindow } = require('electron')

app.whenReady().then(() => {
  const win = new BrowserWindow({ width: 1000, height: 700 })
  win.setContentProtection(true)
  win.loadFile('index.html')
})

The Electron docs add one timing detail: the change "takes effect with the next desktop composition, not when the call returns." Set protection when you create the window. Do not wait until sensitive data is on screen.

macOS. This is the gap Signal could not close. Electron's docs say that on macOS the same call sets the NSWindow sharingType to none, but "newer Mac applications that use ScreenCaptureKit will capture your window despite win.setContentProtection(true)." Signal's post goes further: protections against continuous screen capture exist on macOS, but Signal "cannot reliably block screenshots," which is how most agents read app data. Its only advice for macOS 27 users is the same user-side switch: add Signal to System Settings > Siri > Excluded Apps.

Even with every control above in place, three paths stay open.

One commenter in the HN thread put the dependency simply: "Any protection against this requires OS support." (comment)

Blocking capture has real costs, and Signal's own posts are open about them.

Accessibility users. In its Recall post, Signal noted that "some accessibility software (such as screen readers or magnification tools for people who are visually impaired) may not function correctly" with screen security on. Test your protected screens with TalkBack, VoiceOver and screen magnifiers. On Android, setAccessibilityDataSensitive is designed to keep declared accessibility tools working while shutting out other services, which is one reason to prefer it over blanket blocking for the accessibility path.

Users who need screenshots. Bug reports, receipts, and sharing a funny message are normal uses. Signal lets users disable the protection, and on Windows it shows a warning and asks for confirmation before turning it off. That is a good pattern to copy: protected by default, easy to change, hard to change by accident.

Silent failure. A screenshot that comes out black looks like a bug. Signal chose its Android approach partly to avoid "a poor user experience (where screenshots simply stop working, confusing users)." If you block screenshots, say so somewhere the user will see it.

setAccessibilityDataSensitive (API 34+) to the views that hold the data, and setContentSensitivity (API 35+) to login and payment fields.sceneCaptureState and hide sensitive views while the screen is recorded or mirrored. Handle userDidTakeScreenshotNotification if your product needs to warn people.setContentProtection(true) or SetWindowDisplayAffinity with WDA_EXCLUDEFROMCAPTURE at window creation. Signal described itself as "the canary in the coal mine." By its own account it spent "considerable developer time" over the past few months on forensic investigations across Android and iOS, and it still could not cover macOS or every Android device. A smaller app will hit the same walls. The difference is whether you find out now, from the docs, or later, from a user.

Which screens in your app would you protect first, and has an OS assistant already read one of them?

[1] Signal: Signal is Serious About Protecting Your Privacy

[3] Hacker News discussion of Signal's post

[4] Android Developers: Secure sensitive activities

[5] Android Developers: Optimizing contextual content for the Assistant

[6] Android Developers: Detect when users take device screenshots

[7] Android Developers: Android 15 features and APIs

[8] Android Developers: View reference

[9] Google Play: Use of the AccessibilityService API

[10] Apple Developer: userDidTakeScreenshotNotification

[11] Apple Developer: sceneCaptureState

[12] Apple Developer: isCaptured

[13] EFF: Victory! You Can Now Exclude Apps from Siri AI

[14] Microsoft Learn: SetWindowDisplayAffinity function

[15] Microsoft Learn: Manage Recall

── more in #ai-agents 4 stories · sorted by recency
── more on @signal 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-to-keep-os-ai-ag…] indexed:0 read:11min 2026-11-22 · —