Using AccessibilityService from within a System Service

99 views
Skip to first unread message

Daniel Doron

unread,
Sep 29, 2015, 12:39:59 PM9/29/15
to android-platform
Is it possible to use the AccessibilityService in a system service? Do I need to make changes to "frameworks/base/core/res/AndroidManifest.xml" xml file? if so what changes? 
I did this in a userspace service, no problem. But now I am trying to to the same from within a system service. 
Do I need to add BIND_ACCESSIBILITY_SERVICE to my system service? in that case does the AccessibilityService still needs to be manually enabled via Accessibility menu (Settings)? 
I would appreciate some pointers....


Daniel. 

Tez

unread,
Oct 4, 2015, 10:43:31 PM10/4/15
to android-platform
If you are writing a system service, then you can do directly whatever a11y provides already -- read windows, inject events etc

Daniel Doron

unread,
Oct 6, 2015, 11:07:44 AM10/6/15
to android-platform
The AccessibilityService usage requires creating a class which extends the AccessibilityService class and overriding several methods. 
The AccessibilityService is a hub which receives events from various parts of the system and relays that information to other services. Look into the code, you'll find it is not as straight forward as calling a function. 

Tez

unread,
Oct 6, 2015, 12:23:17 PM10/6/15
to android-platform
Of course its not as simple as calling a function. If you expect such a solution, I'm afraid there is none.
Programming in the platform is very different from the API view for developers. I suggest getting a book on the topic (of android systems programming), there are several.
I would go about this by adding whatever I need directly to the system a11y service and then hooking it up to the custom system service. Of course, since these are all system mods, none of this can ever be used in production, unless you are building your own variant.

Daniel Doron

unread,
Oct 7, 2015, 10:01:04 AM10/7/15
to android-platform
Can you name a few books? 
I have already added my own service and hooked it into the system_server, no problem there. The problem I am currently facing is that there is only one AndroidManifest.xml for the system service. Where should I put my service to be able to add my own manifest file? where should I put that manifest file? 
Of course, I was not expecting a straight forward function calling solution...been into the code long enough...

Daniel.

Tez

unread,
Oct 7, 2015, 3:08:11 PM10/7/15
to android-platform
So basically you could follow this guide to create your own system service:

Since it is a system service, it has all the rights of the system. Therefore, you don't need to edit any manifest file, even to declare it.
Bottom line: You don't need to edit any xml files to create custom system services.

Next, I'd suggest digging thru the accessibility service available under services/ in the source code to see what you need. Generally, there are ways for system services to call other system services (for. e.g. activity manager calling window manager). therefore, I expect that there would be a similar technique for your custom service calling the a11y service.

----
Shameless plug here, but I have a book on system programming from a while ago ("Android Systems Development HowTo"), but that was on gingerbread 2.3. There are basic concepts there, but at this point the current android source code has moved on from what was true for GB (It's hard keeping pace with Android!)

There is also "Embedded Android" by karim yaghmour but I havent checked to see how up to date that is.

Durgadoss Ramanathan

unread,
Oct 7, 2015, 3:14:29 PM10/7/15
to android-...@googlegroups.com
Usually you get the handle to a service using context.getSystemService(SERVICE_NAME).

A simple grep for "getSystemService" inside aosp/frameworks/base/services/core/java/com/android/server
would give you a lot of examples.

Thanks,
Durga

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.



--
Regards
Durgadoss

Daniel Doron

unread,
Oct 8, 2015, 9:31:07 AM10/8/15
to android-platform
That would allow me access the the AccessibilityManager but not to Accessibility events.

D.
Reply all
Reply to author
Forward
0 new messages