Disabling notifications from other apps using Xposed - Xposed General

I'm trying to create an app that allows the user to disable notifications from other apps.
I have been through the Xposed module development tutorial and it is my understanding that I should be able to hook onto some sort of notification method using Xposed in order to inject code either before or after the method call that should let me stop the notification from displaying on the phone.
I have been through the grepcode link from the tutorial and identified the "notify" method which should be useful and have written the following code:
Code:
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Handling package: " + lpparam.packageName);
if (!lpparam.packageName.equals("com.android.app"))
return;
XposedHelpers.findAndHookMethod("com.android.app.NotificationManager", lpparam.classLoader, "notify", String.class, int.class, Notification.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("before params: "+ param.args[0] + ", " + param.args[1].toString());
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("after params: "+ param.args[0] + ", " + param.args[1].toString());
}
});
}
However this doesn't display anything when I receive notifications from for instance the facebook messenger app.
Am I approaching this the correct way?

Related

[Q] Problem: Xposed hook OpenGL ES ?

I'm trying to hook GLES API with Xposed. But met some problems. Xposed can work well when i use it for some other things except the GLES API.
The module:
...
public class Tutorial implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded app: " + lpparam.packageName);
if (lpparam.packageName.equals("android"))
{
XposedBridge.log("Mark !");
findAndHookMethod("android.opengl.GLES20", lpparam.classLoader, "glFinish", new XC_MethodHook() {
@override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("glFinish GLES20");
}
@override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("glFinish GLES20");
}
});
}
...​
And i wrote an app with some glFinish() calls in it. When i run the app, i can't get "glFinish GLES20" at the log file.
I can get "Mark !", and no error in the log file.
Can any one help me? Thanks!

How to hook static method

I want to modify some static field in android.os.Build, such as android.os.Build.BOARD, android.os.Build.DEVICE, android.os.Build.DISPLAY.
Then I tried to hook the static method 'getString(String s)' in android.os.Build .
Code:
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
XposedBridge.log(loadPackageParam.packageName + " -> load ");
Class build = XposedHelpers.findClass(Build.class.getName(), loadPackageParam.classLoader);
XposedHelpers.findAndHookMethod(build, "getString", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("before ->" + param.args[0]);
super.beforeHookedMethod(param);
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("after ->" + param.args[0]);
super.afterHookedMethod(param);
}
});
I wrote
Code:
txvTxt = (TextView) findViewById(R.id.txvTxt);
txvTxt.setText(Build.DISPLAY);
in my activity, I could not see any before or after hook message.
Waiting online for any solution. 3Q

[Q] Hooking to nfc tranceive methods doesn't work

I'am trying to create an Xposed module which hooks into the tranceive methods of nfc to find out what is transfered. But sadly the hook doesn't seam to work. I've created a sample app which sends data over the tranceive method but the logs are not written. Here is my code:
Code:
if (!lpparam.packageName.equals("android"))
return;
findAndHookMethod("android.nfc.tech.BasicTagTechnology", lpparam.classLoader, "transceive", "byte[]", "boolean", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("before");
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("after");
}
});
I've also tried to hook into the service, but no logs either:
Code:
if (!lpparam.packageName.equals("com.android.nfc"))
return;
findAndHookMethod("com.android.nfc.NfcService", lpparam.classLoader, "doTransceiveNoLock", "int", "byte[]", new XC_MethodHook() {
.....
Am I doing something wrong or is it simply not possible to hook into these methods?
I found a solution for my problem. I have to hook the transceive method of com.android.nfc.NfcService$TagService to get access to every tag transmission.

Can't replace return values with setResult

I'm not able to change the return values of a method. The hook is working. Even the logs are correct - but when i actually call the method in another app the real information is shown.
Code:
findAndHookMethod("android.net.wifi.WifiInfo", lpparam.classLoader, "getSSID",new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("getSSID1 "+(String) param.getResult());
param.setResult("\"Changed\"");
XposedBridge.log("getSSID2 "+(String) param.getResult());
}
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});
Output:
Code:
getSSID1 "realSSID"
getSSID2 "Changed"
In app the call actually produces: "realSSID"
Can you help me with that?
what about when you setResult in beforeHookedMethod instead (thus the getSSID won't be called)?
have you ensured that the app calls getSSID to receive this information, and not from cache or something?
I tried beforeHookedMethod and MethodReplacement - same result. And getSSID is called because i can see the XposedBridge logs.
is it an app you wrote? i see from this answer that it can also be retrieved from getBSSID, and it could be the app was checking the string returned by getSSID or was using it for something else
Yes i use an own app for checking if it works. So i'm 100% sure i'm calling getSSID() - the method i've hooked.
the following works for me:
in module:
Code:
if (lpparam.packageName.equals("gitfib.hooks.sdaccounts")) {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", lpparam.classLoader,
"getSSID",
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
param.setResult("ssid");
}
});
}
in activity (same package in onCreate):
Code:
WifiInfo info = ((WifiManager) getSystemService(WIFI_SERVICE)).getConnectionInfo();
Log.i("wifiinfo", info.getSSID());
before rebooting it showed actual ssid

{QUESTION} Hook systems UserAgent

Hi,
I trying to change user agent for all system, but
Code:
User-Agent: Dalvik/2.1.0 (Linux; U; Android 5.1.1; Nexus 6 Build/LMY47X)
saving. Can you say how i can hook method of superclass. Some userAgents don't changing by hooks getProp and changing build.prop
My trying to change
Code:
XposedHelpers.findAndHookMethod("java.net.URLConnection", sharePkgParam.classLoader, "setRequestProperty", String.class, String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("==== BEFORE HOOK ==== " + Arrays.toString(param.args));
if (param.args[0].equals("User-Agent")) {
param.args[1] = "XYZXYZXYZ";
}
}
});
This make a reboot system after 5-7 sec after system loading
Code:
XposedHelpers.findAndHookMethod(System.class, "getProperty", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("==== System BEFORE ==== " + Arrays.toString(param.args));
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("==== System AFTER ==== " + (String) param.getResult());
param.setResult("Dalvik/2.1.0 (Linux; U; Android 5.1.1; Nexus 5 Build/LMY47X)");
}
});
XposedHelpers.findAndHookMethod(Properties.class, "getProperty", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("--- Properties HOOK --- " + Arrays.toString(param.args));
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("--- Properties HOOK --- " + (String) param.getResult());
}
});
solved. Tnx to all xD
Code:
XposedHelpers.findAndHookMethod(System.class, "getProperty", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("==== System BEFORE ==== " + param.args[0]);
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (param.args[0].toString().equals("http.agent")) {
XposedBridge.log("==== System AFTER ==== " + (String) param.getResult());
param.setResult("Dalvik/2.1.0 (Linux; U; Android 6.0.1; Nexus 5 Build/LMY47X)");
XposedBridge.log("==== System AFTER ==== " + (String) param.getResult());
}
}
});

Categories

Resources