[Q] how can i get the context in a service? - Xposed General

i am programing a module, in some case, i try to use AndroidAppHelper.currentApplication to get the context, but it return null. is there any way to get context? or build a communication with another app. i just want to receive data form another app. thank you

If you mean android.app.Service class, simply cast param.thisObject to Context. Service class is derived from Context. http://developer.android.com/reference/android/app/Service.html

Related

[Q] Sending information from hooks TO the settings screen?

I've read a couple of threads on the "context" that my module runs in, but I'm not clear on how I send data from my module (running in the hooked application context) back to my settings screen (running in the Xposed context?)
XSharedPreferences is obviously read only, so that doesn't work. I'm guessing I need to write to a file and parse it back from settings, but I'm hoping someone can set me in the right direction. Is there a module that already does this so I can look at the source? Or can someone give me a high level of the file permissions/location/settings to use so that it's readable/writable from both contexts?
Thanks!
Ryan
I'd say your best option is to register a broadcast receiver in your app, and send a broadcast from the hooked app (you just need a Context to do that.
If you can't get one from the app, you could use AndroidAppHelper.currentApplication()).
GermainZ said:
I'd say your best option is to register a broadcast receiver in your app, and send a broadcast from the hooked app (you just need a Context to do that.
If you can't get one from the app, you could use AndroidAppHelper.currentApplication()).
Click to expand...
Click to collapse
Thank you! I got it. I guess that was obvious, but it seemed like there might be a "tighter" way to do the cross-process communication using Xposed as a bridge.
Thanks for all of your help in this forum,
Ryan

[Q]How to resolved hidden class ItemInfo in xposed module development, thanks!

[Q]How to resolved hidden class ItemInfo in xposed module development, thanks!
I want to develop an xposed module to hide some shortcut in the launcher workspace,
but i can't resolve the hidden class ItemInfo, because i need remove specific item from ArrayList<ItemInfo>,
how to deal with it, thanks!
You can cast it to ArrayList<?>
C3C076 said:
You can cast it to ArrayList<?>
Click to expand...
Click to collapse
sure, i think i can, but how to change the single items in the ArrayList?
because i need to iterate every element in ArrayList to check if someone need to be blocked,
but the element is ItemInfo class type, so....
is there any solution to resolve it, thanks!
is there anybody has good experience on it, thanks!
If you can't use ItemInfo directly at design time simply use xposed functions on its instances to check for property values and call its methods.
E.g. you can iterate through array list and cast items to Object. Then use xposed functions on those objects like getIntField/getFloatField/... to get property or callMethod to call function.
C3C076 said:
If you can't use ItemInfo directly at design time simply use xposed functions on its instances to check for property values and call its methods.
E.g. you can iterate through array list and cast items to Object. Then use xposed functions on those objects like getIntField/getFloatField/... to get property or callMethod to call function.
Click to expand...
Click to collapse
thanks, C3C076, it's good idea, i will try

[DEV]Invoking methods from other apps

Is there a way to invoke other app's method from my app using Xposed?
I know I can hook and modify calls made by destination app, but how about invoking functions myself?
matejdro said:
Is there a way to invoke other app's method from my app using Xposed?
I know I can hook and modify calls made by destination app, but how about invoking functions myself?
Click to expand...
Click to collapse
Not directly as your app runs in different process than app you want to call.
However, you can use some kind of IPC technique.
One example is to hook foreign app and register broadcast receiver within its context which will listen for broadcasts
sent from your own app. You can then execute code (e.g. call methods) within foreign app when broadcast is received.
Ah good idea, did not think of registering broadcast receiver. Thanks!

[Q] Is static members shared between processes in XPosed hook class?

Here's what I think XPosed does:
1. Before zygote_init, hook all apis and insert xposed_before_xxx and xposed_after_xxx method (where xxx is the name of the api).
2. Load modules. Load hook class, realize it and keep it in memory of zygote. For each injecting method, add it to the private list of xposed_before/after_xxx.
3. When an new app loads (forks from zygote), it also forked the hook class and the hooked method.
4. When an app calls xxx, it actually runs xposed_before_xxx first, and the latter calls every inject method in its private list. Then the original api is called. Then xposed_after_xxx is called, and deals with itself's list.
So for each app, hook class is individual after forking from zygote. So, static members are not shared. Cause each hook class has only one instance in an app, static members act the same as non-static members. Am I right?
And by the way, how does a xposed module to communicate between processes? I've seen a post realizing its own rpc by getting context and creating a service. Any simpler ways for just single direction transferring? Currently I'm using XSharedPreference and SharedPreference, but then then the hook method can't write back anything (such as logging). Any ideas to solve this?
Thanks for reading my long & poor English...

How can I add my service into remote and start it which I injected by Xposed?

Hello everyone,,,
I recently hooked an app, and I've found some methods that I can call them in it, like I hooked a before onCreate method in the main activity, then I can call some method as well. That's perfect.
But I want to call them via my app, I can do it through BroadCast, but the broadcast can't run more than 10 seconds, it's very bad run some big task, and sometimes I prefer a result can be returned.
So seems it's wonderful I can add my service in the remote app and start it, but the problem is it isn't in the `AndroidManifest.xml`.
By the way, how can I get the ClassLoader from the remote app, I am not sure it will be working if I got the ClassLoader.
Welcome to correct me!
Thank you all. Waiting for your opinions.
Feel free to contact me with email [email protected] or Wechat(id:imwangshiqi)

Categories

Resources