Search code examples
androidaccessibilityservice

Accessibility Overlay: Can't type in EditText field


I know accessibility overlays are a huge security concern, this is just a fun project I'm making for myself that will only run on my phone.

I have an overlay with an EditText in it. The problem is I can't type any text in that overlay. If I use the FLAG_LOCAL_FOCUS_MODE flag, I can type into that field with my desktop keyboard when running my app through the emulator. But I can't type into the field with the soft keyboard in the emulator or when I push the app to my phone.

I've looked around for this but I can't find anything. Am I missing a flag? Here's my [kotlin] code: (Thanks for your help.)

    val lp = WindowManager.LayoutParams()
    lp.gravity = Gravity.TOP
    lp.format = PixelFormat.TRANSLUCENT
    lp.width = WindowManager.LayoutParams.MATCH_PARENT
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT
    lp.type = WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY
    lp.flags = lp.flags or WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE

    val wm = getSystemService(WINDOW_SERVICE) as WindowManager
    wm.addView(overlayLayout, lp)

Solution

  • I've thought about it and I think after all the bad press of overlays being used to steal passwords and credit cards Android just started blocking all keyboard input to anything in an overlay.

    But I think my desktop keyboard still works because it's coming in as a different input or event that didn't get blocked so it behaves normally.

    Maybe this will save someone some hours some day...