GithubHelp home page GithubHelp logo

Comments (16)

AdamNiederer avatar AdamNiederer commented on May 27, 2024 5

I believe I've figured it out: We can add a transparent overlay upon enabling the AccessibilityService, and then manipulate its color/transparency by sending events over an EventBus to the AccessibilityService as needed. Only thing left is to get it working with the app monitor and notification, and make the UX not terrible.

Partially completed code can be tracked here https://github.com/AdamNiederer/red-moon/tree/accessibility-overlay

from red-moon.

Yachont avatar Yachont commented on May 27, 2024 3

I found a solution to this for Android 12 users:

Using adb, type the following command:
adb shell settings put global block_untrusted_touches 0


This is documented here:
https://developer.android.com/about/versions/12/behavior-changes-all#untrusted-touch-events

If you need to setup ADB (Android Debug Bridge), here's a guide:
https://www.xda-developers.com/install-adb-windows-macos-linux/

from red-moon.

smichel17 avatar smichel17 commented on May 27, 2024 1

In general, there's many issues on modern Android that are not addressed, because my phone is still running 7.0.

This particular issue looks like it's related to this section:
https://developer.android.com/about/versions/12/behavior-changes-all#untrusted-touch-events

Look for the log message, Untrusted touch due to occlusion by PACKAGE_NAME

It seems like the only way around this would be to mark the app as an accessibility overlay. Honestly this is probably a better fit than TYPE_APPLICATION_OVERLAY, anyway.

I'd welcome a PR adapting Red Moon to be an accessibility service. This might also enable us to drop other workarounds, make it less likely that Red Moon will be killed due to running out of memory, etc.

from red-moon.

smichel17 avatar smichel17 commented on May 27, 2024 1

Yes, I think this would also fix #312, #253, and probably a couple other issues floating around with the api26+ tag.

For ease of implementation—

  • Switching from TYPE_APPLICATION_OVERLAY to TYPE_ACCESSIBILITY_OVERLAY is a simple find-and-replace.
  • I'm not 100% sure what's involved in otherwise declaring Red Moon as an accessibility service. Some research needed here.
    • The main open question is whether it just needs some tweaks to the AndroidManifest.xml and Overlay.kt, or whether the FilterService also needs to be updated and (if so) whether accessibility services follow the same lifecycle as regular services.
  • There may be some additional UI work needed. If accessibility service permission replaces the overlay permission, then it's minimal enough, but if the user needs to grant both, then we might want to update how the prompt works a little bit. Although, I would merge a less-than-perfect UX in this case — better than not working at all!

from red-moon.

AdamNiederer avatar AdamNiederer commented on May 27, 2024 1

I have a minimal PoC for this that enables the overlay as soon as the Accessibility Service is enabled, but I have no idea how to add the overlay view outside of the "privileged" context you get when enabling it. This passes all touches through, and draws over the notification shade, status/nav bars, and homescreen.

class OverlayAccessibilityService : AccessibilityService() {
    override fun onInterrupt() {}
    override fun onAccessibilityEvent(event: AccessibilityEvent?) {}
    override fun onServiceConnected() {
        val layout = (getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(R.layout.overlay_layout, null)
        val lp = WindowManager.LayoutParams().apply {
            type = WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY
            format = PixelFormat.TRANSLUCENT
            flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE.or(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
        }
        (getSystemService(WINDOW_SERVICE) as WindowManager).addView(layout, lp)
    }
}
        <service
            android:name=".OverlayAccessibilityService"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
            android:label="@string/overlay_accessibility_service_label"
            android:exported="true">
            <intent-filter>
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>
        </service>

The overlay layout can be literally any fullscreen layout with a translucent background.

I've tried making FilterService a subclass of AccessibilityService (they're all services, right?), but that won't let me set it. It seems like it has to be in one of the AccessibilityService-specific methods.

from red-moon.

AdamNiederer avatar AdamNiederer commented on May 27, 2024 1

I'm not sure I understand what the problem is with that patch actually? Presumably the overlay doesn't need to be edited outside of the privileged context?

That patch will enable the filter when you enable the accessibility service in your phone's settings, so to turn it off you'd have to go back into your settings and turn off the accessibility service. No timing it or turning it off/on from the app's activity or notification.

from red-moon.

gadgetguy08 avatar gadgetguy08 commented on May 27, 2024

Seeing same behavior on Android 12.

Did see this warning in the log:
type=1400 audit(0.0:27180): avc: denied { lock } for path="/apex/com.android.art/javalib/arm64/boot-bouncycastle.art" dev="dm-12" ino=141 scontext=u:r:untrusted_app_29:s0:c166,c256,c512,c768 tcontext=u:object_r:system_file:s0 tclass=file permissive=0 app=com.jmstudios.redmoon

and this note about bouncy castle and Android 12. Not sure if it applies or not:

https://developer.android.com/about/versions/12/behavior-changes-all#bouncy-castle

from red-moon.

hamishmb avatar hamishmb commented on May 27, 2024

The accessibility overlay thing would probably also fix the issues with the lock screen and notification bar not being filtered.

Is this easy to implement? If so, I might give it a go when I have some time, as I'm new to developing anything for Android.

from red-moon.

hamishmb avatar hamishmb commented on May 27, 2024

Okay, seeing as you're interested and have given me some pointers, I will see if I can find some time soonish to have a look at least and report back.

from red-moon.

IMPranshu avatar IMPranshu commented on May 27, 2024

Anyone working on this bug??? I am looking to start with this any tips will be very much helpful.

from red-moon.

smichel17 avatar smichel17 commented on May 27, 2024

I am looking to start with this any tips will be very much helpful.

I'm not sure what else you'd like to know besides the information I already shared. A good place to start would be researching what's needed for Red Moon to mark itself as an accessibility service.

from red-moon.

mateMathieu avatar mateMathieu commented on May 27, 2024

+1

from red-moon.

wombalton avatar wombalton commented on May 27, 2024

My Samsung s10se just got an update to Android 12. Now not any touch input is recognised on the screen area wich red moon overdraws. Luckily this is not the status and notification bar, so I'm able to turn redmoon of again ... I think this is related to the issues mentioned here.

I hope you guys find a fix quickly. At the moment red moon is unusable for me. Im sorry but I cannot code to help.

from red-moon.

hamishmb avatar hamishmb commented on May 27, 2024

I'm not sure I understand what the problem is with that patch actually? Presumably the overlay doesn't need to be edited outside of the privileged context?

from red-moon.

hamishmb avatar hamishmb commented on May 27, 2024

Ah, I see.

from red-moon.

hamishmb avatar hamishmb commented on May 27, 2024

Awesome :)

from red-moon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.