2

i'm trying to create an accessibility service to use the autofill feature in the browsers on android.

My project is a flutter project but i'm currently working on my service in Kotlin. My problem is that the function 'onAccessibilityEvent' in my service is never called. I've been searching for days on Stackoverflow but none of the solutions worked for me. The function 'onServiceConnected' is called.

My service class:

class PasswordAutofillAccessService: AccessibilityService() {

    override fun onServiceConnected() {
        print("test service connected")
        super.onServiceConnected()
    }

    override fun onInterrupt() {
        print("test interrupt")
    }

    override fun onUnbind(intent: Intent?): Boolean {
        print("test unbind")
        return super.onUnbind(intent)        
    }

    override fun onAccessibilityEvent(event: AccessibilityEvent?) {
        print("test event")
    }

    override fun onRebind(intent: Intent?) {
        super.onRebind(intent)
    }
} 

My accessibility service configuration XML:

<accessibility-service
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityEventTypes="typeViewFocused|typeViewClicked"
    android:accessibilityFeedbackType="feedbackAllMask"
    android:canRequestEnhancedWebAccessibility="true"
    android:notificationTimeout="100"
    android:packageNames="net.company.my_app"
    android:description="@string/serviceDescription"
    android:canRetrieveWindowContent="true"
    android:accessibilityFlags="flagRetrieveInteractiveWindows"
    android:settingsActivity="net.company.my_app.AuthenticateActivity"
    />

In the AndroidManifest:

<service android:name=".PasswordAutofillAccessService"
            android:enabled="true"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
            android:label="Test app">
            <intent-filter>
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>
            <meta-data
                android:name="android.accessibilityservice"
                android:resource="@xml/accessibility_service" />
        </service>

I'm currently testing on a Pixel 3 with Android P (PQ3A.190705.003). I've tried with some others (API 26 & +) and it still have the problem.

Thanks for your help!

ViduraPrasangana
  • 858
  • 9
  • 17
Seb
  • 63
  • 7
  • you probably need to check if your service is enabled. have a look this link https://stackoverflow.com/questions/5081145/android-how-do-you-check-if-a-particular-accessibilityservice-is-enabled – Abdu Dec 03 '19 at 19:24
  • Thank you, there are only 3 implemented accessibility in Flutter. see: [Flutter accessibility](https://flutter.dev/docs/development/accessibility-and-localization/accessibility) – Seb Dec 05 '19 at 16:32
  • you probably need to check that accessibility permissions are granted. Accessibility settings can be turn on the service matching the respective label at Settings >Accessibility > My_Application_Name > Tap on the toggle to switch ON. – Abdu Jan 01 '20 at 14:24

0 Answers0