From 60afa4050dfb03cc7867d7f61e022934debae5a3 Mon Sep 17 00:00:00 2001 From: Us3rRogu3 Date: Mon, 17 Jul 2017 12:20:33 +0530 Subject: [PATCH] Second Update --- .idea/misc.xml | 2 +- .idea/vcs.xml | 2 +- app/build.gradle | 6 +- app/src/main/AndroidManifest.xml | 4 +- .../content_holmes/ScreenReaderService.java | 71 +++++++++++++++++-- app/src/main/res/xml/screenserviceconfig.xml | 2 +- 6 files changed, 75 insertions(+), 12 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb6828..5d19981 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/.idea/vcs.xml b/.idea/vcs.xml index b2bdec2..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 369eb38..783c1f3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { - applicationId "www.contentholmes.com.content_holmes" + applicationId 'www.contentholmes.com.content_holmes' minSdkVersion 19 targetSdkVersion 25 versionCode 1 @@ -17,10 +17,12 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + productFlavors { + } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 72e6160..fb296ea 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,7 +22,9 @@ - + diff --git a/app/src/main/java/www/contentholmes/com/content_holmes/ScreenReaderService.java b/app/src/main/java/www/contentholmes/com/content_holmes/ScreenReaderService.java index 59bd7b6..4549f31 100644 --- a/app/src/main/java/www/contentholmes/com/content_holmes/ScreenReaderService.java +++ b/app/src/main/java/www/contentholmes/com/content_holmes/ScreenReaderService.java @@ -5,22 +5,77 @@ */ import android.accessibilityservice.AccessibilityService; +import android.app.Notification; +import android.os.Parcelable; import android.util.Log; import android.view.accessibility.AccessibilityEvent; import android.accessibilityservice.AccessibilityServiceInfo; import android.view.accessibility.AccessibilityNodeInfo; +import java.util.Date; + public class ScreenReaderService extends AccessibilityService{ + String AppName = "Content-Holmes"; AccessibilityServiceInfo info; @Override public void onAccessibilityEvent(AccessibilityEvent event) { AccessibilityNodeInfo source = event.getSource(); +// Log.v("Content-Holmes", "start event"); +// Log.v("Content-Holmes", "asdasdasd"); if (source == null) { return; } - Log.i("Event", event.toString()+"-event"); - Log.i("Source", source.toString()+"-source"); - Log.i("Children", source.getChildCount()+"-children"); + if(source.getPackageName().toString().equals("com.android.systemui")){ + return; + } + if(event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED){ + getNotificationFromView(event); + }else{ + getTextFromView(source); + } + Log.v(AppName, source.getPackageName().toString()); + Log.v(AppName, new Date(event.getEventTime()).toString()); +// Log.v(AppName, source.getPackageName().toString()); +// Log.v("Content-Holmes", event.toString()+"-event"); +// Log.v("Content-Holmes", source.toString()+"-source"); +// Log.v("Content-Holmes", source.getChildCount()+"-children"); + } + + public void getNotificationFromView(AccessibilityEvent event){ + if(event == null){ + return; + } + Parcelable data = event.getParcelableData(); + if(data instanceof Notification){ + Notification n = (Notification) data; + Log.v(AppName, "Notification-"+n.tickerText.toString()); + Log.v(AppName, "Notification text-"+n.toString()); + } + + } + + public void getTextFromView(AccessibilityNodeInfo source){ + if (source == null){ + return; + } + //Log.d(AppName, "source is " + source.toString()); + if (source.getChildCount() > 0){ + for(int i=0; i