Module Is Enabled, But not really Active | Devs Help ASAP - Xposed Framework Development

Hello, I'm developing my first Xposed Module, and made a text that says if Module is active or not.
What I'm facing that the Xposed Module is enabled from the installed, but the Xposed Module itself not active, what i'm changing are drawble, and color from SystemUI .
Here's my Xposed Activity code :
So, what's the problem in my code ? why it's not active ?
HTML:
package com.abohani.xsystemui;
import android.content.res.XModuleResources;
import android.content.res.XResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class XposedActivity {
public class CustomHeaderImage implements IXposedHookZygoteInit,IXposedHookInitPackageResources {
public String MODULE_PATH = null;
public static final String TAG = "xSystemUI";
public static final boolean DEBUG = false;
public final String PACKAGE_MODULE = XposedActivity.class.getPackage().getName();
public void log(String message) {
XposedBridge.log(TAG + ": " + message);
}
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
// module package
if (lpparam.packageName.equals(PACKAGE_MODULE)) {
try {
if (DEBUG) log("Hooking isModuleActive method");
XposedHelpers.findAndHookMethod(Settings.PlaceholderFragment.class.getName(),
lpparam.classLoader, "isModuleActive",
XC_MethodReplacement.returnConstant(Boolean.valueOf(true)));
} catch (Throwable t) {
XposedBridge.log(t);
}
}
}
[user=439709]@override[/user]
public void initZygote(StartupParam startupParam) throws Throwable {
String MODULE_PATH = startupParam.modulePath;
}
[user=439709]@override[/user]
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui"))
return;
if (resparam.packageName.equals("com.android.systemui")) {
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
XResources.setSystemWideReplacement("com.android.systemui", "drawable", "notification_header_bg", modRes.fwd(R.drawable.notification_header_bg));
XResources.setSystemWideReplacement("com.android.systemui", "color", "system_primary_color",
modRes.fwd(R.integer.color));
}
}
//
}
}

abo hani said:
Hello, I'm developing my first Xposed Module, and made a text that says if Module is active or not.
What I'm facing that the Xposed Module is enabled from the installed, but the Xposed Module itself not active, what i'm changing are drawble, and color from SystemUI .
Here's my Xposed Activity code :
So, what's the problem in my code ? why it's not active ?
HTML:
package com.abohani.xsystemui;
import android.content.res.XModuleResources;
import android.content.res.XResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class XposedActivity {
public class CustomHeaderImage implements IXposedHookZygoteInit,IXposedHookInitPackageResources {
public String MODULE_PATH = null;
public static final String TAG = "xSystemUI";
public static final boolean DEBUG = false;
public final String PACKAGE_MODULE = XposedActivity.class.getPackage().getName();
public void log(String message) {
XposedBridge.log(TAG + ": " + message);
}
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
// module package
if (lpparam.packageName.equals(PACKAGE_MODULE)) {
try {
if (DEBUG) log("Hooking isModuleActive method");
XposedHelpers.findAndHookMethod(Settings.PlaceholderFragment.class.getName(),
lpparam.classLoader, "isModuleActive",
XC_MethodReplacement.returnConstant(Boolean.valueOf(true)));
} catch (Throwable t) {
XposedBridge.log(t);
}
}
}
[user=439709]@override[/user]
public void initZygote(StartupParam startupParam) throws Throwable {
String MODULE_PATH = startupParam.modulePath;
}
[user=439709]@override[/user]
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui"))
return;
if (resparam.packageName.equals("com.android.systemui")) {
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
XResources.setSystemWideReplacement("com.android.systemui", "drawable", "notification_header_bg", modRes.fwd(R.drawable.notification_header_bg));
XResources.setSystemWideReplacement("com.android.systemui", "color", "system_primary_color",
modRes.fwd(R.integer.color));
}
}
//
}
}
Click to expand...
Click to collapse
Does your xposed_init file (\assets folder) contain the correct class path (below)?
Code:
com.abohani.xsystemui.XposedActivity
Also you can hardcode ur package instead of playing with java:
PHP:
public static final String PACKAGE_MODULE = "com.abohani.xsystemui";

serajr said:
Does your xposed_init file (\assets folder) contain the correct class path (below)?
Code:
com.abohani.xsystemui.XposedActivity
Also you can hardcode ur package instead of playing with java:
PHP:
public static final String PACKAGE_MODULE = "com.abohani.xsystemui";
Click to expand...
Click to collapse
Yes, the xposed_init file contains the code you mentioned.
Sorry, I'm new and didn't know about that , edited .
If xposed_init is set correct, what left to be related to this problem ?

abo hani said:
Yes, the xposed_init file contains the code you mentioned.
Sorry, I'm new and didn't know about that , edited .
If xposed_init is set correct, what left to be related to this problem ?
Click to expand...
Click to collapse
That's a good question buddy! you can head onto my Blurred System UI (LP) module's source code and take a look at on its bowels!

serajr said:
That's a good question buddy! you can head onto my Blurred System UI (LP) module's source code and take a look at on its bowels!
Click to expand...
Click to collapse
Downloaded and compared, only difference that you are using hooks in different activities ( which i don't find it as a problem ) .
Download another Xposed Module sample, from Github, compared, nothing is different .
Gonna make a sample without Preference Screen, and feedback, maybe it's my problem from my MainActivity, not from my XposedActivity, right ?

serajr said:
That's a good question buddy! you can head onto my Blurred System UI (LP) module's source code and take a look at on its bowels!
Click to expand...
Click to collapse
Ok then, i've tried to make a sample, and shrinked my Xposed Code, but still the same, nothing changed, I've made a blank activity with Resource forwarding, so when it's enabled it will change the SystemUI header directly .
Here the code :
XposedActivity
HTML:
package com.abohani.xsystemui;
import android.content.res.XModuleResources;
import android.content.res.XResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
public class XposedActivity implements IXposedHookZygoteInit,IXposedHookInitPackageResources{
public String MODULE_PATH = null;
public static final String TAG = "xSystemUI";
public void log(String message) {
XposedBridge.log(TAG + ": " + message);
}
[user=439709]@override[/user]
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
}
[user=439709]@override[/user]
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui")) {
return;
}
if (resparam.packageName.equals("com.android.systemui")) {
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
XResources.setSystemWideReplacement("com.android.systemui", "drawable", "notification_header_bg", modRes.fwd(R.drawable.notification_header_bg));
}
}
}
assets/xposed_init
com.abohani.xsystemui.XposedActivity
So, what's the problem ?

abo hani said:
Ok then, i've tried to make a sample, and shrinked my Xposed Code, but still the same, nothing changed, I've made a blank activity with Resource forwarding, so when it's enabled it will change the SystemUI header directly .
Here the code :
XposedActivity
HTML:
package com.abohani.xsystemui;
import android.content.res.XModuleResources;
import android.content.res.XResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
public class XposedActivity implements IXposedHookZygoteInit,IXposedHookInitPackageResources{
public String MODULE_PATH = null;
public static final String TAG = "xSystemUI";
public void log(String message) {
XposedBridge.log(TAG + ": " + message);
}
[user=439709]@override[/user]
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
}
[user=439709]@override[/user]
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui")) {
return;
}
if (resparam.packageName.equals("com.android.systemui")) {
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
XResources.setSystemWideReplacement("com.android.systemui", "drawable", "notification_header_bg", modRes.fwd(R.drawable.notification_header_bg));
}
}
}
assets/xposed_init
com.abohani.xsystemui.XposedActivity
So, what's the problem ?
Click to expand...
Click to collapse
Bro... Attached you can find a fully working xposed module (Eclipse) just for that purpose (see the screenshot)!
Feel free to change it as much as you want/need.
Hope that helps you!!
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}

Related

[SOLVED] java.lang.NoSuchMethodError where such a method exists

Hello, I get the following exception in logcat
Code:
E/Xposed (10014): java.lang.NoSuchMethodError: com.android.keyguard.KeyguardSecurityContainer#updateSecurityView(android.view.View,java.lang.Boolean)#exact
and my code is
Code:
public class XposedMod implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) && (lpparam.packageName.contains("android.keyguard") || lpparam.packageName.contains("com.android.systemui")))
{
Class<?> KeyguardHostView = XposedHelpers.findClass("com.android.keyguard.KeyguardSecurityContainer", lpparam.classLoader);
findAndHookMethod(KeyguardHostView, "updateSecurityView", View.class, Boolean.class, mUpdateSecurityViewHook);
}
}
The method exists here https://github.com/android/platform.../keyguard/KeyguardSecurityContainer.java#L139
What should I do? Thanks for your help!
Code:
findAndHookMethod(KeyguardHostView, "updateSecurityView", View.class, boolean.class, mUpdateSecurityViewHook);
The primitive boolean was to be used instead of the boxed Boolean
Rijul.A said:
Hello, I get the following exception in logcat
Code:
E/Xposed (10014): java.lang.NoSuchMethodError: com.android.keyguard.KeyguardSecurityContainer#updateSecurityView(android.view.View,java.lang.Boolean)#exact
and my code is
Code:
public class XposedMod implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) && (lpparam.packageName.contains("android.keyguard") || lpparam.packageName.contains("com.android.systemui")))
{
Class<?> KeyguardHostView = XposedHelpers.findClass("com.android.keyguard.KeyguardSecurityContainer", lpparam.classLoader);
findAndHookMethod(KeyguardHostView, "updateSecurityView", View.class, Boolean.class, mUpdateSecurityViewHook);
}
}
The method exists here https://github.com/android/platform.../keyguard/KeyguardSecurityContainer.java#L139
What should I do? Thanks for your help!
Click to expand...
Click to collapse
Make class and paste this content
PHP:
import java.lang.reflect.Method;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
public class XposedWrapper {
public static XC_MethodHook.Unhook hookMethod(Class<?> sClass,String method_Name,Object... parameterTypesAndCallback) {
Method method = XposedHelpers.findMethodBestMatch(sClass,method_Name,removeCallback(parameterTypesAndCallback));
XC_MethodHook callback = (XC_MethodHook) parameterTypesAndCallback[parameterTypesAndCallback.length-1];
return XposedBridge.hookMethod(method,callback);
}
private static Object[] removeCallback(Object... args) {
Object[] list = new Object[args.length-1];
for (int i = 0 ; i < args.length ; i++) {
if (!(args[i] instanceof XC_MethodHook)) {
list[i] = args[i];
}
}
return list;
}
}
Now in the xposed class
do like this
PHP:
XposedWrapper.hookMethod(KeyguardHostView, "updateSecurityView", View.class, Boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("Hooked");
}
});

FindViewById from hooked method?

Hello!
I'm trying to make Xposed module from this patch: https://github.com/CyanogenMod/android_frameworks_base/commit/19e458f4a26fe7c8b6419cadba81a0c46dc79dad
My code looks like this:
Code:
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
}
@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals(PACKAGE_NAME))
return;
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
mFakeIdScrimview = resparam.res.addResource(modRes, R.id.scrimview);
mFakeIdVisView = resparam.res.addResource(modRes, R.id.visualizerview);
}
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals(PACKAGE_NAME))
return;
findAndHookMethod("com.android.systemui.statusbar.phone.PhoneStatusBar", lpparam.classLoader,
"makeStatusBarView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
FrameLayout lStatusBarWindow = (FrameLayout) XposedHelpers.getObjectField(param.thisObject, "mStatusBarWindow");
FrameLayout scrimView = (FrameLayout) lStatusBarWindow.findViewById(mFakeIdScrimview);
if (scrimView != null) {
mVisualizerView = (VisualizerView) scrimView.findViewById(mFakeIdVisView);
} else {
XposedBridge.log("scrimView = null !!!!");
}
if (mVisualizerView != null){
mVisualizerView.setKeyguardMonitor(mKeyguardMonitor);
} else {
XposedBridge.log("mVisualizerView = null !!!!! ");
}
}
});
The problem is that scrimView is always null and I can't get this piece of code working.
Anybody has any idea?
Untested, but could you try to replace your scrimView assignment line with this
Code:
FrameLayout scrimView = (FrameLayout) XposedHelpers.callMethod(lStatusBarWindow, "findViewById", mFakeIdScrimview);
Rijul.A said:
Untested, but could you try to replace your scrimView assignment line with this
Code:
FrameLayout scrimView = (FrameLayout) XposedHelpers.callMethod(lStatusBarWindow, "findViewById", mFakeIdScrimview);
Click to expand...
Click to collapse
Unfortunately scrimView is still null.

Hook long press notification

How can you guys capture long press notification?
I found this method on SystemUI:
Code:
Code:
protected SwipeHelper.LongPressListener getNotificatioLongnClicker() {
return new SwipeHelper.LongPressListener() {
[user=439709]@override[/user]
public boolean onLongPress(View v, int x, int y) {...
But I can't do afterHookedMethod or beforeHookedMethod.
Code:
Code:
public class Tutorial implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded app: " + lpparam.packageName);
if (!lpparam.packageName.equals("com.android.systemui"))
return;
findAndHookMethod("com.android.systemui.statusbar.BaseStatusBar", lpparam.classLoader, "getNotificationLongClicker", new XC_MethodHook() {
[user=439709]@override[/user]
protected void afterHookedMethod (MethodHookParam param) throws Throwable {
// this will be called before the clock was updated by the original method
return new View.OnLongClickListener() {
[user=439709]@override[/user]
public boolean onLongClick(final View v) {
XposedBridge.log("long press notification action");
return true;
}
}
});
}
}
}
How I can call the method from another class "SwipeHelper" and access "LongPressListener" public interface and "onLongPress" method which return boolean value?
I tried with object and method "View.OnLongClickListener" without success. Anyway, if I can't do it there is another way because I see system long press notification working on xNotification module.
PS.: I'm noobie: http://stackoverflow.com/questions/3...ing-xposed-mod
@pixeltech.dev
lukakas said:
How can you guys capture long press notification?
I found this method on SystemUI:
Code:
Code:
protected SwipeHelper.LongPressListener getNotificatioLongnClicker() {
return new SwipeHelper.LongPressListener() {
[user=439709]@override[/user]
public boolean onLongPress(View v, int x, int y) {...
But I can't do afterHookedMethod or beforeHookedMethod.
Code:
Code:
public class Tutorial implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded app: " + lpparam.packageName);
if (!lpparam.packageName.equals("com.android.systemui"))
return;
findAndHookMethod("com.android.systemui.statusbar.BaseStatusBar", lpparam.classLoader, "getNotificationLongClicker", new XC_MethodHook() {
[user=439709]@override[/user]
protected void afterHookedMethod (MethodHookParam param) throws Throwable {
// this will be called before the clock was updated by the original method
return new View.OnLongClickListener() {
[user=439709]@override[/user]
public boolean onLongClick(final View v) {
XposedBridge.log("long press notification action");
return true;
}
}
});
}
}
}
How I can call the method from another class "SwipeHelper" and access "LongPressListener" public interface and "onLongPress" method which return boolean value?
I tried with object and method "View.OnLongClickListener" without success. Anyway, if I can't do it there is another way because I see system long press notification working on xNotification module.
PS.: I'm noobie: http://stackoverflow.com/questions/3...ing-xposed-mod
@pixeltech.dev
Click to expand...
Click to collapse
Hi, View.OnLongClickListener is not a method, it's an interface. Basically what you need to do is get the method result in your hook (it would be either SwipeHelper or OnClickListener based on your Andorid version) and use it based on its methods and your needs
pixeltech.dev said:
Hi, View.OnLongClickListener is not a method, it's an interface. Basically what you need to do is get the method result in your hook (it would be either SwipeHelper or OnClickListener based on your Andorid version) and use it based on its methods and your needs
Click to expand...
Click to collapse
I tried to do this without success:
Code:
public class Tutorial implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded app: " + lpparam.packageName);
if (!lpparam.packageName.equals("com.android.systemui"))
return;
findAndHookMethod("com.android.systemui.statusbar.SwipeHelper$LongPressListener", lpparam.classLoader, "onLongPress",View.class, Integer.TYPE, Integer.TYPE, new XC_MethodHook() {
@Override
protected void afterHookedMethod (MethodHookParam param) throws Throwable {
// this will be called before the clock was updated by the original method
XposedBridge.log("long press notification action");
}
});
}
}
Logcat:
Code:
05-30 22:35:13.580 18201-18201/com.android.systemui E/Xposed: java.lang.IllegalArgumentException: Cannot hook interfaces: public abstract boolean com.android.systemui.SwipeHelper$LongPressListener.onLongPress(android.view.View,int,int)

Boolean Replacement

