Do you have Busybox installed? Or rather, do you have an /sbin/sh executable? The script is executed by /sbin/sh, which is linked to /sbin/busybox on my phone.
Good to know that even the binaries are compatible for Stock, AOSP and CM9! That's what I hoped.So I've installed the apk and red clock test one aswell. It works fine on CM9 and seems like a great project.
I didn't have the time to look at it in detail. From what I saw, most of the patches are for creating new classes and only a few things modify the existing code. In Xposed, some of the modifications might have to be done a bit differently (as you cannot change the code inside a method), but I think this should be possible.Just a quick (maybe dumb) question/idea:
Would a module build with PDroid work with this?
Absolutely! Actually, I have already implemented new methods that make it very easy for developers to change some of the resources (e.g. strings and booleans). Unfortunately, with these changes the applications list in the settings crashes and I'm trying not to work around this, but fix the root cause. And for this, I have already spent like 30-40 hours of debugging in the past days. It's probably a stack corruption and very hard to debug.This could also be used for theming right? I mean, make apps search for graphics in other places than it normally would?
I already have a use case for it: put callbacks on the Power Manager so that in conjunction with BetterBatteryStats tool, one can not only know the process and WL that is responsible for the CPU being awake, but also activate an Xposed module that can catch all acquire/release invocations and log the stack trace so it's possible to know the exact java/smali places to look for WakeLock issues.
I think it should work.. but I haven't tried yet. As mentioned, I'm currently busy with bug hunting. Afterwards, I will have a look at this.This brings me to my question: is it possible in your implementation to wrap native methods as well? Or must I go a bit upstream so I'm putting callbacks on "regular" java methods?
Lol, I wouldn't be expecting JKay apologizing for noob questions
In reflection it's not possible to add methods or fields, although accessing existing member fields is just the same as accessing methods.
Have a look at the Reflection tutorial for a quick glance of what's possible to do. Then, for what's not (e.g. instrumentation or dynamic injection of new fields / methods), the pressure's on rovo89 to add it to his framework
I'm not familiar with your internal implementation, but lots of stuff should fit this model. When you're adding a wrapper to an existing class' method, you could maintain on your side (the wrapper) additional info and additional methods, and have them used whenever the right conditions are needed. And if multiple objects of the same type (or not) are wrapped by a single class or object of yours, you could still use the original object reference as a key to a Map where you store per-object stuff. Theoretically, most of the stuff should be possible ...
Performance might be something to consider (as well as code maintainability as you mentioned), but provided nothing is called lots of times in succession, the reflection overhead should be relatively low within all the code. Also, the main concern is power usage / deep sleep - where lots of custom lock screens, etc. put a lot of stress on power management - but on that front nothing would change.
public static void init(String startClassName) {
if (startClassName != null)
return;
try {
XResources.setSystemWideReplacement("android", "bool", "config_animateScreenLights", false);
XResources.setSystemWideReplacement("android", "bool", "config_unplugTurnsOnScreen", false);
XposedBridge.hookInitPackageResources(Example.class, "handleInitPackageResources", Callback.PRIORITY_DEFAULT);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
@SuppressWarnings("unused")
private static void handleInitPackageResources(String packageName, XResources res) {
// replacements only for SystemUI
if (!packageName.equals("com.android.systemui"))
return;
res.setReplacement(0x7f080083, "YEAH!"); // WLAN toggle text. You should not do this because the id is not fixed. Only for framework resources, you could use android.R.string.something
res.setReplacement("com.android.systemui:string/quickpanel_bluetooth_text", "WOO!");
res.setReplacement("com.android.systemui", "string", "quickpanel_gps_text", "HOO!");
res.setReplacement("com.android.systemui", "integer", "config_maxLevelOfSignalStrengthIndicator", 6);
}