Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,810,588 Members 45,425 Now Online
XDA Developers Android and Mobile Development Forum

[Q] Can I hook methods in ContentProvider?

Tip us?
 
x11911778
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Jun 2014
Question [Q] Can I hook methods in ContentProvider?

I'd like to hook the query() method in ContentProvider in order to get to know which applications are accessing the personal information(e.g: contacts, sms) stored in the device. By reading the tutorial, we know that we can hook methods in app packages. However, what can we do when the methods we want to hook are in those system components? Any suggestion is appreciated.
 
rovo89
Old
#2  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter 14,104
Posts: 2,367
Join Date: Jan 2012
Quote:
Originally Posted by x11911778 View Post
I'd like to hook the query() method in ContentProvider in order to get to know which applications are accessing the personal information(e.g: contacts, sms) stored in the device. By reading the tutorial, we know that we can hook methods in app packages. However, what can we do when the methods we want to hook are in those system components? Any suggestion is appreciated.
Well first off, you can't hook ContentProvider.query() because it's an abstract method (at least one of the two variants). So you would have to hook the subclasses that provide an implementation for this method.

You would also need to clarify what you mean with "system components". I think some of these providers are implemented in system apps, so you would hook them like any other app. Others might be part of the system process (system_server), which also hosts all the system services like package manager etc. Simply use the special package name "android" for these, otherwise handle it like a normal app. And then there might be cases where you want to hook a Android framework method on the whole system. You would do that in initZygote().

In all cases, you would first have do identify a good place to hook into, then find out when to place the hook (as described above) and then use findAndHookMethod().
Tired of updating your mod for every new ROM release?
You want give users the possibility to combine different mods without creating tons of different files for all possible combinations?
Then have a look at my Xposed framework - modifications without APK changes!
The Following User Says Thank You to rovo89 For This Useful Post: [ Click to Expand ]
 
x11911778
Old
#3  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Jun 2014
Quote:
Originally Posted by rovo89 View Post
Well first off, you can't hook ContentProvider.query() because it's an abstract method (at least one of the two variants). So you would have to hook the subclasses that provide an implementation for this method.

You would also need to clarify what you mean with "system components". I think some of these providers are implemented in system apps, so you would hook them like any other app. Others might be part of the system process (system_server), which also hosts all the system services like package manager etc. Simply use the special package name "android" for these, otherwise handle it like a normal app. And then there might be cases where you want to hook a Android framework method on the whole system. You would do that in initZygote().

In all cases, you would first have do identify a good place to hook into, then find out when to place the hook (as described above) and then use findAndHookMethod().
Thanks a lot, that really helps~
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes