|
1 | 1 | package com.yyxx.wechatfp; |
2 | 2 |
|
3 | 3 | import android.annotation.TargetApi; |
4 | | -import android.app.Activity; |
| 4 | +import android.app.Application; |
5 | 5 | import android.content.Context; |
6 | | -import android.content.SharedPreferences; |
7 | | -import android.content.pm.PackageInfo; |
8 | | -import android.os.Bundle; |
9 | | -import android.provider.Settings; |
10 | | -import android.view.View; |
11 | | -import android.widget.EditText; |
12 | | -import android.widget.ImageView; |
13 | | -import android.widget.RelativeLayout; |
14 | | -import android.widget.TextView; |
15 | | -import android.widget.Toast; |
16 | | - |
17 | | -import com.wei.android.lib.fingerprintidentify.FingerprintIdentify; |
18 | | -import com.wei.android.lib.fingerprintidentify.base.BaseFingerprint; |
19 | | -import com.yyxx.wechatfp.ObfuscationHelper.MM_Classes; |
20 | | -import com.yyxx.wechatfp.ObfuscationHelper.MM_Fields; |
21 | | -import com.yyxx.wechatfp.ObfuscationHelper.MM_Res; |
22 | | -import com.yyxx.wechatfp.Utils.AESHelper; |
23 | 6 |
|
24 | 7 | import de.robv.android.xposed.IXposedHookLoadPackage; |
25 | 8 | import de.robv.android.xposed.IXposedHookZygoteInit; |
|
30 | 13 |
|
31 | 14 |
|
32 | 15 | public class WalletBaseUI implements IXposedHookZygoteInit, IXposedHookLoadPackage { |
33 | | - private static Activity mWalletPayUIActivity; |
34 | | - private static EditText mInputEditText; |
35 | | - private RelativeLayout mPasswordLayout; |
36 | | - private ImageView mFingerprintImageView; |
37 | | - private RelativeLayout mFingerPrintLayout; |
38 | | - private TextView mPayTitleTextView, mPasswordTextView; |
39 | | - private static FingerprintIdentify mFingerprintIdentify; |
40 | | - private static boolean mNeedFingerprint; |
| 16 | + |
41 | 17 | public static final String WECHAT_PACKAGENAME = "com.tencent.mm"; |
42 | 18 |
|
43 | 19 | public void initZygote(StartupParam startupParam) throws Throwable { |
44 | 20 | } |
45 | 21 |
|
46 | 22 | @Override |
47 | | - public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable { |
48 | | - XposedBridge.log("loaded: [" + lpparam.packageName + "]"); |
| 23 | + public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable { |
49 | 24 | if (lpparam.packageName.equals(WECHAT_PACKAGENAME)) { |
50 | | - try { |
51 | | - final Context context = (Context) XposedHelpers.callMethod(XposedHelpers.callStaticMethod(XposedHelpers.findClass("android.app.ActivityThread", null), "currentActivityThread", new Object[0]), "getSystemContext", new Object[0]); |
52 | | - PackageInfo packageInfo = context.getPackageManager().getPackageInfo(WECHAT_PACKAGENAME, 0); |
53 | | - int versionCode = packageInfo.versionCode; |
54 | | - String versionName = packageInfo.versionName; |
55 | | - boolean isVersionSupported = ObfuscationHelper.init(versionCode, versionName, lpparam); |
56 | | - if (!isVersionSupported) { |
57 | | - Toast.makeText(context, "当前版本:" + versionName + "." + versionCode + "不支持", Toast.LENGTH_LONG).show(); |
58 | | - XposedBridge.log("当前版本:" + versionName + "." + versionCode + "不支持"); |
59 | | - return; |
60 | | - } |
61 | | - |
62 | | - |
63 | | - XposedHelpers.findAndHookMethod(MM_Classes.PayUI, "onCreate", Bundle.class, new XC_MethodHook() { |
64 | | - @TargetApi(21) |
65 | | - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
66 | | - mWalletPayUIActivity = (Activity) param.thisObject; |
67 | | - mNeedFingerprint = true; |
68 | | - } |
69 | | - }); |
70 | | - XposedHelpers.findAndHookMethod(MM_Classes.FetchUI, "onCreate", Bundle.class, new XC_MethodHook() { |
71 | | - @TargetApi(21) |
72 | | - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
73 | | - mWalletPayUIActivity = (Activity) param.thisObject; |
74 | | - mNeedFingerprint = true; |
75 | | - } |
76 | | - }); |
77 | | - XposedHelpers.findAndHookConstructor(MM_Classes.Payview, Context.class, new XC_MethodHook() { |
78 | | - @TargetApi(21) |
79 | | - protected void afterHookedMethod(MethodHookParam param) throws Throwable { |
80 | | - SharedPreferences xmodPrefs = XPreferenceProvider.getRemoteSharedPreference(context); |
81 | | - XposedBridge.log("设置数量" + String.valueOf(xmodPrefs.getAll().size())); |
82 | | - boolean fingerPrintEnabled = xmodPrefs.getBoolean("enable_fp", false); |
83 | | - XposedBridge.log("fingerPrintEnabled:" + fingerPrintEnabled); |
84 | | - |
85 | | - if (fingerPrintEnabled && mNeedFingerprint && mWalletPayUIActivity != null) { |
86 | | - initFingerPrintLock(); |
87 | | - mPasswordLayout = (RelativeLayout) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PaypwdView); |
88 | | - mInputEditText = (EditText) XposedHelpers.getObjectField(mPasswordLayout, MM_Fields.PaypwdEditText); |
89 | | - XposedBridge.log("密码输入框:" + mInputEditText.getClass().getName()); |
90 | | - mInputEditText.setVisibility(View.GONE); |
91 | | - mPayTitleTextView = (TextView) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PayTitle); |
92 | | - mPayTitleTextView.setText(MM_Res.Finger_title); |
93 | | - final View mKeyboard = (View) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PayInputView); |
94 | | - XposedBridge.log("密码键盘:" + mKeyboard.getClass().getName()); |
95 | | - mKeyboard.setVisibility(View.GONE); |
96 | | - mFingerPrintLayout = new RelativeLayout(mWalletPayUIActivity); |
97 | | - RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); |
98 | | - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); |
99 | | - mFingerPrintLayout.setLayoutParams(layoutParams); |
100 | | - mFingerprintImageView = new ImageView(mWalletPayUIActivity); |
101 | | - mFingerprintImageView.setImageResource(MM_Res.Finger_icon); |
102 | | - mFingerPrintLayout.addView(mFingerprintImageView); |
103 | | - mPasswordLayout.addView(mFingerPrintLayout); |
104 | | - mFingerprintImageView.setOnClickListener(new View.OnClickListener() { |
105 | | - @Override |
106 | | - public void onClick(View view) { |
107 | | - mPasswordLayout.removeView(mFingerPrintLayout); |
108 | | - mInputEditText.setVisibility(View.VISIBLE); |
109 | | - mKeyboard.setVisibility(View.VISIBLE); |
110 | | - mFingerprintIdentify.cancelIdentify(); |
111 | | - mPayTitleTextView.setText(MM_Res.passwd_title); |
112 | | - } |
113 | | - }); |
114 | | - mPasswordTextView = (TextView) XposedHelpers.getObjectField(param.thisObject, MM_Fields.Passwd_Text); |
115 | | - mPasswordTextView.setVisibility(View.VISIBLE); |
116 | | - mPasswordTextView.setOnClickListener(new View.OnClickListener() { |
117 | | - @Override |
118 | | - public void onClick(View view) { |
119 | | - mPasswordLayout.removeView(mFingerPrintLayout); |
120 | | - mInputEditText.setVisibility(View.VISIBLE); |
121 | | - mKeyboard.setVisibility(View.VISIBLE); |
122 | | - mFingerprintIdentify.cancelIdentify(); |
123 | | - mPayTitleTextView.setText(MM_Res.passwd_title); |
124 | | - } |
125 | | - }); |
126 | | - } else { |
127 | | - |
128 | | - } |
129 | | - } |
130 | | - }); |
131 | | - XposedHelpers.findAndHookMethod(MM_Classes.Payview, "dismiss", new XC_MethodHook() { |
132 | | - @TargetApi(21) |
133 | | - protected void afterHookedMethod(MethodHookParam param) throws Throwable { |
134 | | - XposedBridge.log(new Exception()); |
135 | | - if (mWalletPayUIActivity != null) { |
136 | | - mFingerprintIdentify.cancelIdentify(); |
137 | | - mWalletPayUIActivity = null; |
138 | | - mNeedFingerprint = false; |
139 | | - } |
140 | | - } |
141 | | - }); |
142 | | - } catch (Throwable l) { |
143 | | - XposedBridge.log(l); |
144 | | - } |
145 | | - } |
146 | | - } |
147 | | - |
148 | | - public static void initFingerPrintLock() { |
149 | | - mFingerprintIdentify = new FingerprintIdentify(mWalletPayUIActivity); |
150 | | - if (mFingerprintIdentify.isFingerprintEnable()) { |
151 | | - mFingerprintIdentify.startIdentify(3, new BaseFingerprint.FingerprintIdentifyListener() { |
152 | | - @Override |
153 | | - public void onSucceed() { |
154 | | - // 验证成功,自动结束指纹识别 |
155 | | - Toast.makeText(mWalletPayUIActivity, "指纹识别成功", Toast.LENGTH_SHORT).show(); |
156 | | - onSuccessUnlock(mWalletPayUIActivity); |
157 | | - } |
158 | | - |
159 | | - @Override |
160 | | - public void onNotMatch(int availableTimes) { |
161 | | - // 指纹不匹配,并返回可用剩余次数并自动继续验证 |
162 | | - Toast.makeText(mWalletPayUIActivity, "指纹识别失败,还可尝试" + String.valueOf(availableTimes) + "次", Toast.LENGTH_SHORT).show(); |
163 | | - } |
164 | | - |
165 | | - @Override |
166 | | - public void onFailed(boolean isDeviceLocked) { |
167 | | - // 错误次数达到上限或者API报错停止了验证,自动结束指纹识别 |
168 | | - // isDeviceLocked 表示指纹硬件是否被暂时锁定 |
169 | | - Toast.makeText(mWalletPayUIActivity, "多次尝试错误,请确认指纹", Toast.LENGTH_SHORT).show(); |
170 | | - } |
171 | | - |
172 | | - @Override |
173 | | - public void onStartFailedByDeviceLocked() { |
174 | | - // 第一次调用startIdentify失败,因为设备被暂时锁定 |
175 | | - Toast.makeText(mWalletPayUIActivity, "系统限制,重启后必须验证密码后才能使用指纹验证", Toast.LENGTH_SHORT).show(); |
| 25 | + XposedBridge.log("loaded: [" + lpparam.packageName + "]" + " version:" + BuildConfig.VERSION_NAME); |
| 26 | + XposedHelpers.findAndHookMethod(Application.class, "onCreate", new XC_MethodHook() { |
| 27 | + @TargetApi(21) |
| 28 | + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
| 29 | + XposedBridge.log("Application onCreate"); |
| 30 | + Context context = (Context) param.thisObject; |
| 31 | + XposedPluginLoader.load(XposedPlugin.class, context, lpparam); |
176 | 32 | } |
177 | 33 | }); |
178 | 34 | } |
179 | 35 | } |
180 | | - |
181 | | - private static void onSuccessUnlock(Context context) { |
182 | | - String pwd; |
183 | | - String ANDROID_ID = Settings.System.getString(mWalletPayUIActivity.getContentResolver(), Settings.System.ANDROID_ID); |
184 | | - |
185 | | - SharedPreferences xmodPrefs = XPreferenceProvider.getRemoteSharedPreference(context); |
186 | | - XposedBridge.log("设置数量" + String.valueOf(xmodPrefs.getAll().size())); |
187 | | - if (xmodPrefs.getAll().size() > 0) { |
188 | | - pwd = xmodPrefs.getString("paypwd", ""); |
189 | | - } else { |
190 | | - pwd = ""; |
191 | | - } |
192 | | - if (pwd.length() > 0) { |
193 | | - mInputEditText.setText(AESHelper.decrypt(pwd, ANDROID_ID)); |
194 | | - } else { |
195 | | - Toast.makeText(mWalletPayUIActivity, "未设定支付密码,请在WechatFp中设定微信的支付密码", Toast.LENGTH_SHORT).show(); |
196 | | - } |
197 | | - |
198 | | - } |
199 | 36 | } |
0 commit comments