Skip to content

Commit 82ccbc4

Browse files
AbedAbed
Abed
authored and
Abed
committed
- Tracking wish app
- Printing the values of all the text feilds inside the screens of Wish
1 parent c25943e commit 82ccbc4

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

app/src/main/AndroidManifest.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
>
2626
<intent-filter>
2727
<action android:name="android.accessibilityservice.AccessibilityService" />
28-
<meta-data
29-
android:name="android.accessibilityservice" android:resource="@xml/serviceconfig" />
28+
3029
</intent-filter>
30+
<meta-data
31+
android:name="android.accessibilityservice" android:resource="@xml/serviceconfig" />
3132
</service>
3233
</application>
3334

app/src/main/java/com/mollyiv/chatheads/MyAccessibilityService.java

+24-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.content.Intent;
1010
import android.util.Log;
1111
import android.view.accessibility.AccessibilityEvent;
12+
import android.view.accessibility.AccessibilityNodeInfo;
1213

1314
public class MyAccessibilityService extends AccessibilityService {
1415

@@ -30,31 +31,42 @@ public void onServiceConnected() {
3031
// Set the type of events that this service wants to listen to. Others won't be passed to this service.
3132
// We are only considering windows state changed event.
3233
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
33-
info.eventTypes = AccessibilityEvent.TYPE_WINDOWS_CHANGED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
34+
info.eventTypes = AccessibilityEvent.TYPE_WINDOWS_CHANGED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED| AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
3435
// If you only want this service to work with specific applications, set their package names here. Otherwise, when the service is activated, it will listen to events from all applications.
35-
// info.packageNames = new String[]{"com.example.android.myFirstApp", "com.example.android.mySecondApp"};
36+
info.packageNames = new String[]{"com.contextlogic.wish",};
3637
// Set the type of feedback your service will provide. We are setting it to GENERIC.
3738
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
3839
// Default services are invoked only if no package-specific ones are present for the type of AccessibilityEvent generated.
3940
// This is a general-purpose service, so we will set some flags
40-
info.flags = AccessibilityServiceInfo.DEFAULT;
41-
info.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
42-
info.flags = AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
43-
info.flags = AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY;
44-
info.flags = AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
41+
info.flags = AccessibilityServiceInfo.DEFAULT | AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS | AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY | AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
4542
// We are keeping the timeout to 0 as we don’t need any delay or to pause our accessibility events
4643
info.notificationTimeout = 0;
4744
this.setServiceInfo(info);
4845
}
4946

5047
@Override
5148
public void onAccessibilityEvent(AccessibilityEvent event) {
52-
Log.d(TAG, "onAccessibilityEvent: " + event.toString());
53-
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
54-
if (event.getPackageName().equals("com.android.chrome")) {
55-
getApplicationContext().startService(new Intent(getApplicationContext(), HeadService.class));
56-
}
49+
// Log.d(TAG, "onAccessibilityEvent: " + event.toString());
50+
51+
AccessibilityNodeInfo source = event.getSource();
52+
if (source == null) {
53+
return;
5754
}
55+
// Log.d("Event:: ", event.toString());
56+
// Log.d("Source:: ", source.toString());
57+
traverseView(source);
58+
// if (source.getText() != null)
59+
// Log.d("Text:: ", source.getText().toString());
5860
}
5961

62+
private void traverseView(AccessibilityNodeInfo info) {
63+
for (int i = 0; i < info.getChildCount(); i++) {
64+
if (info.getChild(i) != null) {
65+
// Log.d("traverse:: ", info.getChild(i).getClassName().toString());
66+
if (info.getChild(i).getText() != null)
67+
Log.d("traverse text:: ", info.getChild(i).getText().toString());
68+
traverseView(info.getChild(i));
69+
}
70+
}
71+
}
6072
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
4-
android:accessibilityEventTypes="typeWindowContentChanged|typeWindowStateChanged"
4+
android:accessibilityEventTypes="typeWindowContentChanged|typeWindowStateChanged|typeWindowsChanged"
55
android:accessibilityFeedbackType="feedbackGeneric"
66
android:accessibilityFlags="flagDefault|flagIncludeNotImportantViews|flagReportViewIds|flagRequestEnhancedWebAccessibility|flagRetrieveInteractiveWindows"
77
android:canRetrieveWindowContent="true"
88
android:notificationTimeout="0"
9-
android:packageNames="com.example.android.myFirstApp, com.example.android.mySecondApp"
9+
android:packageNames="com.contextlogic.wish"
1010
android:settingsActivity="com.example.android.apis.accessibility.TestBackActivity" />

0 commit comments

Comments
 (0)