-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
77 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/me/firesun/wechat/enhancement/plugin/AutoLogin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package me.firesun.wechat.enhancement.plugin; | ||
|
||
|
||
import android.app.Activity; | ||
import android.widget.Button; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
import de.robv.android.xposed.XC_MethodHook; | ||
import de.robv.android.xposed.XposedHelpers; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import me.firesun.wechat.enhancement.PreferencesUtils; | ||
import me.firesun.wechat.enhancement.util.HookClasses; | ||
import me.firesun.wechat.enhancement.util.ReflectionUtil; | ||
|
||
import static de.robv.android.xposed.XposedBridge.log; | ||
|
||
|
||
public class AutoLogin { | ||
private static AutoLogin instance = null; | ||
|
||
private AutoLogin() { | ||
} | ||
|
||
public static AutoLogin getInstance() { | ||
if (instance == null) | ||
instance = new AutoLogin(); | ||
return instance; | ||
} | ||
|
||
public void hook(XC_LoadPackage.LoadPackageParam lpparam) { | ||
XposedHelpers.findAndHookMethod(android.app.Activity.class, "onStart", new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(MethodHookParam param) { | ||
try { | ||
if (!PreferencesUtils.isAutoLogin()) | ||
return; | ||
Activity activity = (Activity) param.thisObject; | ||
if (activity.getClass().getName().equals(HookClasses.WebWXLoginUIClassName)) { | ||
Class clazz = activity.getClass(); | ||
Field field = XposedHelpers.findFirstFieldByExactType(clazz, Button.class); | ||
Button button = (Button) field.get(activity); | ||
if (button != null) { | ||
button.performClick(); | ||
} | ||
} | ||
|
||
} catch (Error | Exception e) { | ||
log("error:" + e); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters