Hi, I'm new to the subject of modules for Xposed, I hope you can help.
1) I have managed to make a change in the status bar of android, with a few lines.
Code:
String methodeStatusBar = "com.android.systemui.statusbar.phone.PhoneStatusBar";
XposedHelpers.findAndHookMethod(methodeStatusBar, lpparam.classLoader, "makeStatusBarView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
XposedBridge.log("Hola Mundo-> Xposed: " + param);
Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext");
LinearLayout mStatusBarContents = (LinearLayout)XposedHelpers.getObjectField(param.thisObject, "mStatusBarContents");
mStatusBarContents.setBackgroundColor(Color.rgb(100, 100, 255));
XposedBridge.log("findAndHookMethod-> Xposed: " + mContext);
XposedBridge.log("findAndHookMethod-> Xposed: " + mStatusBarContents);
}
});
2) I manage to identify activity that has focus.
Code:
XposedHelpers.findAndHookMethod(Activity.class, "onWindowFocusChanged", boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Activity activity = (Activity) param.thisObject;
}
});
3) but I can not connect "StatusBar" with "Activity", to extract the color of the "activity" and then set the "setBackgroundColor" the statusbar.
my question is: How can I connect "StatusBar" with "Activity"?
you can help me !!!!
translation "translate.google.com.do/".
Related
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.
Hello, I've hooked a method to get KeysEvent, but I've ran into 2 problems :
1. Can't get long press.
2. Getting up to 7 events when it's only 1 event, Explain ? I've added a log.i in "if(blabla == VOLUME_DOWN ), When i press that key i get the log 7 times.
Here's the code :
HTML:
public static void init() {
final Class localClass = XposedHelpers.findClass("com.android.internal.policy.impl.PhoneWindowManager", Xposed.CLASS_LOADER);
XposedBridge.hookAllConstructors(localClass, new XC_MethodHook() {
protected void afterHookedMethod(final XC_MethodHook.MethodHookParam paramAnonymousMethodHookParam)
throws Throwable {
}
});
XposedHelpers.findAndHookMethod(localClass, "interceptKeyBeforeQueueing", KeyEvent.class, Integer.TYPE, new XC_MethodHook() {
[user=439709]@override[/user]
protected void beforeHookedMethod(MethodHookParam param)
throws Throwable {
KeyEvent event = (KeyEvent) param.args[0];
int code = event.getKeyCode();
if (code == KeyEvent.KEYCODE_BACK) {
Log.i(Xposed.TAG, "Back Pressed");
}
}
});
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)
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!
I'm trying to get the TextView of the following method, but everything I have tried returns a null value.
This is the code:
Code:
public final void a(boolean z) {
if (z) {
if (this.W == null) {
this.W = new TextView(getContext());
this.W.setBackgroundResource(android.support.design.widget.b.AnonymousClass7.ay);
this.W.setGravity(17);
LayoutParams marginLayoutParams = new MarginLayoutParams(-2, -2);
marginLayoutParams.bottomMargin = getContext().getResources().getDimensionPixelSize(android.support.design.widget.b.AnonymousClass5.ap);
addView(this.W, marginLayoutParams);
this.h = this.W;
}
this.W.setText(k.e(getContext(), this.a.k).toUpperCase());
this.W.setTextSize(a(getResources()));
this.W.setVisibility(0);
this.t = true;
return;
}
if (this.W != null) {
this.W.setVisibility(8);
}
this.t = false;
}
This is one of the ways in which I have tried to obtain value.
Code:
findAndHookMethod(class, "a", boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam params) throws Throwable {
super.afterHookedMethod(params);
TextView textView = (TextView) params.thisObject;
if (textView!=null) {
textView.setTextColor(color);
}
}
});
I have also tried the following:
Code:
TextView textView = (TextView) XposedHelpers.getObjectField(p.thisObject, "W");
and
Code:
TextView textView = (TextView] params.args[0];
But nothing is working.
Is it possible to get the TextView? and if it's possible, how to do it?
Problem solved, I had to assign the private variable field as setAccessible(true).