afterburner
afterburner copied to clipboard
Is there a way proxy final methods in Android classes with Afterburner?
I am trying desperately to setup a Proxy for Android classes such as TextView in my library. Specifically, I need to know when TextView#setText(int resId) is called in the client app. Unfortunately, this method is inexplicably final. TextView itself is not a final class.
After some initial investigation it does not seem that what I need is possible even with bytecode weaving. I am pretty sure I can't replace the dex of classes already part of the parent class loader. Or am I wrong? Please let me be wrong :).
Is there some other pattern that requires slightly more implementation by users of my library that I can achieve with afterburner? I am just hoping there is a better way to than having the users of my library call explicit static methods everywhere they set text via resource id.
There might be other ways to achieve it, maybe an internal non final method of TextView, but I don't know them.
Otherwise, no, I don't think you can modify a class like TextView as it's part of Android Framework, these classes are embedded in each device and you don't have access to them. Maybe using a custom class loader could do, but I am not sure.
Otherwise, using Javassist, you can for sure detect each invocation of setText on a textview, but this is out of the scope of afterburner.
Stéphane
2015-01-19 15:00 GMT-05:00 Joshua Deffibaugh [email protected]:
I am trying desperately to setup a Proxy for Android classes such as TextView in my library. Specifically, I need to know when TextView#setText(int resId) is called in the client app. Unfortunately, this method is inexplicably final. TextView itself is not a final class.
After some initial investigation it does not seem that what I need is possible even with bytecode weaving. I am pretty sure I can't replace the dex of classes already part of the parent class loader. Or am I wrong? Please let me be wrong :).
Is there some other pattern that requires slightly more implementation by users of my library that I can achieve with afterburner? I am just hoping there is a better way to than having the users of my library call explicit static methods everywhere they set text via resource id.
— Reply to this email directly or view it on GitHub https://github.com/stephanenicolas/afterburner/issues/5.
"Otherwise, using Javassist, you can for sure detect each invocation of setText on a textview, but this is out of the scope of afterburner."
What do you mean by this? Does Javassist handle final methods?