Hey Guys..
I have a problem with my xposed module.
I will a class to boolean false not true if rooted device..
Code:
public static boolean isRooted()
This to return false if rooted device..
Code:
XposedHelpers.findAndHockMethod("com.example.utils.RootCheck", lpparam.classLoader, "isRooted", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.args[0] = false;
}
});
Xposed say me nosuchmethoderror com.example.utils.RootCheck#isRooted(boolean)..
Can help me..
Thanks
Sorry for my bad English i m a german.
what class is it, is it your own?
are you filtering by package name?
Is not my own class..
From another Application..
This is the class. i have decoded.
I want replace "public static final String" , public static boolean isRooted() to ever false and private static boolean a(String str) to ever false..
can help me?
Code:
public final class RootCheck {
public static final String VALUE_DEVICE_FLAG_SU = "su";
public static final String VALUE_DEVICE_FLAG_SUPER_USER_APK = "superuser.apk";
public static final String VALUE_DEVICE_FLAG_TEST_KEYS = "testkeys";
private RootCheck() {
}
public static boolean isRooted() {
BuildConfig.IS_PROD.booleanValue();
return false;
}
public static Object[] getFlags() {
int i;
int i2;
List arrayList;
Object[] objArr;
int i3 = 1;
String str = Build.TAGS;
if (str == null || !str.contains("test-keys")) {
i = 0;
} else {
i = 1;
}
try {
if (new File("/system/app/Superuser.apk").exists()) {
i2 = 1;
if (!(a("/system/xbin/which su") || a("/system/bin/which su") || a("which su"))) {
i3 = 0;
}
arrayList = new ArrayList();
if (i3 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SU);
}
if (i2 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SUPER_USER_APK);
}
if (i != 0) {
arrayList.add(VALUE_DEVICE_FLAG_TEST_KEYS);
}
objArr = new Object[0];
if (arrayList.isEmpty()) {
return arrayList.toArray(objArr);
}
return objArr;
}
} catch (Exception e) {
}
i2 = 0;
i3 = 0;
arrayList = new ArrayList();
if (i3 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SU);
}
if (i2 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SUPER_USER_APK);
}
if (i != 0) {
arrayList.add(VALUE_DEVICE_FLAG_TEST_KEYS);
}
objArr = new Object[0];
if (arrayList.isEmpty()) {
return objArr;
}
return arrayList.toArray(objArr);
}
private static boolean a(String str) {
try {
Runtime.getRuntime().exec(str);
return true;
} catch (Exception e) {
return false;
}
}
}
oh wait, isRooted doesn't take any arguments and you're trying to hook isRooted with a boolean argument, which would be a different method
return values are called result here (getResult, setResult.) args is only for arguments
Oh thx
Code:
06-17 22:21:05.373: E/Xposed(30470): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
06-17 22:21:05.373: E/Xposed(30470): at de.bozja.hrh.Hidder$1.beforeHookedMethod(Hidder.java:22)
Error why?
class
Code:
findAndHookMethod("com.example.RootCheck", lpparam.classLoader, "isRooted", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
boolean isRoot = (Boolean) param.getResult(); //Error on this line
if(isRoot == true)
isRoot = false;
param.setResult(isRoot);
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
boolean isRoot = (Boolean) param.getResult();
if(isRoot == true)
isRoot = false;
param.setResult(isRoot);
}
});
beforeHookedMethod is called before the method is executed, so there can't be any result. so it's null
Just setresult to false in beforehooked dont add extra junk
And dont hook method afterhook no need before will do what u need
gitfib said:
oh wait, isRooted doesn't take any arguments and you're trying to hook isRooted with a boolean argument, which would be a different method
return values are called result here (getResult, setResult.) args is only for arguments
Click to expand...
Click to collapse
i am also facing the same issue today when trying to hook some certain method that doesnt take in any argument. And i really didnt get the answer you gave. Could you be more elaborate please?
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
gitfib said:
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
Click to expand...
Click to collapse
thanks. Will try this too. Couldn't find it on Google
gitfib said:
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
Click to expand...
Click to collapse
this is the method i want to hook. I want it to return false
public boolean vpn() {
try {
Iterator it = Collections.list(NetworkInterface.getNetworkInterfaces()).iterator();
String str = "";
do {
if (!it.hasNext()) {
return false;
}
NetworkInterface networkInterface = (NetworkInterface) it.next();
if (networkInterface.isUp()) {
str = networkInterface.getName();
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("IFACE NAME: ");
stringBuilder.append(str);
Log.d("DEBUG", stringBuilder.toString());
if (str.contains("tun") || str.contains("ppp")) {
Toast.makeText(getContext(), "Hello vpn detected", 1).show();
}
} while (!str.contains("pptp"));
Toast.makeText(getContext(), "Hello vpn detected", 1).show();
return true;
} catch (SocketException e) {
e.printStackTrace();
}
}
and this is my kotlin class
package app.devzeus.yesvpn.hook
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage
class hook: IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
val pakage = "com.eclipse.gamonyapp"
val className = "com.eclipse.gamonyapp.Fragments.OffersFragment"
val method = "vpn"
if (lpparam?.packageName == pakage){
XposedHelpers.findAndHookMethod(className, lpparam.classLoader, method, object: XC_MethodHook(){
override fun beforeHookedMethod(param: MethodHookParam?) {
super.beforeHookedMethod(param)
param?.result = false
}
})
}
}
}
am i doing it wrong? it still doesnt work. The class and method locations are correct
devzeus_ke said:
XposedHelpers.findAndHookMethod(className, lpparam.classLoader, method, object: XC_MethodHook(){
override fun beforeHookedMethod(param: MethodHookParam?) {
super.beforeHookedMethod(param)
param?.result = false
}
Click to expand...
Click to collapse
this should be a separate thread imo
XC_MethodHook | Xposed Framework API
api.xposed.info
in Java there would be no need for the super call and the syntax is .setResult, but I'm not sure in Kotlin
gitfib said:
this should be a separate thread imo
XC_MethodHook | Xposed Framework API
api.xposed.info
in Java there would be no need for the super call and the syntax is .setResult, but I'm not sure in Kotlin
Click to expand...
Click to collapse
about the .setResult(false) the compiler suggests .result = false

Can't change navigation bar buttons icons with my Xposed module

Hello friends!
I"m trying to build xposed module for educational purposes.
I want the module to:
1. Change the navigation bar color to green - this one works OK.
2. Change the navigation bar icons to custom icons i provide from my drawable resources - this one partially works, as described below.
The "home" button is changed, but the "recent apps" and "back" buttons didn't. Please see picture attached.
Can some one tell me why i can change the "home" button but not the "recent apps" and "back" buttons?
Any suggestion how to fix this?
module code:
Code:
import android.content.Context;
import android.content.res.XModuleResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import de.robv.android.xposed.callbacks.XC_LayoutInflated;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class TweakNavigationBar implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
private static String MODULE_PATH = null;
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
}
@Override
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui"))
return;
resparam.res.hookLayout("com.android.systemui", "layout", "navigation_bar", new XC_LayoutInflated() {
@Override
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, liparam.res);
LinearLayout NavigationButtonsLayout = (LinearLayout) liparam.view.findViewById(
liparam.res.getIdentifier("nav_buttons", "id", "com.android.systemui"));
NavigationButtonsLayout.setBackgroundColor(Color.GREEN);
Context mContext = NavigationButtonsLayout.getContext();
ImageView backButton = (ImageView) liparam.view.findViewById(liparam.res.getIdentifier("back", "id", "com.android.systemui"));
ImageView homeButton = (ImageView) liparam.view.findViewById(liparam.res.getIdentifier("home", "id", "com.android.systemui"));
ImageView recentButton = (ImageView) liparam.view.findViewById(liparam.res.getIdentifier("recent_apps", "id", "com.android.systemui"));
//this also didn't work
//ImageView backButton = (ImageView) NavigationButtonsLayout.getChildAt(2);
//ImageView homeButton = (ImageView) NavigationButtonsLayout.getChildAt(3);
//ImageView recentButton = (ImageView) NavigationButtonsLayout.getChildAt(4);
recentButton.setImageDrawable(modRes.getDrawable(R.drawable.blue_button,null)); // didn't work!
homeButton.setImageDrawable(modRes.getDrawable(R.drawable.red_button,null)); // WORKS!
backButton.setImageDrawable(modRes.getDrawable(R.drawable,yellow_button,null)); // didn't work!
XposedBridge.log("start scan:");
for(int i=0; i< NavigationButtonsLayout.getChildCount() ; i++) {
View viewChild = (View) NavigationButtonsLayout.getChildAt(i);
XposedBridge.log(viewChild.toString());
if(viewChild instanceof ImageView)
XposedBridge.log("Child At " + i + " is instanceof ImageView" ) ;
}
}
});
}
}
Use this:
resparam.res.setReplacement(SYSTEM_UI, "drawable", "ic_sysbar_back_ime", modRes.fwd(R.drawable.n_back_down));
resparam.res.setReplacement(SYSTEM_UI, "drawable", "ic_sysbar_recent", modRes.fwd(R.drawable.n_recents));
resparam.res.setReplacement(SYSTEM_UI, "drawable", "ic_sysbar_back", modRes.fwd(R.drawable.n_back));
Note: SYSTEM_UI="com.android.systemui"
Using my method, i wasnt able to change the home button. But using your method, it did!
Thanks man!

Categories

Resources