From 5cd747ad2af7a0822d01f7f8fdb85eaf29d87ea2 Mon Sep 17 00:00:00 2001 From: Jason Eric Date: Thu, 7 Sep 2017 15:06:30 +0800 Subject: [PATCH] =?UTF-8?q?Support=20>=3D=20Android=20N=20Support=20Galaxy?= =?UTF-8?q?=20S8+=20=E6=94=AF=E6=8C=81Android=20Studio=203.0=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=A4=9A=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 23 +- .../wechatfp/ExampleInstrumentedTest.java | 26 -- app/src/main/AndroidManifest.xml | 5 + .../com/yyxx/wechatfp/SettingsActivity.java | 58 ++-- .../java/com/yyxx/wechatfp/WalletBaseUI.java | 250 +++++++++--------- .../yyxx/wechatfp/XPreferenceProvider.java | 31 +++ .../com/yyxx/wechatfp/ExampleUnitTest.java | 17 -- build.gradle | 26 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 0 10 files changed, 216 insertions(+), 222 deletions(-) delete mode 100644 app/src/androidTest/java/com/yyxx/wechatfp/ExampleInstrumentedTest.java create mode 100644 app/src/main/java/com/yyxx/wechatfp/XPreferenceProvider.java delete mode 100644 app/src/test/java/com/yyxx/wechatfp/ExampleUnitTest.java mode change 100644 => 100755 gradlew diff --git a/app/build.gradle b/app/build.gradle index 0cf2333..ca7479a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 26 + buildToolsVersion "26.0.1" defaultConfig { applicationId "com.yyxx.wechatfp" minSdkVersion 14 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 6 - versionName "1.3" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + versionName "1.3.0" } buildTypes { release { @@ -26,15 +25,9 @@ android { } } - dependencies { - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) - compile 'com.android.support:support-v4:25.1.0' - compile 'com.wei.android.lib:fingerprintidentify:1.2.1' + implementation 'com.android.support:support-v4:26.0.2' + implementation 'com.wei.android.lib:fingerprintidentify:1.2.1' + implementation 'com.crossbowffs.remotepreferences:remotepreferences:0.5' provided 'de.robv.android.xposed:api:53' - provided 'de.robv.android.xposed:api:53:sources' - - testCompile 'junit:junit:4.12' -} +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/yyxx/wechatfp/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/yyxx/wechatfp/ExampleInstrumentedTest.java deleted file mode 100644 index 84c6335..0000000 --- a/app/src/androidTest/java/com/yyxx/wechatfp/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.yyxx.wechatfp; - -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumentation test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() throws Exception { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("com.yyxx.wechatfp", appContext.getPackageName()); - } -} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b077034..8d5d2fa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,6 +32,11 @@ + + diff --git a/app/src/main/java/com/yyxx/wechatfp/SettingsActivity.java b/app/src/main/java/com/yyxx/wechatfp/SettingsActivity.java index 6f95d4b..0479638 100644 --- a/app/src/main/java/com/yyxx/wechatfp/SettingsActivity.java +++ b/app/src/main/java/com/yyxx/wechatfp/SettingsActivity.java @@ -1,15 +1,12 @@ package com.yyxx.wechatfp; -import android.app.Activity; -import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; import android.preference.PreferenceActivity; -import android.preference.PreferenceManager; import android.provider.Settings; import android.util.Log; import android.widget.Toast; @@ -34,32 +31,32 @@ public class SettingsActivity extends PreferenceActivity implements Preference.O * A preference value change listener that updates the preference's summary * to reflect its new value. */ - private SharedPreferences prefs,defaultprefs; + private SharedPreferences prefs; private EditTextPreference mPaypwd; private CheckBoxPreference mEnable; private FingerprintIdentify mFingerprintIdentify; private static final String MOD_PREFS = "fp_settings"; + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - prefs=getSharedPreferences(MOD_PREFS, 1); - defaultprefs= PreferenceManager.getDefaultSharedPreferences(this); + prefs = XPreferenceProvider.getRemoteSharedPreference(this); addPreferencesFromResource(R.xml.preference); - mEnable=(CheckBoxPreference)findPreference("enable_fp"); - mPaypwd=(EditTextPreference)findPreference("paypwd"); - mPaypwd.setText(prefs.getString("paypwd","")); - mEnable.setChecked(prefs.getBoolean("enable_fp",false)); + mEnable = (CheckBoxPreference) findPreference("enable_fp"); + mPaypwd = (EditTextPreference) findPreference("paypwd"); + mPaypwd.setText(prefs.getString("paypwd", "")); + mEnable.setChecked(prefs.getBoolean("enable_fp", false)); mPaypwd.setOnPreferenceChangeListener(this); mEnable.setOnPreferenceChangeListener(this); mEnable.setOnPreferenceClickListener(this); mPaypwd.setOnPreferenceClickListener(this); mFingerprintIdentify = new FingerprintIdentify(this); - if(!mFingerprintIdentify.isHardwareEnable()){ + if (!mFingerprintIdentify.isHardwareEnable()) { Toast.makeText(this, "指纹传感器不可用,请确认本机已配备指纹传感器", Toast.LENGTH_SHORT).show(); mEnable.setChecked(false); mEnable.setEnabled(false); mPaypwd.setEnabled(false); - }else{ - if(!mFingerprintIdentify.isRegisteredFingerprint()){ + } else { + if (!mFingerprintIdentify.isRegisteredFingerprint()) { Toast.makeText(this, "未录入指纹,请在设置中录入有效指纹", Toast.LENGTH_SHORT).show(); mEnable.setChecked(false); mEnable.setEnabled(false); @@ -71,31 +68,24 @@ public void onCreate(Bundle savedInstanceState) { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - if(preference==mPaypwd){ - SharedPreferences.Editor mEditor=prefs.edit(); - SharedPreferences.Editor dmEditor=defaultprefs.edit(); + if (preference == mPaypwd) { + SharedPreferences.Editor mEditor = prefs.edit(); String ANDROID_ID = Settings.System.getString(getContentResolver(), Settings.System.ANDROID_ID); - Log.e("deviceid",ANDROID_ID); + Log.e("deviceid", ANDROID_ID); - String pwd=(String)newValue; - Log.e("deviceid",AESHelper.encrypt(pwd,ANDROID_ID)); - if(pwd.length()>10){ - mEditor.putString("paypwd",pwd); - dmEditor.putString("paypwd",pwd); - }else{ - mEditor.putString("paypwd", AESHelper.encrypt(pwd,ANDROID_ID)); - dmEditor.putString("paypwd", AESHelper.encrypt(pwd,ANDROID_ID)); + String pwd = (String) newValue; + Log.e("deviceid", AESHelper.encrypt(pwd, ANDROID_ID)); + if (pwd.length() > 10) { + mEditor.putString("paypwd", pwd); + } else { + mEditor.putString("paypwd", AESHelper.encrypt(pwd, ANDROID_ID)); } - dmEditor.commit(); return mEditor.commit(); } - if(preference==mEnable){ - SharedPreferences.Editor mEditor=prefs.edit(); - SharedPreferences.Editor dmEditor=defaultprefs.edit(); - mEditor.putBoolean("enable_fp",(boolean)newValue); - mEditor.putBoolean("enable_fp",(boolean)newValue); - dmEditor.commit(); + if (preference == mEnable) { + SharedPreferences.Editor mEditor = prefs.edit(); + mEditor.putBoolean("enable_fp", (boolean) newValue); return mEditor.commit(); } return false; @@ -103,8 +93,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { @Override public boolean onPreferenceClick(Preference preference) { - if(preference==mPaypwd){ - mPaypwd.setText(prefs.getString("paypwd","")); + if (preference == mPaypwd) { + mPaypwd.setText(prefs.getString("paypwd", "")); } return false; } diff --git a/app/src/main/java/com/yyxx/wechatfp/WalletBaseUI.java b/app/src/main/java/com/yyxx/wechatfp/WalletBaseUI.java index 6589126..df75f25 100644 --- a/app/src/main/java/com/yyxx/wechatfp/WalletBaseUI.java +++ b/app/src/main/java/com/yyxx/wechatfp/WalletBaseUI.java @@ -4,27 +4,16 @@ import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; -import android.os.Build; +import android.content.pm.PackageInfo; import android.os.Bundle; -import android.preference.CheckBoxPreference; import android.provider.Settings; -import android.util.Log; import android.view.View; -import android.widget.BaseAdapter; import android.widget.EditText; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; -import de.robv.android.xposed.IXposedHookLoadPackage; -import de.robv.android.xposed.IXposedHookZygoteInit; -import de.robv.android.xposed.XC_MethodHook; -import de.robv.android.xposed.XSharedPreferences; -import de.robv.android.xposed.XposedBridge; -import de.robv.android.xposed.XposedHelpers; -import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam; - import com.wei.android.lib.fingerprintidentify.FingerprintIdentify; import com.wei.android.lib.fingerprintidentify.base.BaseFingerprint; import com.yyxx.wechatfp.ObfuscationHelper.MM_Classes; @@ -32,113 +21,124 @@ import com.yyxx.wechatfp.ObfuscationHelper.MM_Res; import com.yyxx.wechatfp.Utils.AESHelper; +import de.robv.android.xposed.IXposedHookLoadPackage; +import de.robv.android.xposed.IXposedHookZygoteInit; +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; public class WalletBaseUI implements IXposedHookZygoteInit, IXposedHookLoadPackage { - private static Activity WalletPayUI_Activity=null; - private static EditText mInputEditText=null; - private static XSharedPreferences XMOD_PREFS = null; - private RelativeLayout Passwd; - private ImageView fingerprint; - private RelativeLayout fp_linear; - private TextView inputpwd,passwdtv; + private static Activity mWalletPayUIActivity; + private static EditText mInputEditText; + private RelativeLayout mPasswordLayout; + private ImageView mFingerprintImageView; + private RelativeLayout mFingerPrintLayout; + private TextView mPayTitleTextView, mPasswordTextView; private static FingerprintIdentify mFingerprintIdentify; - private static boolean needfp; + private static boolean mNeedFingerprint; public static final String WECHAT_PACKAGENAME = "com.tencent.mm"; + public void initZygote(StartupParam startupParam) throws Throwable { - XMOD_PREFS = new XSharedPreferences("com.yyxx.wechatfp", "fp_settings"); - XMOD_PREFS.makeWorldReadable(); - XposedBridge.log("设置数量"+String.valueOf(XMOD_PREFS.getAll().size())); } @Override public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable { - XposedBridge.log("loaded: " + lpparam.packageName); + XposedBridge.log("loaded: [" + lpparam.packageName + "]"); if (lpparam.packageName.equals(WECHAT_PACKAGENAME)) { try { - Context context = (Context) XposedHelpers.callMethod(XposedHelpers.callStaticMethod(XposedHelpers.findClass("android.app.ActivityThread", null), "currentActivityThread", new Object[0]), "getSystemContext", new Object[0]); - if (ObfuscationHelper.init(context.getPackageManager().getPackageInfo(WECHAT_PACKAGENAME, 0).versionCode, context.getPackageManager().getPackageInfo(WECHAT_PACKAGENAME, 0).versionName, lpparam)) { - XposedHelpers.findAndHookMethod(MM_Classes.PayUI, "onCreate",Bundle.class, new XC_MethodHook() { - @TargetApi(21) - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - WalletPayUI_Activity = (Activity)param.thisObject; - needfp = true; - } - }); - XposedHelpers.findAndHookMethod(MM_Classes.FetchUI, "onCreate",Bundle.class, new XC_MethodHook() { - @TargetApi(21) - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - WalletPayUI_Activity = (Activity)param.thisObject; - needfp = true; - } - }); - XposedHelpers.findAndHookConstructor(MM_Classes.Payview ,Context.class , new XC_MethodHook() { - @TargetApi(21) - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - boolean mEnable; - XMOD_PREFS.reload(); - if(XMOD_PREFS.getAll().size()>0){ - mEnable = XMOD_PREFS.getBoolean("enable_fp",false); - }else{ - mEnable = false; - } - if(mEnable && needfp && WalletPayUI_Activity!= null){ - initFingerPrintLock(); - Passwd = (RelativeLayout)XposedHelpers.getObjectField(param.thisObject, MM_Fields.PaypwdView); - mInputEditText= (EditText) XposedHelpers.getObjectField(Passwd, MM_Fields.PaypwdEditText); - XposedBridge.log("密码输入框:" + mInputEditText.getClass().getName()); - mInputEditText.setVisibility(View.GONE); - inputpwd = (TextView) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PayTitle); - inputpwd.setText(MM_Res.Finger_title); - final View mKeyboard = (View) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PayInputView); - XposedBridge.log("密码键盘:" + mKeyboard.getClass().getName()); - mKeyboard.setVisibility(View.GONE); - fp_linear = new RelativeLayout(WalletPayUI_Activity); - RelativeLayout.LayoutParams layoutParams= new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - fp_linear.setLayoutParams(layoutParams); - fingerprint = new ImageView(WalletPayUI_Activity); - fingerprint.setImageResource(MM_Res.Finger_icon); - fp_linear.addView(fingerprint); - Passwd.addView(fp_linear); - fingerprint.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Passwd.removeView(fp_linear); - mInputEditText.setVisibility(View.VISIBLE); - mKeyboard.setVisibility(View.VISIBLE); - mFingerprintIdentify.cancelIdentify(); - inputpwd.setText(MM_Res.passwd_title); - } - }); - passwdtv = (TextView) XposedHelpers.getObjectField(param.thisObject, MM_Fields.Passwd_Text); - passwdtv.setVisibility(View.VISIBLE); - passwdtv.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Passwd.removeView(fp_linear); - mInputEditText.setVisibility(View.VISIBLE); - mKeyboard.setVisibility(View.VISIBLE); - mFingerprintIdentify.cancelIdentify(); - inputpwd.setText(MM_Res.passwd_title); - } - }); - }else{ - - } + final Context context = (Context) XposedHelpers.callMethod(XposedHelpers.callStaticMethod(XposedHelpers.findClass("android.app.ActivityThread", null), "currentActivityThread", new Object[0]), "getSystemContext", new Object[0]); + PackageInfo packageInfo = context.getPackageManager().getPackageInfo(WECHAT_PACKAGENAME, 0); + int versionCode = packageInfo.versionCode; + String versionName = packageInfo.versionName; + boolean isVersionSupported = ObfuscationHelper.init(versionCode, versionName, lpparam); + if (!isVersionSupported) { + Toast.makeText(context, "当前版本:" + versionName + "." + versionCode + "不支持", Toast.LENGTH_LONG).show(); + XposedBridge.log("当前版本:" + versionName + "." + versionCode + "不支持"); + return; + } + + + XposedHelpers.findAndHookMethod(MM_Classes.PayUI, "onCreate", Bundle.class, new XC_MethodHook() { + @TargetApi(21) + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + mWalletPayUIActivity = (Activity) param.thisObject; + mNeedFingerprint = true; + } + }); + XposedHelpers.findAndHookMethod(MM_Classes.FetchUI, "onCreate", Bundle.class, new XC_MethodHook() { + @TargetApi(21) + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + mWalletPayUIActivity = (Activity) param.thisObject; + mNeedFingerprint = true; + } + }); + XposedHelpers.findAndHookConstructor(MM_Classes.Payview, Context.class, new XC_MethodHook() { + @TargetApi(21) + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + SharedPreferences xmodPrefs = XPreferenceProvider.getRemoteSharedPreference(context); + XposedBridge.log("设置数量" + String.valueOf(xmodPrefs.getAll().size())); + boolean fingerPrintEnabled = xmodPrefs.getBoolean("enable_fp", false); + XposedBridge.log("fingerPrintEnabled:" + fingerPrintEnabled); + + if (fingerPrintEnabled && mNeedFingerprint && mWalletPayUIActivity != null) { + initFingerPrintLock(); + mPasswordLayout = (RelativeLayout) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PaypwdView); + mInputEditText = (EditText) XposedHelpers.getObjectField(mPasswordLayout, MM_Fields.PaypwdEditText); + XposedBridge.log("密码输入框:" + mInputEditText.getClass().getName()); + mInputEditText.setVisibility(View.GONE); + mPayTitleTextView = (TextView) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PayTitle); + mPayTitleTextView.setText(MM_Res.Finger_title); + final View mKeyboard = (View) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PayInputView); + XposedBridge.log("密码键盘:" + mKeyboard.getClass().getName()); + mKeyboard.setVisibility(View.GONE); + mFingerPrintLayout = new RelativeLayout(mWalletPayUIActivity); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); + mFingerPrintLayout.setLayoutParams(layoutParams); + mFingerprintImageView = new ImageView(mWalletPayUIActivity); + mFingerprintImageView.setImageResource(MM_Res.Finger_icon); + mFingerPrintLayout.addView(mFingerprintImageView); + mPasswordLayout.addView(mFingerPrintLayout); + mFingerprintImageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mPasswordLayout.removeView(mFingerPrintLayout); + mInputEditText.setVisibility(View.VISIBLE); + mKeyboard.setVisibility(View.VISIBLE); + mFingerprintIdentify.cancelIdentify(); + mPayTitleTextView.setText(MM_Res.passwd_title); + } + }); + mPasswordTextView = (TextView) XposedHelpers.getObjectField(param.thisObject, MM_Fields.Passwd_Text); + mPasswordTextView.setVisibility(View.VISIBLE); + mPasswordTextView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mPasswordLayout.removeView(mFingerPrintLayout); + mInputEditText.setVisibility(View.VISIBLE); + mKeyboard.setVisibility(View.VISIBLE); + mFingerprintIdentify.cancelIdentify(); + mPayTitleTextView.setText(MM_Res.passwd_title); + } + }); + } else { + } - }); - XposedHelpers.findAndHookMethod(MM_Classes.Payview, "dismiss", new XC_MethodHook() { - @TargetApi(21) - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - if(WalletPayUI_Activity != null){ - mFingerprintIdentify.cancelIdentify(); - WalletPayUI_Activity = null; - needfp = false; - } + } + }); + XposedHelpers.findAndHookMethod(MM_Classes.Payview, "dismiss", new XC_MethodHook() { + @TargetApi(21) + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + XposedBridge.log(new Exception()); + if (mWalletPayUIActivity != null) { + mFingerprintIdentify.cancelIdentify(); + mWalletPayUIActivity = null; + mNeedFingerprint = false; } - }); - } + } + }); } catch (Throwable l) { XposedBridge.log(l); } @@ -146,54 +146,54 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } public static void initFingerPrintLock() { - mFingerprintIdentify = new FingerprintIdentify(WalletPayUI_Activity); + mFingerprintIdentify = new FingerprintIdentify(mWalletPayUIActivity); if (mFingerprintIdentify.isFingerprintEnable()) { mFingerprintIdentify.startIdentify(3, new BaseFingerprint.FingerprintIdentifyListener() { @Override public void onSucceed() { // 验证成功,自动结束指纹识别 - Toast.makeText(WalletPayUI_Activity, "指纹识别成功", Toast.LENGTH_SHORT).show(); - onSuccessUnlock(); + Toast.makeText(mWalletPayUIActivity, "指纹识别成功", Toast.LENGTH_SHORT).show(); + onSuccessUnlock(mWalletPayUIActivity); } @Override public void onNotMatch(int availableTimes) { // 指纹不匹配,并返回可用剩余次数并自动继续验证 - Toast.makeText(WalletPayUI_Activity, "指纹识别失败,还可尝试"+String.valueOf(availableTimes)+"次", Toast.LENGTH_SHORT).show(); + Toast.makeText(mWalletPayUIActivity, "指纹识别失败,还可尝试" + String.valueOf(availableTimes) + "次", Toast.LENGTH_SHORT).show(); } @Override public void onFailed(boolean isDeviceLocked) { // 错误次数达到上限或者API报错停止了验证,自动结束指纹识别 // isDeviceLocked 表示指纹硬件是否被暂时锁定 - Toast.makeText(WalletPayUI_Activity, "多次尝试错误,请确认指纹", Toast.LENGTH_SHORT).show(); + Toast.makeText(mWalletPayUIActivity, "多次尝试错误,请确认指纹", Toast.LENGTH_SHORT).show(); } @Override public void onStartFailedByDeviceLocked() { // 第一次调用startIdentify失败,因为设备被暂时锁定 - Toast.makeText(WalletPayUI_Activity, "系统限制,重启后必须验证密码后才能使用指纹验证", Toast.LENGTH_SHORT).show(); + Toast.makeText(mWalletPayUIActivity, "系统限制,重启后必须验证密码后才能使用指纹验证", Toast.LENGTH_SHORT).show(); } }); } } - private static void onSuccessUnlock() { + + private static void onSuccessUnlock(Context context) { String pwd; - String ANDROID_ID = Settings.System.getString(WalletPayUI_Activity.getContentResolver(), Settings.System.ANDROID_ID); - if(XMOD_PREFS.getAll().size() > 0){ - pwd= XMOD_PREFS.getString("paypwd", ""); - }else{ - pwd=""; + String ANDROID_ID = Settings.System.getString(mWalletPayUIActivity.getContentResolver(), Settings.System.ANDROID_ID); + + SharedPreferences xmodPrefs = XPreferenceProvider.getRemoteSharedPreference(context); + XposedBridge.log("设置数量" + String.valueOf(xmodPrefs.getAll().size())); + if (xmodPrefs.getAll().size() > 0) { + pwd = xmodPrefs.getString("paypwd", ""); + } else { + pwd = ""; } - if(pwd.length()>0){ - mInputEditText.setText(AESHelper.decrypt(pwd,ANDROID_ID)); - }else{ - Toast.makeText(WalletPayUI_Activity, "未设定支付密码,请在WechatFp中设定微信的支付密码", Toast.LENGTH_SHORT).show(); + if (pwd.length() > 0) { + mInputEditText.setText(AESHelper.decrypt(pwd, ANDROID_ID)); + } else { + Toast.makeText(mWalletPayUIActivity, "未设定支付密码,请在WechatFp中设定微信的支付密码", Toast.LENGTH_SHORT).show(); } } - - - - } diff --git a/app/src/main/java/com/yyxx/wechatfp/XPreferenceProvider.java b/app/src/main/java/com/yyxx/wechatfp/XPreferenceProvider.java new file mode 100644 index 0000000..97966d7 --- /dev/null +++ b/app/src/main/java/com/yyxx/wechatfp/XPreferenceProvider.java @@ -0,0 +1,31 @@ +package com.yyxx.wechatfp; + +import android.content.Context; +import android.content.SharedPreferences; + +import com.crossbowffs.remotepreferences.RemotePreferenceProvider; +import com.crossbowffs.remotepreferences.RemotePreferences; + +public class XPreferenceProvider extends RemotePreferenceProvider { + + public static final String AUTHORITY = "com.yyxx.wechatfp.XPreferenceProvider"; + public static final String PREF_NAME = "main_prefs"; + + private static SharedPreferences sSharedPreferenceInstance; + + public static SharedPreferences getRemoteSharedPreference(Context context) { + if (sSharedPreferenceInstance == null) { + synchronized (XPreferenceProvider.class) { + if (sSharedPreferenceInstance == null) { + sSharedPreferenceInstance = new RemotePreferences(context, AUTHORITY, PREF_NAME); + } + } + } + return sSharedPreferenceInstance; + } + + public XPreferenceProvider() { + super(AUTHORITY, new String[] {PREF_NAME}); + } + +} \ No newline at end of file diff --git a/app/src/test/java/com/yyxx/wechatfp/ExampleUnitTest.java b/app/src/test/java/com/yyxx/wechatfp/ExampleUnitTest.java deleted file mode 100644 index 4a29bc0..0000000 --- a/app/src/test/java/com/yyxx/wechatfp/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.yyxx.wechatfp; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index c20bca1..ad055cb 100644 --- a/build.gradle +++ b/build.gradle @@ -3,18 +3,36 @@ buildscript { repositories { jcenter() + google() + mavenCentral() + maven { url 'https://maven.google.com' } } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.android.tools.build:gradle:3.0.0-beta4' } } + allprojects { repositories { + def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/' + all { ArtifactRepository repo -> + if (repo instanceof MavenArtifactRepository) { + def url = repo.url.toString() + if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) { +// project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL." + remove repo + } + } + } + maven { + url REPOSITORY_URL + } + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + + google() jcenter() + mavenCentral() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 04e285f..fc9b829 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/gradlew b/gradlew old mode 100644 new mode 100755