From cc588b680ff3b6978950422c7f7b27e47940702e Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sun, 1 Sep 2013 18:53:01 +0200 Subject: =?UTF-8?q?Add=20Xposed=20module=20to=20ignore=20VPN=20Confirmatio?= =?UTF-8?q?n=20dialog=20(does=20not=20work=20yet=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vpndialogxposed/src/main/AndroidManifest.xml | 22 +++++ vpndialogxposed/src/main/assets/xposed_init | 1 + .../vpndialogxposed/IConnectivityManager.java | 105 +++++++++++++++++++++ .../blinkt/vpndialogxposed/VpnDialogPatcher.java | 66 +++++++++++++ .../src/main/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 741 bytes .../src/main/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 549 bytes .../src/main/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 1061 bytes .../src/main/res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 1647 bytes .../src/main/res/layout/activity_main.xml | 16 ++++ vpndialogxposed/src/main/res/menu/main.xml | 6 ++ vpndialogxposed/src/main/res/values/strings.xml | 8 ++ vpndialogxposed/src/main/res/values/styles.xml | 20 ++++ 12 files changed, 244 insertions(+) create mode 100644 vpndialogxposed/src/main/AndroidManifest.xml create mode 100644 vpndialogxposed/src/main/assets/xposed_init create mode 100644 vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/IConnectivityManager.java create mode 100644 vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/VpnDialogPatcher.java create mode 100644 vpndialogxposed/src/main/res/drawable-hdpi/ic_launcher.png create mode 100644 vpndialogxposed/src/main/res/drawable-mdpi/ic_launcher.png create mode 100644 vpndialogxposed/src/main/res/drawable-xhdpi/ic_launcher.png create mode 100644 vpndialogxposed/src/main/res/drawable-xxhdpi/ic_launcher.png create mode 100644 vpndialogxposed/src/main/res/layout/activity_main.xml create mode 100644 vpndialogxposed/src/main/res/menu/main.xml create mode 100644 vpndialogxposed/src/main/res/values/strings.xml create mode 100644 vpndialogxposed/src/main/res/values/styles.xml (limited to 'vpndialogxposed/src/main') diff --git a/vpndialogxposed/src/main/AndroidManifest.xml b/vpndialogxposed/src/main/AndroidManifest.xml new file mode 100644 index 00000000..d34264c7 --- /dev/null +++ b/vpndialogxposed/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/vpndialogxposed/src/main/assets/xposed_init b/vpndialogxposed/src/main/assets/xposed_init new file mode 100644 index 00000000..b228b31c --- /dev/null +++ b/vpndialogxposed/src/main/assets/xposed_init @@ -0,0 +1 @@ +de.blinkt.vpndialogxposed.VpnDialogPatcher diff --git a/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/IConnectivityManager.java b/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/IConnectivityManager.java new file mode 100644 index 00000000..9b26283e --- /dev/null +++ b/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/IConnectivityManager.java @@ -0,0 +1,105 @@ +/* + * This file is auto-generated. DO NOT MODIFY. + * Original file: /Users/arne/software/icsopenvpn/vpndialogxposed/src/main/aidl/android/net/IConnectivityManager.aidl + */ +package de.blinkt.vpndialogxposed; +/** + * Interface that answers queries about, and allows changing, the + * state of network connectivity. + */ + +/** + * {@hide} + */ +public interface IConnectivityManager extends android.os.IInterface { + public boolean prepareVpn(java.lang.String oldPackage, java.lang.String newPackage) throws android.os.RemoteException; + + /** Local-side IPC implementation stub class. */ + public static abstract class Stub extends android.os.Binder implements IConnectivityManager { + static final int TRANSACTION_prepareVpn = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); + private static final java.lang.String DESCRIPTOR = "android.net.IConnectivityManager"; + + /** Construct the stub at attach it to the interface. */ + public Stub() { + this.attachInterface(this, DESCRIPTOR); + } + + /** + * Cast an IBinder object into an android.net.IConnectivityManager interface, + * generating a proxy if needed. + */ + public static IConnectivityManager asInterface(android.os.IBinder obj) { + if ((obj == null)) { + return null; + } + android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR); + if (((iin != null) && (iin instanceof IConnectivityManager))) { + return ((IConnectivityManager) iin); + } + return new IConnectivityManager.Stub.Proxy(obj); + } + + @Override + public android.os.IBinder asBinder() { + return this; + } + + @Override + public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException { + switch (code) { + case INTERFACE_TRANSACTION: { + reply.writeString(DESCRIPTOR); + return true; + } + case TRANSACTION_prepareVpn: { + data.enforceInterface(DESCRIPTOR); + java.lang.String _arg0; + _arg0 = data.readString(); + java.lang.String _arg1; + _arg1 = data.readString(); + boolean _result = this.prepareVpn(_arg0, _arg1); + reply.writeNoException(); + reply.writeInt(((_result) ? (1) : (0))); + return true; + } + } + return super.onTransact(code, data, reply, flags); + } + + private static class Proxy implements IConnectivityManager { + private android.os.IBinder mRemote; + + Proxy(android.os.IBinder remote) { + mRemote = remote; + } + + @Override + public android.os.IBinder asBinder() { + return mRemote; + } + + public java.lang.String getInterfaceDescriptor() { + return DESCRIPTOR; + } + + @Override + public boolean prepareVpn(java.lang.String oldPackage, java.lang.String newPackage) throws android.os.RemoteException { + android.os.Parcel _data = android.os.Parcel.obtain(); + android.os.Parcel _reply = android.os.Parcel.obtain(); + boolean _result; + try { + _data.writeInterfaceToken(DESCRIPTOR); + _data.writeString(oldPackage); + _data.writeString(newPackage); + mRemote.transact(Stub.TRANSACTION_prepareVpn, _data, _reply, 0); + _reply.readException(); + _result = (0 != _reply.readInt()); + } finally { + _reply.recycle(); + _data.recycle(); + } + return _result; + } + } + } +} diff --git a/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/VpnDialogPatcher.java b/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/VpnDialogPatcher.java new file mode 100644 index 00000000..74cd97e4 --- /dev/null +++ b/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/VpnDialogPatcher.java @@ -0,0 +1,66 @@ +package de.blinkt.vpndialogxposed; + +import android.app.Activity; +import android.content.Context; +import android.os.IBinder; +import android.widget.Toast; +import de.robv.android.xposed.IXposedHookLoadPackage; +import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XposedBridge; +import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam; + +import java.lang.reflect.Method; + +public class VpnDialogPatcher implements IXposedHookLoadPackage { + @Override + public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable { + if (!lpparam.packageName.equals("com.android.vpndialogs")) + return; + + + XposedBridge.log("Got VPN Dialog"); + + XposedHelpers.findAndHookMethod("com.android.vpndialogs.ConfirmDialog", lpparam.classLoader, + "onResume", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + + // IConnectivityManager mService = IConnectivityManager.Stub.asInterface( + // ServiceManager.getService(Context.CONNECTIVITY_SERVICE)); + + try { + + /*Class servicemanager = Class.forName("android.os.ServiceManager"); + Method getService = servicemanager.getMethod("getService",String.class); + + IConnectivityManager mService = IConnectivityManager.Stub.asInterface( + (IBinder) getService.invoke(servicemanager, Context.CONNECTIVITY_SERVICE)); + */ + + Object mService = XposedHelpers.getObjectField(param.thisObject, "mService"); + + String mPackage = ((Activity) param.thisObject).getCallingPackage(); + + // App is already allowed do nothing + if (mService.prepareVpn(mPackage, null)) { + return; + } + + if (mPackage.equals("de.blinkt.openvpn")) { + mService.prepareVpn(null, mPackage); + Toast.makeText((Context)param.thisObject,"Allowed de.blinkt.openvpn",Toast.LENGTH_LONG).show(); + } + + } catch (Exception e) { + e.printStackTrace(); + + } + + } + + + }); + + } +} diff --git a/vpndialogxposed/src/main/res/drawable-hdpi/ic_launcher.png b/vpndialogxposed/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..a134d5fa Binary files /dev/null and b/vpndialogxposed/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/vpndialogxposed/src/main/res/drawable-mdpi/ic_launcher.png b/vpndialogxposed/src/main/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..ad6d2155 Binary files /dev/null and b/vpndialogxposed/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/vpndialogxposed/src/main/res/drawable-xhdpi/ic_launcher.png b/vpndialogxposed/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..10d3c009 Binary files /dev/null and b/vpndialogxposed/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/vpndialogxposed/src/main/res/drawable-xxhdpi/ic_launcher.png b/vpndialogxposed/src/main/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..22db1531 Binary files /dev/null and b/vpndialogxposed/src/main/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/vpndialogxposed/src/main/res/layout/activity_main.xml b/vpndialogxposed/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..efcbf18d --- /dev/null +++ b/vpndialogxposed/src/main/res/layout/activity_main.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/vpndialogxposed/src/main/res/menu/main.xml b/vpndialogxposed/src/main/res/menu/main.xml new file mode 100644 index 00000000..f3b10b6c --- /dev/null +++ b/vpndialogxposed/src/main/res/menu/main.xml @@ -0,0 +1,6 @@ + + + diff --git a/vpndialogxposed/src/main/res/values/strings.xml b/vpndialogxposed/src/main/res/values/strings.xml new file mode 100644 index 00000000..f233e945 --- /dev/null +++ b/vpndialogxposed/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ + + + + VpnDialog Xposed Module + Settings + Hello world! + + diff --git a/vpndialogxposed/src/main/res/values/styles.xml b/vpndialogxposed/src/main/res/values/styles.xml new file mode 100644 index 00000000..6ce89c7b --- /dev/null +++ b/vpndialogxposed/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + -- cgit v1.2.3