I'm doing some task with the accessibility service. All works great, but I need to remove the configuration of my xml and run the service from the onServiConnected configuration method and here is where I have the problem.
I can see in the log that onServiceConnected work when I enable the service in my phone, but it doesn't work with the package name like where I run the configuration in the access_xml_config.
Then, that I want to do is have same functionality that I have from the access_xml_config but in the onServiceConnected method.
My method:
@Override
    @SuppressLint("NewApi")
    public void onServiceConnected() {
        super.onServiceConnected();
        Log.i(TAG, "onServiceConnected AccessibilityService");
        AccessibilityServiceInfo info = new AccessibilityServiceInfo();
        info.flags = AccessibilityServiceInfo.DEFAULT;
        info.getCanRetrieveWindowContent();
        info.notificationTimeout = 100;
        info.feedbackType = AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
        info.feedbackType = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
        info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
        info.feedbackType = AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
        info.packageNames = new String[]{"com.android.incallui"};
        this.setServiceInfo(info);
    }
Manifest
 <service android:name=".VsAccessibilityCallScreenService"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
            <intent-filter>
                <action android:name= "android.accessibilityservice.AccessibilityService" />
            </intent-filter>
This is my access_xml_config:
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:packageNames="com.android.incallui"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFlags="flagDefault|flagReportViewIds|flagIncludeNotImportantViews|flagRetrieveInteractiveWindows"
android:accessibilityFeedbackType="feedbackGeneric"
android:notificationTimeout="100"
android:canRetrieveWindowContent="true"
android:description="@string/app_name"
    />