[Galaxy Note II Original Android Development] gosnik:
Disable wireless charging popup

Hi All,

After adding a wireless charging module in the back of my Note 2 and my S3 I found that the charging notification(s) became a major pain (especially in the middle of the night). So to solve the problem I started searching and came across the XPosed framework. Unfortunately I wasn't able to find a module that did exactly what I needed, so I had to develop something myself. As a result, I present my DisableWirelessChargingPopup module that:

Prevents the screen from turning on when a charger is connected

Disables the wireless charging popup

Disables the beep when a charger is connected

Prevents the screen from turning on when the battery is full

Note that this has only been tested on the Samsung Note 2 and the Samsung S3.

I notice other phones may have a different entry point for the wireless popup.

I hope this helps...

public class DisableWirelessChargingPopup implements IXposedHookLoadPackage
{
[MENTION=439709]override[/MENTION]
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable
{
if (lpparam.packageName.equals("android"))
{
XposedBridge.log("handleLoadPackage: " + lpparam.packageName);

try
{
Class localClass = XposedHelpers.findClass("com.android.server.PowerManagerService$BatteryReceiver", lpparam.classLoader);

Object[] parameterTypesAndCallbackPower = new Object[3];
parameterTypesAndCallbackPower[0] = Context.class;
parameterTypesAndCallbackPower[1] = Intent.class;
parameterTypesAndCallbackPower[2] = XC_MethodReplacement.DO_NOTHING;

XposedHelpers.findAndHookMethod(localClass, "onReceive", parameterTypesAndCallbackPower);
XposedBridge.log("Hooked: PowerManagerService$BatteryReceiver");
}
catch (Exception e)
{
XposedBridge.log(e.toString());
}
}

if (lpparam.packageName.equals("com.android.systemui"))
{
XposedBridge.log("handleLoadPackage: " + lpparam.packageName);
try
{
Object[] parameterTypesAndCallbackWireless = new Object[2];
parameterTypesAndCallbackWireless[0] = Integer.TYPE;
parameterTypesAndCallbackWireless[1] = XC_MethodReplacement.DO_NOTHING;

//XposedHelpers.findAndHookMethod("com.android.systemui.power.PowerUI", lpparam.classLoader, "showWirelessChargingNotice", arrayOfObject);
XposedHelpers.findAndHookMethod("com.android.systemui.power.PowerUI",
lpparam.classLoader, "showWirelessChargeDialog", parameterTypesAndCallbackWireless);

XposedBridge.log("Hooked: " + lpparam.packageName + " showWirelessChargeDialog");
}
catch (Exception e)
{
XposedBridge.log(e.toString());
}

try
{
Object[] parameterTypesAndCallbackPlaySound = new Object[2];
parameterTypesAndCallbackPlaySound[0] = Integer.TYPE;
parameterTypesAndCallbackPlaySound[1] = XC_MethodReplacement.DO_NOTHING;

XposedHelpers.findAndHookMethod("com.android.systemui.power.PowerUI",
lpparam.classLoader, "playSound", parameterTypesAndCallbackPlaySound);

XposedBridge.log("Hooked: " + lpparam.packageName + " playSound");
}
catch (Exception e)
{
XposedBridge.log(e.toString());
}

try
{
XposedHelpers.findAndHookMethod("com.android.systemui.power.PowerUI",
lpparam.classLoader, "notifyFullBatteryNotification",
XC_MethodReplacement.DO_NOTHING);
}
catch (Exception e)
{
XposedBridge.log(e.toString());
}
}
}
}