diff --git a/README.md b/README.md index 9a94b54..69980a4 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ 已适配版本:\ 微信: 6.5.8 [6.5.10-1080](https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/1.3/weixin6510.apk) 6.5.13-1081 [6.5.13-1100](https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/1.4.1/WeChat-6.5.13-1100.apk) [6.5.16-1101](https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/2.4.0/WeChat-6.5.16-1101.apk) [6.5.16-1120](https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/2.3.0/WeChat-6.5.16-1120.apk)\ -支付宝: 10.1.0.090418-114\ -淘宝: 6.11.0-161 +支付宝: 10.1.0.090418-114及以上\ +淘宝: 6.11.0-161及以上 以下软件经测试过测试, 可以正常调用支付宝、微信:\ 猫眼\ @@ -27,7 +27,7 @@ 使用步骤: -1. 下载并安装插件: https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/2.4.0/WeChatFp-2.4.0-release.apk +1. 下载并安装插件: https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/2.5.0/WeChatFp-2.5.0-release.apk 2. 下载并安装微信6.5.16-1120版本 https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/2.3.0/WeChat-6.5.16-1120.apk 3. 下载并安装支付宝10.1.0.090418-114版本 https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/2.0.0/Alipay-10.1.0.090418-114.apk 4. 下载并安装淘宝6.11.0-161版本 https://github.com/eritpchy/Xposed-Fingerprint-pay/releases/download/2.1.0/Taobao-6.11.0-161.apk @@ -38,9 +38,9 @@ 链接: https://pan.baidu.com/s/1eSq0QNw 密码: fbrg 友情提示: -1. 由于没有复杂密码的支付宝账号, 支付宝的支付密码只支持6位简单密码噢. -2. 以上提供的安装包均为 支付宝/微信/淘宝官方提供的安装包, 没有任何添加修改, 提供安装包只为方便找到指定适配过的安装包. -3. 本软件的网络功能仅限检查自己软件更新功能, 如不放心, 欢迎REVIEW代码. +1. 以上提供的安装包均为 支付宝/微信/淘宝官方提供的安装包, 没有任何添加修改, 提供安装包只为方便找到指定适配过的安装包. +2. 本软件的网络功能仅限检查自己软件更新功能, 如不放心, 欢迎REVIEW代码. +3. 不支持QQ, 别问我为什么, 反正就是不支持! ![qq](https://github.com/eritpchy/Xposed-Fingerprint-pay/raw/master/doc/qqGroup.png) diff --git a/app/build.gradle b/app/build.gradle index 4e7205e..483674d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.yyxx.wechatfp" minSdkVersion 14 targetSdkVersion 26 - versionCode 11 - versionName "2.4.0" + versionCode 12 + versionName "2.5.0" buildConfigField "String", "APP_PRODUCT_NAME", "\"WeChatFp\"" } diff --git a/app/src/main/java/com/yyxx/wechatfp/Constant.java b/app/src/main/java/com/yyxx/wechatfp/Constant.java index e067fb5..e6bec7b 100644 --- a/app/src/main/java/com/yyxx/wechatfp/Constant.java +++ b/app/src/main/java/com/yyxx/wechatfp/Constant.java @@ -12,7 +12,7 @@ public class Constant { public static final String HELP_URL_WECHAT = "https://github.com/eritpchy/Xposed-Fingerprint-pay/blob/master/doc/WeChat/README.md"; public static final String HELP_URL_ALIPAY = "https://github.com/eritpchy/Xposed-Fingerprint-pay/blob/master/doc/Alipay/README.md"; public static final String HELP_URL_TAOBAO = "https://github.com/eritpchy/Xposed-Fingerprint-pay/blob/master/doc/Taobao/README.md"; - public static final String PROJECT_URL = "https://github.com/eritpchy/WechatFp"; + public static final String PROJECT_URL = "https://github.com/eritpchy/Xposed-Fingerprint-pay"; public static final String UPDATE_URL_GITHUB = "https://api.github.com/repos/eritpchy/Xposed-Fingerprint-pay/releases/latest"; public static final String DONATE_ID_ALIPAY = "https://qr.alipay.com/FKX012222QIU52C6LATAB7"; public static final String DONATE_ID_WECHAT = "wxp://f2f0-1_Hm7XAY7SXA3B_0R0v-VJD71jYCWog"; diff --git a/app/src/main/java/com/yyxx/wechatfp/Lang.java b/app/src/main/java/com/yyxx/wechatfp/Lang.java index 4333878..a4ed89e 100644 --- a/app/src/main/java/com/yyxx/wechatfp/Lang.java +++ b/app/src/main/java/com/yyxx/wechatfp/Lang.java @@ -75,6 +75,8 @@ public class Lang { public static final int TOAST_PASSWORD_NOT_SET_ALIPAY = 0x01000010; public static final int TOAST_PASSWORD_NOT_SET_WECHAT = 0x01000011; public static final int TOAST_PASSWORD_AUTO_ENTER_FAIL = 0x01000012; + public static final int TOAST_GOTO_DONATE_PAGE_FAIL_ALIPAY = 0x01000013; + public static final int TOAST_GOTO_DONATE_PAGE_FAIL_WECHAT = 0x01000014; private static final int TEMPLATE = 0xFFFFFFFF; @@ -117,7 +119,7 @@ public static String getString(int res) { case SETTINGS_TITLE_WECHAT: return tr("微信", "微信", "WeChat"); case ENTER_PASSWORD: - return tr("请输入密码", "請輸入密碼", "Enter password"); + return tr("输入密码", "輸入密碼", "Enter password"); case SETTINGS_TITLE_SWITCH: return tr("启用", "啟用", "Enable"); case SETTINGS_TITLE_PASSWORD: @@ -173,6 +175,10 @@ public static String getString(int res) { return tr("未设定支付密码,请前往設置->指紋設置中设定微信的支付密码", "未設定支付密碼,請前往設置 -> 指紋設置中設定微信的支付密碼", "Payment password not set, please goto Settings -> Fingerprint to enter you payment password"); case TOAST_PASSWORD_AUTO_ENTER_FAIL: return tr("Oops.. 输入失败了. 请手动输入密码", "Oops.. 輸入失敗了. 請手動輸入密碼", "Oops... auto input failure, switch to manual input"); + case TOAST_GOTO_DONATE_PAGE_FAIL_ALIPAY: + return tr("调用支付宝捐赠页失败, 您可以手动转账捐赠哦, 帐号: " + Constant.AUTHOR_ALIPAY, "調用支付寶捐贈頁失敗, 您可以手動轉賬捐贈哦, 帳號: " + Constant.AUTHOR_ALIPAY, "Can't jump to Alipay donate page, You can do it manually by transfer to account: " + Constant.AUTHOR_ALIPAY); + case TOAST_GOTO_DONATE_PAGE_FAIL_WECHAT: + return tr("调用微信捐赠页失败, 您可以手动转账捐赠哦, 帐号: " + Constant.AUTHOR_WECHAT, "調用微信捐贈頁失敗, 您可以手動轉賬捐贈哦, 帳號: " + Constant.AUTHOR_WECHAT, "Can't jump to WeChat donate page, You can do it manually by transfer to account: " + Constant.AUTHOR_WECHAT); case TEMPLATE: return tr("", "", ""); } diff --git a/app/src/main/java/com/yyxx/wechatfp/activity/HomeActivity.java b/app/src/main/java/com/yyxx/wechatfp/activity/HomeActivity.java index a7390f5..22b5baf 100644 --- a/app/src/main/java/com/yyxx/wechatfp/activity/HomeActivity.java +++ b/app/src/main/java/com/yyxx/wechatfp/activity/HomeActivity.java @@ -42,7 +42,7 @@ public void onCreate(Bundle savedInstanceState) { list.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_HELP_ALIPAY), Lang.getString(Lang.SETTINGS_SUB_TITLE_HELP_ALIPAY))); list.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_HELP_TAOBAO), Lang.getString(Lang.SETTINGS_SUB_TITLE_HELP_TAOBAO))); list.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_CHECKUPDATE), Lang.getString(Lang.SETTINGS_SUB_TITLE_CHECKUPDATE))); - list.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_WEBSIDE), Lang.getString(Lang.SETTINGS_SUB_TITLE_WEBSIDE))); + list.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_WEBSIDE), PROJECT_URL)); list.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_VERSION), BuildConfig.VERSION_NAME)); mListAdapter = new PreferenceAdapter(list); listView.setAdapter(mListAdapter); diff --git a/app/src/main/java/com/yyxx/wechatfp/util/DonateUtil.java b/app/src/main/java/com/yyxx/wechatfp/util/DonateUtil.java index 776d6c8..71e3856 100644 --- a/app/src/main/java/com/yyxx/wechatfp/util/DonateUtil.java +++ b/app/src/main/java/com/yyxx/wechatfp/util/DonateUtil.java @@ -33,7 +33,7 @@ public static boolean openAlipayPayPage(Context context, String qrcode) { return false; } - public static void openWeChatPay(Context context) { + public static boolean openWeChatPay(Context context) { try { Intent donateIntent = new Intent(); donateIntent.setClassName(context, "com.tencent.mm.plugin.remittance.ui.RemittanceAdapterUI"); @@ -41,17 +41,15 @@ public static void openWeChatPay(Context context) { donateIntent.putExtra("pay_channel", 13); donateIntent.putExtra("receiver_name", Constant.DONATE_ID_WECHAT); context.startActivity(donateIntent); + return true; } catch (Exception e) { L.e(e); } + return false; } - private static void openUri(Context context, String s) { - try { - Intent intent = Intent.parseUri(s, Intent.URI_INTENT_SCHEME); - context.startActivity(intent); - } catch (Exception e) { - L.e(e); - } + private static void openUri(Context context, String s) throws Exception { + Intent intent = Intent.parseUri(s, Intent.URI_INTENT_SCHEME); + context.startActivity(intent); } } diff --git a/app/src/main/java/com/yyxx/wechatfp/util/UrlUtil.java b/app/src/main/java/com/yyxx/wechatfp/util/UrlUtil.java index b52d05e..8d13398 100644 --- a/app/src/main/java/com/yyxx/wechatfp/util/UrlUtil.java +++ b/app/src/main/java/com/yyxx/wechatfp/util/UrlUtil.java @@ -7,6 +7,8 @@ import android.net.Uri; import android.util.Log; +import com.yyxx.wechatfp.util.log.L; + /** * Created by Jason on 2017/7/7. */ @@ -59,7 +61,11 @@ public static void openUrl(Context context, String url){ Uri content_url = Uri.parse(url); intent.setData(content_url); } - context.startActivity(intent); + try { + context.startActivity(intent); + } catch (Exception e) { + L.d(e); + } } } \ No newline at end of file diff --git a/app/src/main/java/com/yyxx/wechatfp/util/ViewUtil.java b/app/src/main/java/com/yyxx/wechatfp/util/ViewUtil.java index 51bec6d..67e441c 100644 --- a/app/src/main/java/com/yyxx/wechatfp/util/ViewUtil.java +++ b/app/src/main/java/com/yyxx/wechatfp/util/ViewUtil.java @@ -174,7 +174,7 @@ public static void recursiveLoopChildren(ViewGroup parent) { } else { if (child != null) { try { - L.d("view", getViewInfo(child)); + L.d("view", getViewInfo(child), child.getTag()); } catch (Exception e) { } diff --git a/app/src/main/java/com/yyxx/wechatfp/view/DonateView.java b/app/src/main/java/com/yyxx/wechatfp/view/DonateView.java index 1ac1812..22a8e42 100644 --- a/app/src/main/java/com/yyxx/wechatfp/view/DonateView.java +++ b/app/src/main/java/com/yyxx/wechatfp/view/DonateView.java @@ -10,6 +10,7 @@ import android.widget.AdapterView; import android.widget.LinearLayout; import android.widget.ListView; +import android.widget.Toast; import com.yyxx.wechatfp.Constant; import com.yyxx.wechatfp.Lang; @@ -80,9 +81,13 @@ public void onItemClick(AdapterView adapterView, View view, int position, lon PreferenceAdapter.Data data = mListAdapter.getItem(position); final Context context = getContext(); if (Lang.getString(Lang.SETTINGS_TITLE_ALIPAY).equals(data.title)) { - DonateUtil.openAlipayPayPage(context); + if (!DonateUtil.openAlipayPayPage(context)) { + Toast.makeText(context, Lang.getString(Lang.TOAST_GOTO_DONATE_PAGE_FAIL_ALIPAY), Toast.LENGTH_LONG).show(); + } } else if (Lang.getString(Lang.SETTINGS_TITLE_WECHAT).equals(data.title)) { - DonateUtil.openWeChatPay(context); + if (!DonateUtil.openWeChatPay(context)) { + Toast.makeText(context, Lang.getString(Lang.TOAST_GOTO_DONATE_PAGE_FAIL_WECHAT), Toast.LENGTH_LONG).show(); + } } } } diff --git a/app/src/main/java/com/yyxx/wechatfp/view/PasswordInputView.java b/app/src/main/java/com/yyxx/wechatfp/view/PasswordInputView.java index 2e4f948..438d372 100644 --- a/app/src/main/java/com/yyxx/wechatfp/view/PasswordInputView.java +++ b/app/src/main/java/com/yyxx/wechatfp/view/PasswordInputView.java @@ -11,6 +11,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.EditText; +import com.yyxx.wechatfp.Constant; import com.yyxx.wechatfp.Lang; import com.yyxx.wechatfp.util.DpUtil; @@ -44,9 +45,17 @@ private void initView(Context context) { mInputView.setFocusable(true); mInputView.setFocusableInTouchMode(true); mInputView.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); - mInputView.setInputType(InputType.TYPE_CLASS_NUMBER - | InputType.TYPE_NUMBER_VARIATION_PASSWORD - ); + String packageName = context.getPackageName(); + if (Constant.PACKAGE_NAME_ALIPAY.equals(packageName) + || Constant.PACKAGE_NAME_TAOBAO.equals(packageName)) { + mInputView.setInputType(InputType.TYPE_CLASS_TEXT + | InputType.TYPE_TEXT_VARIATION_PASSWORD + ); + } else { + mInputView.setInputType(InputType.TYPE_CLASS_NUMBER + | InputType.TYPE_NUMBER_VARIATION_PASSWORD + ); + } LayoutParams layoutParam = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); int defHMargin = DpUtil.dip2px(context, 15); diff --git a/app/src/main/java/com/yyxx/wechatfp/view/SettingsView.java b/app/src/main/java/com/yyxx/wechatfp/view/SettingsView.java index 38f273b..f335cfb 100644 --- a/app/src/main/java/com/yyxx/wechatfp/view/SettingsView.java +++ b/app/src/main/java/com/yyxx/wechatfp/view/SettingsView.java @@ -88,7 +88,7 @@ private void init(Context context) { } mSettingsDataList.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_DONATE), Lang.getString(Lang.SETTINGS_SUB_TITLE_DONATE))); mSettingsDataList.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_CHECKUPDATE), Lang.getString(Lang.SETTINGS_SUB_TITLE_CHECKUPDATE))); - mSettingsDataList.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_WEBSIDE), Lang.getString(Lang.SETTINGS_SUB_TITLE_WEBSIDE))); + mSettingsDataList.add(new PreferenceAdapter.Data(Lang.getString(Lang.SETTINGS_TITLE_WEBSIDE), Constant.PROJECT_URL)); mListAdapter = new PreferenceAdapter(mSettingsDataList); rootVerticalLayout.addView(settingsTitle); diff --git a/app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedAlipayPlugin.java b/app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedAlipayPlugin.java index 6ad9ce4..d795217 100644 --- a/app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedAlipayPlugin.java +++ b/app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedAlipayPlugin.java @@ -15,6 +15,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -254,27 +255,15 @@ public void showFingerPrintDialog(final Activity activity) { return; } - String modulePackageName = "com.alipay.android.phone.safepaybase"; - View keysView[] = new View[] { - ViewUtil.findViewByName(activity, modulePackageName, "key_num_1"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_2"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_3"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_4", "key_4"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_5"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_6"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_7"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_8"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_9"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_0"), - }; - - try { - inputPassword(pwd, keysView); - } catch (NullPointerException e) { - Toast.makeText(context, Lang.getString(Lang.TOAST_PASSWORD_AUTO_ENTER_FAIL), Toast.LENGTH_LONG).show(); - } catch (Exception e) { - Toast.makeText(context, Lang.getString(Lang.TOAST_PASSWORD_AUTO_ENTER_FAIL), Toast.LENGTH_LONG).show(); - L.e(e); + if (!tryInputGenericPassword(activity, pwd)) { + try { + inputDigitPassword(activity, pwd); + } catch (NullPointerException e) { + Toast.makeText(context, Lang.getString(Lang.TOAST_PASSWORD_AUTO_ENTER_FAIL), Toast.LENGTH_LONG).show(); + } catch (Exception e) { + Toast.makeText(context, Lang.getString(Lang.TOAST_PASSWORD_AUTO_ENTER_FAIL), Toast.LENGTH_LONG).show(); + L.e(e); + } } AlertDialog dialog = mFingerPrintAlertDialog; if (dialog != null) { @@ -364,7 +353,20 @@ private void doSettingsMenuInject(final Activity activity) { } } - private void inputPassword(String password, View[] ks) { + private void inputDigitPassword(Activity activity, String password) { + String modulePackageName = "com.alipay.android.phone.safepaybase"; + View ks[] = new View[] { + ViewUtil.findViewByName(activity, modulePackageName, "key_num_1"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_2"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_3"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_4", "key_4"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_5"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_6"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_7"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_8"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_9"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_0"), + }; char[] chars = password.toCharArray(); for (char c : chars) { View v; @@ -405,4 +407,57 @@ private void inputPassword(String password, View[] ks) { ViewUtil.performActionClick(v); } } + + private boolean tryInputGenericPassword(Activity activity, String password) { + ViewGroup rootView = (ViewGroup) activity.getWindow().getDecorView(); + EditText pwdEditText = findPasswordEditText(rootView); + L.d("pwdEditText", pwdEditText); + if (pwdEditText == null) { + return false; + } + View confirmPwdBtn = findConfirmPasswordBtn(rootView); + L.d("confirmPwdBtn", confirmPwdBtn); + if (confirmPwdBtn == null) { + return false; + } + pwdEditText.setText(password); + ((View)confirmPwdBtn.getParent()).performClick(); + return true; + } + + private EditText findPasswordEditText(ViewGroup viewGroup) { + List outList = new ArrayList<>(); + ViewUtil.getChildViews(viewGroup, "", outList); + for (View view : outList) { + if (view instanceof EditText) { + if (view.getId() != -1) { + continue; + } + if (!view.isShown()) { + continue; + } + return (EditText) view; + } + } + return null; + } + + private View findConfirmPasswordBtn(ViewGroup viewGroup) { + + List outList = new ArrayList<>(); + ViewUtil.getChildViews(viewGroup, "付款", outList); + if (outList.isEmpty()) { + ViewUtil.getChildViews(viewGroup, "Pay", outList); + } + for (View view : outList) { + if (view.getId() != -1) { + continue; + } + if (!view.isShown()) { + continue; + } + return view; + } + return null; + } } diff --git a/app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedTaobaoPlugin.java b/app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedTaobaoPlugin.java index 26e2691..db9bd99 100644 --- a/app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedTaobaoPlugin.java +++ b/app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedTaobaoPlugin.java @@ -15,6 +15,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -97,7 +98,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { if (mCurrentActivity != activity) { return; } - ViewUtil.recursiveLoopChildren((ViewGroup) activity.getWindow().getDecorView()); if (ViewUtil.findViewByName(activity, "com.taobao.taobao", "mini_spwd_input") == null && ViewUtil.findViewByName(activity, "com.taobao.taobao", "simplePwdLayout") == null) { return; @@ -253,27 +253,15 @@ public void showFingerPrintDialog(final Activity activity) { return; } - String modulePackageName = "com.taobao.taobao"; - View keysView[] = new View[] { - ViewUtil.findViewByName(activity, modulePackageName, "key_num_1"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_2"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_3"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_4", "key_4"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_5"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_6"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_7"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_8"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_9"), - ViewUtil.findViewByName(activity, modulePackageName, "key_num_0"), - }; - - try { - inputPassword(pwd, keysView); - } catch (NullPointerException e) { - Toast.makeText(context, Lang.getString(Lang.TOAST_PASSWORD_AUTO_ENTER_FAIL), Toast.LENGTH_LONG).show(); - } catch (Exception e) { - Toast.makeText(context, Lang.getString(Lang.TOAST_PASSWORD_AUTO_ENTER_FAIL), Toast.LENGTH_LONG).show(); - L.e(e); + if (!tryInputGenericPassword(activity, pwd)) { + try { + inputDigitPassword(activity, pwd); + } catch (NullPointerException e) { + Toast.makeText(context, Lang.getString(Lang.TOAST_PASSWORD_AUTO_ENTER_FAIL), Toast.LENGTH_LONG).show(); + } catch (Exception e) { + Toast.makeText(context, Lang.getString(Lang.TOAST_PASSWORD_AUTO_ENTER_FAIL), Toast.LENGTH_LONG).show(); + L.e(e); + } } AlertDialog dialog = mFingerPrintAlertDialog; if (dialog != null) { @@ -363,7 +351,20 @@ private void doSettingsMenuInject(final Activity activity) { } } - private void inputPassword(String password, View[] ks) { + private void inputDigitPassword(Activity activity, String password) { + String modulePackageName = "com.taobao.taobao"; + View ks[] = new View[] { + ViewUtil.findViewByName(activity, modulePackageName, "key_num_1"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_2"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_3"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_4", "key_4"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_5"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_6"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_7"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_8"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_9"), + ViewUtil.findViewByName(activity, modulePackageName, "key_num_0"), + }; char[] chars = password.toCharArray(); for (char c : chars) { View v; @@ -404,4 +405,77 @@ private void inputPassword(String password, View[] ks) { ViewUtil.performActionClick(v); } } + + private boolean tryInputGenericPassword(Activity activity, String password) { + EditText pwdEditText = findPasswordEditText(activity); + L.d("pwdEditText", pwdEditText); + if (pwdEditText == null) { + return false; + } + View confirmPwdBtn = findConfirmPasswordBtn(activity); + L.d("confirmPwdBtn", confirmPwdBtn); + if (confirmPwdBtn == null) { + return false; + } + pwdEditText.setText(password); + confirmPwdBtn.performClick(); + return true; + } + + private EditText findPasswordEditText(Activity activity) { + View pwdEditText = ViewUtil.findViewByName(activity, "com.taobao.taobao", "input_et_password");; + if (pwdEditText instanceof EditText) { + if (!pwdEditText.isShown()) { + return null; + } + return (EditText) pwdEditText; + } + ViewGroup viewGroup = (ViewGroup)activity.getWindow().getDecorView(); + List outList = new ArrayList<>(); + ViewUtil.getChildViews(viewGroup, "", outList); + for (View view : outList) { + if (view instanceof EditText) { + if (view.getId() != -1) { + continue; + } + if (!view.isShown()) { + continue; + } + return (EditText) view; + } + } + return null; + } + + private View findConfirmPasswordBtn(Activity activity) { + View okView = ViewUtil.findViewByName(activity, "com.taobao.taobao", "button_ok"); + if (okView != null) { + if (!okView.isShown()) { + return null; + } + return okView; + } + ViewGroup viewGroup = (ViewGroup)activity.getWindow().getDecorView(); + List outList = new ArrayList<>(); + ViewUtil.getChildViews(viewGroup, "确认", outList); + if (outList.isEmpty()) { + ViewUtil.getChildViews(viewGroup, "付款", outList); + } + if (outList.isEmpty()) { + ViewUtil.getChildViews(viewGroup, "確認", outList); + } + if (outList.isEmpty()) { + ViewUtil.getChildViews(viewGroup, "Pay", outList); + } + for (View view : outList) { + if (view.getId() != -1) { + continue; + } + if (!view.isShown()) { + continue; + } + return (View) view.getParent(); + } + return null; + } }