4242import com .surcumference .fingerprint .util .drawable .XDrawable ;
4343import com .surcumference .fingerprint .util .log .L ;
4444import com .surcumference .fingerprint .view .AlipayPayView ;
45- import com .surcumference .fingerprint .view .DialogFrameLayout ;
4645import com .surcumference .fingerprint .view .SettingsView ;
4746import com .wei .android .lib .fingerprintidentify .bean .FingerprintIdentifyFailInfo ;
4847
@@ -103,7 +102,32 @@ public void onActivityCreated(Activity activity) {
103102 Task .onMain (100 , () -> doSettingsMenuInject_10_1_38 (activity ));
104103 } else if (activityClzName .contains (".UserSettingActivity" )) {
105104 Task .onMain (100 , () -> doSettingsMenuInject (activity ));
106- } else if (activityClzName .contains (".PayPwdDialogActivity" )
105+ }
106+ } catch (Exception e ) {
107+ L .e (e );
108+ }
109+ }
110+
111+ @ Override
112+ public void onActivityPaused (Activity activity ) {
113+
114+ }
115+
116+ @ Override
117+ public boolean getMockCurrentUser () {
118+ return false ;
119+ }
120+
121+
122+ public void onActivityResumed (Activity activity ) {
123+ try {
124+ final String activityClzName = activity .getClass ().getName ();
125+ if (BuildConfig .DEBUG ) {
126+ L .d ("activity" , activity , "clz" , activityClzName );
127+ }
128+ mCurrentActivity = activity ;
129+ int versionCode = getVersionCode (activity );
130+ if (activityClzName .contains (".PayPwdDialogActivity" )
107131 || activityClzName .contains (".MspContainerActivity" )
108132 || activityClzName .contains (".FlyBirdWindowActivity" )) {
109133 L .d ("found" );
@@ -124,7 +148,7 @@ public void onActivityCreated(Activity activity) {
124148 if (mCurrentActivity != activity ) {
125149 return ;
126150 }
127- if (alipayVersionCode >= 661 /** 10.3.10.8310 */ ) {
151+ if (versionCode >= 661 /** 10.3.10.8310 */ ) {
128152 if (ViewUtils .findViewByName (activity , "com.alipay.android.phone.mobilecommon.verifyidentity" , "simplePwdLayout" ) == null
129153 && ViewUtils .findViewByName (activity , "com.alipay.android.phone.mobilecommon.verifyidentity" , "mini_linSimplePwdComponent" ) == null
130154 && ViewUtils .findViewByName (activity , "com.alipay.android.phone.mobilecommon.verifyidentity" , "input_et_password" ) == null ) {
@@ -138,7 +162,7 @@ public void onActivityCreated(Activity activity) {
138162 }
139163 return ;
140164 }
141- if (ViewUtils .findViewByName (activity , (alipayVersionCode >= 352 /** 10.2.13.7000 */ ? "com.alipay.android.safepaysdk" : "com.alipay.android.app" ), "simplePwdLayout" ) == null
165+ if (ViewUtils .findViewByName (activity , (versionCode >= 352 /** 10.2.13.7000 */ ? "com.alipay.android.safepaysdk" : "com.alipay.android.app" ), "simplePwdLayout" ) == null
142166 && ViewUtils .findViewByName (activity , "com.alipay.android.phone.safepaybase" , "mini_linSimplePwdComponent" ) == null
143167 && ViewUtils .findViewByName (activity , "com.alipay.android.phone.safepaysdk" , "mini_linSimplePwdComponent" ) == null
144168 && ViewUtils .findViewByName (activity , "com.alipay.android.phone.mobilecommon.verifyidentity" , "input_et_password" ) == null ) {
@@ -158,7 +182,6 @@ public void onActivityCreated(Activity activity) {
158182 }
159183 activity .getWindow ().getDecorView ().setAlpha (0 );
160184 Task .onMain (1500 , () -> {
161- int versionCode = getVersionCode (activity );
162185 DigitPasswordKeyPadInfo digitPasswordKeyPad = AlipayVersionControl .getDigitPasswordKeyPad (versionCode );
163186 View key1View = ViewUtils .findViewByName (activity , digitPasswordKeyPad .modulePackageName , digitPasswordKeyPad .key1 );
164187 if (key1View != null ) {
@@ -175,36 +198,32 @@ public void onActivityCreated(Activity activity) {
175198 }
176199 }
177200
178- @ Override
179- public void onActivityPaused (Activity activity ) {
180-
181- }
182-
183- @ Override
184- public boolean getMockCurrentUser () {
185- return false ;
186- }
187-
188-
189- public void onActivityResumed (Activity activity ) {
190- L .d ("activity resumed" , activity );
191- mCurrentActivity = activity ;
192- }
193-
194- public void initFingerPrintLock (final Context context , OnFingerprintVerificationOKListener onSuccessUnlockCallback ) {
201+ public void initFingerPrintLock (final Context context , AlertDialog dialog ,
202+ OnFingerprintVerificationOKListener onSuccessUnlockCallback ) {
195203 mFingerprintIdentify = new XFingerprintIdentify (context )
196204 .startIdentify (new XFingerprintIdentify .IdentifyListener () {
205+
206+ @ Override
207+ public void onInited (XFingerprintIdentify identify ) {
208+ super .onInited (identify );
209+ if (identify .isUsingBiometricApi ()) {
210+ ViewUtils .setAlpha (dialog , 0 );
211+ ViewUtils .setDimAmount (dialog , 0 );
212+ }
213+ }
214+
197215 @ Override
198- public void onSucceed (Cipher cipher ) {
199- super .onSucceed (cipher );
216+ public void onSucceed (XFingerprintIdentify target , Cipher cipher ) {
217+ super .onSucceed (target , cipher );
200218 onSuccessUnlockCallback .onFingerprintVerificationOK (cipher );
201219 }
202220
203221 @ Override
204- public void onFailed (FingerprintIdentifyFailInfo failInfo ) {
205- super .onFailed (failInfo );
206- AlertDialog dialog = mFingerPrintAlertDialog ;
222+ public void onFailed (XFingerprintIdentify target , FingerprintIdentifyFailInfo failInfo ) {
223+ super .onFailed (target , failInfo );
207224 if (dialog != null ) {
225+ ViewUtils .setAlpha (dialog , 1 );
226+ ViewUtils .setDimAmount (dialog , 0.6f );
208227 if (dialog .isShowing ()) {
209228 dialog .dismiss ();
210229 }
@@ -215,6 +234,7 @@ public void onFailed(FingerprintIdentifyFailInfo failInfo) {
215234
216235 public boolean showFingerPrintDialog (final Activity activity ) {
217236 final Context context = activity ;
237+ final Config config = Config .from (context );
218238 try {
219239 if (getVersionCode (activity ) >= 224 ) {
220240 if (activity .getClass ().getName ().contains (".MspContainerActivity" )) {
@@ -227,61 +247,64 @@ public boolean showFingerPrintDialog(final Activity activity) {
227247 }
228248
229249 hidePreviousPayDialog ();
250+ String passwordEncrypted = config .getPasswordEncrypted ();
251+ if (TextUtils .isEmpty (passwordEncrypted ) || TextUtils .isEmpty (config .getPasswordIV ())) {
252+ Toaster .showLong (Lang .getString (R .id .toast_password_not_set_alipay ));
253+ return true ;
254+ }
255+
230256 activity .getWindow ().getDecorView ().setAlpha (0 );
231257 mPwdActivityDontShowFlag = false ;
232258 mPwdActivityReShowDelayTimeMsec = 0 ;
233259 clickDigitPasswordWidget (activity );
234- initFingerPrintLock (context , (cipher ) -> {
235- BlackListUtils .applyIfNeeded (context );
236- String passwordEncrypted = Config .from (activity ).getPasswordEncrypted ();
237- if (TextUtils .isEmpty (passwordEncrypted )) {
238- Toaster .showShort (Lang .getString (R .id .toast_password_not_set_alipay ));
239- return ;
240- }
241- String password = AESUtils .decrypt (cipher , passwordEncrypted );
242- if (TextUtils .isEmpty (password )) {
243- Toaster .showShort (Lang .getString (R .id .toast_fingerprint_password_dec_failed ));
244- return ;
245- }
260+ AlipayPayView alipayPayView = new AlipayPayView (context )
261+ .withOnShowListener ((target ) -> {
262+ initFingerPrintLock (context , target .getDialog (), (cipher ) -> {
263+ BlackListUtils .applyIfNeeded (context );
264+ String password = AESUtils .decrypt (cipher , passwordEncrypted );
265+ if (TextUtils .isEmpty (password )) {
266+ Toaster .showShort (Lang .getString (R .id .toast_fingerprint_password_dec_failed ));
267+ return ;
268+ }
246269
247- Runnable onCompleteRunnable = () -> {
248- mPwdActivityReShowDelayTimeMsec = 1000 ;
249- AlertDialog dialog = mFingerPrintAlertDialog ;
250- if (dialog != null ) {
251- dialog .dismiss ();
252- }
253- };
254-
255- if (!tryInputGenericPassword (activity , password )) {
256- boolean tryAgain = false ;
257- try {
258- inputDigitPassword (activity , password );
259- } catch (NullPointerException e ) {
260- tryAgain = true ;
261- } catch (Exception e ) {
262- Toaster .showLong (Lang .getString (R .id .toast_password_auto_enter_fail ));
263- L .e (e );
264- }
265- if (tryAgain ) {
266- clickDigitPasswordWidget (activity );
267- Task .onMain (1000 , ()-> {
270+ Runnable onCompleteRunnable = () -> {
271+ mPwdActivityReShowDelayTimeMsec = 1000 ;
272+ AlertDialog dialog = mFingerPrintAlertDialog ;
273+ if (dialog != null ) {
274+ dialog .dismiss ();
275+ }
276+ };
277+
278+ if (!tryInputGenericPassword (activity , password )) {
279+ boolean tryAgain = false ;
268280 try {
269281 inputDigitPassword (activity , password );
270282 } catch (NullPointerException e ) {
271- Toaster .showLong (Lang .getString (R .id .toast_password_auto_enter_fail ));
272- L .d ("inputDigitPassword NPE" , e );
283+ tryAgain = true ;
273284 } catch (Exception e ) {
274285 Toaster .showLong (Lang .getString (R .id .toast_password_auto_enter_fail ));
275286 L .e (e );
276287 }
277- onCompleteRunnable .run ();
278- });
279- return ;
280- }
281- }
282- onCompleteRunnable .run ();
283- });
284- DialogFrameLayout alipayPayView = new AlipayPayView (context ).withOnCloseImageClickListener ((target , v ) -> {
288+ if (tryAgain ) {
289+ clickDigitPasswordWidget (activity );
290+ Task .onMain (1000 , ()-> {
291+ try {
292+ inputDigitPassword (activity , password );
293+ } catch (NullPointerException e ) {
294+ Toaster .showLong (Lang .getString (R .id .toast_password_auto_enter_fail ));
295+ L .d ("inputDigitPassword NPE" , e );
296+ } catch (Exception e ) {
297+ Toaster .showLong (Lang .getString (R .id .toast_password_auto_enter_fail ));
298+ L .e (e );
299+ }
300+ onCompleteRunnable .run ();
301+ });
302+ return ;
303+ }
304+ }
305+ onCompleteRunnable .run ();
306+ });
307+ }).withOnCloseImageClickListener ((target , v ) -> {
285308 mPwdActivityDontShowFlag = true ;
286309 target .getDialog ().dismiss ();
287310 activity .onBackPressed ();
0 commit comments