I have an AccessibilityService which was working fine but for some reason during development it stopped working. I can't seem to find that reason. Please have a look at my code and tell why it isn't working.
public class MyServicee extends AccessibilityService {
public static final String TAG = "volumeMaster";
@TargetApi(Build.VERSION_CODES.KITKAT)
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
List<CharSequence> eventText;
Log.v(TAG, "***** onAccessibilityEvent");
final int eventType = event.getEventType();
switch (eventType) {
case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
break;
}
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) {
}
}
private String processUSSDText(List<CharSequence> eventText) {
for (CharSequence s : eventText) {
String text = String.valueOf(s);
if (true) {
return text;
}
}
return null;
}
@Override
public void onInterrupt() {
Log.v(TAG, "***** onInterrupt");
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onServiceConnected() {
Log.v(TAG, "***** onServiceConnected");
AccessibilityServiceInfo info = getServiceInfo();
info.eventTypes =
AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED
| AccessibilityEvent.TYPE_VIEW_CLICKED
| AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
info.packageNames = new String[]{"com.whatsapp"};
info.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
setServiceInfo(info);
super.onServiceConnected();
}
}
Here's the relevant part of Manifest:
<service android:name=".MyServicee"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:enabled="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data android:name="android.accessibilityservice"
android:resource="@xml/myservice" />
</service>
Here's myserviceconfig.xml:
<accessibility-service
xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeViewClicked|typeNotificationStateChanged|typeWindowStateChanged"
android:accessibilityFeedbackType="feedbackAllMask"
android:canRetrieveWindowContent="true"
android:accessibilityFlags="flagIncludeNotImportantViews|flagRequestFilterKeyEvents"
android:notificationTimeout="1"
android:packageNames="com.whatsapp"
android:settingsActivity="@string/app_name" />
The code attempts to detect when the user has started a call recording service.