@hanwha-ss1/plugin 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,6 +53,7 @@ dependencies {
53
53
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
54
54
  implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
55
55
  implementation 'androidx.core:core:1.6.0'
56
+ implementation 'androidx.fragment:fragment:1.3.5'
56
57
  testImplementation "junit:junit:$junitVersion"
57
58
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
58
59
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
@@ -2,7 +2,6 @@ package com.plugin.bio;
2
2
 
3
3
  import android.app.Activity;
4
4
  import android.util.Log;
5
- import android.view.WindowManager;
6
5
 
7
6
 
8
7
  public class Bio {
@@ -3,7 +3,6 @@ package com.plugin.bio;
3
3
  import android.Manifest;
4
4
  import android.app.Activity;
5
5
  import android.app.KeyguardManager;
6
- import android.content.Context;
7
6
  import android.content.Intent;
8
7
  import android.content.pm.PackageManager;
9
8
  import android.hardware.fingerprint.FingerprintManager;
@@ -56,13 +55,10 @@ public class BioAuthManager {
56
55
  private BiometricPrompt.CryptoObject bioCryptoObject; // over api 28
57
56
 
58
57
  private boolean canAuthenticate(Activity activity){
59
-
60
58
  Intent intent;
61
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
62
- {
59
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
63
60
  BiometricManager biometricManager = BiometricManager.from(activity);
64
- switch (biometricManager.canAuthenticate(BIOMETRIC_STRONG))
65
- {
61
+ switch (biometricManager.canAuthenticate(BIOMETRIC_STRONG)) {
66
62
  case BiometricManager.BIOMETRIC_SUCCESS:
67
63
  Log.d("MY_APP_TAG", "App can authenticate using biometrics.");
68
64
  return true;
@@ -82,36 +78,31 @@ public class BioAuthManager {
82
78
  activity.startActivityForResult(intent, REQUEST_FINGERPRINT_ENROLLMENT_AUTH);
83
79
  return false;
84
80
  }
85
- }
86
- else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
87
- {
88
- if (!fingerprintManager.isHardwareDetected()) // 지문을 사용할 수 없는 디바이스인 경우
89
- {
81
+ } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
82
+ // 지문을 사용할 없는 디바이스인 경우
83
+ if (!fingerprintManager.isHardwareDetected()) {
90
84
  Log.d("fingerprint", "it is not device that can use fingerprint");
91
85
  return false;
92
86
  }
93
87
  // 지문 인증 사용을 거부한 경우
94
- else if (ContextCompat.checkSelfPermission(activity, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED)
95
- {
88
+ else if (activity.checkSelfPermission(Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
96
89
  Log.d("fingerprint", "permission denied");
97
90
  return false;
98
91
  }
99
- else if (!keyguardManager.isKeyguardSecure()) // 잠금 화면이 설정되지 않은 경우
100
- {
92
+ // 잠금 화면이 설정되지 않은 경우
93
+ else if (!keyguardManager.isKeyguardSecure()) {
101
94
  Log.d("fingerprint", "please set lock screen");
102
95
  return false;
103
96
  }
104
- else if (!fingerprintManager.hasEnrolledFingerprints()) // 등록된 지문이 없는 경우
105
- {
97
+ // 등록된 지문이 없는 경우
98
+ else if (!fingerprintManager.hasEnrolledFingerprints()) {
106
99
  Log.d("fingerprint", "please enroll fingerprint");
107
100
  intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
108
101
  activity.startActivityForResult(intent, REQUEST_FINGERPRINT_ENROLLMENT_AUTH);
109
102
  return false;
110
103
  }
111
-
112
104
  return true;
113
105
  }
114
-
115
106
  return false;
116
107
  }
117
108
 
@@ -123,9 +114,8 @@ public class BioAuthManager {
123
114
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
124
115
  Log.d("bioAuth", "start biometricPrompt");
125
116
 
126
- if (canAuthenticate(activity))
127
- {
128
- executor = ContextCompat.getMainExecutor(activity);
117
+ if (canAuthenticate(activity)) {
118
+ executor = activity.getMainExecutor();
129
119
 
130
120
  biometricPrompt = new BiometricPrompt((FragmentActivity) activity, executor, new BiometricPrompt.AuthenticationCallback() {
131
121
  @Override
@@ -161,7 +151,7 @@ public class BioAuthManager {
161
151
  promptInfo = new BiometricPrompt.PromptInfo.Builder()
162
152
  .setTitle("지문 인증")
163
153
  .setSubtitle("기기에 등록된 지문을 이용하여 지문을 인증해주세요.")
164
- .setDescription("생체 인증 설명")
154
+ // .setDescription("생체 인증 설명")
165
155
  // BIOMETRIC_STRONG 은 안드로이드 11 에서 정의한 클래스 3 생체 인식을 사용하는 인증 - 암호회된 키 필요
166
156
  // BIOMETRIC_WEAK 은 안드로이드 11 에서 정의한 클래스 2 생체 인식을 사용하는 인증 - 암호화된 키까지 필요하지는 않음
167
157
  // DEVICE_CREDENTIAL 은 화면 잠금 사용자 인증 정보를 사용하는 인증 - 사용자의 PIN, 패턴 또는 비밀번호
@@ -172,8 +162,7 @@ public class BioAuthManager {
172
162
 
173
163
  keyManager.generateKey();
174
164
 
175
- if (keyManager.cipherInit())
176
- {
165
+ if (keyManager.cipherInit()) {
177
166
  bioCryptoObject = new BiometricPrompt.CryptoObject(keyManager.getCipher());
178
167
  biometricPrompt.authenticate(promptInfo, bioCryptoObject);
179
168
  }
@@ -182,38 +171,19 @@ public class BioAuthManager {
182
171
  }
183
172
 
184
173
  }
185
- else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)// api 23 ( ANDROID 6.0 ) 부터 api 28 ( ANDROID 9.0 ) 까지는 fingerprint 사용
186
- {
174
+ // api 23 ( ANDROID 6.0 ) 부터 api 28 ( ANDROID 9.0 ) 까지는 fingerprint 사용
175
+ else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
187
176
  Log.d("fingerprint", "fingerprint start");
188
177
 
189
178
  fingerprintManager = (FingerprintManager) activity.getSystemService(FINGERPRINT_SERVICE);
190
179
  keyguardManager = (KeyguardManager) activity.getSystemService(KEYGUARD_SERVICE);
191
- // if (!fingerprintManager.isHardwareDetected()) // 지문을 사용할 수 없는 디바이스인 경우
192
- // {
193
- // Log.d("fingerprint", "it is not device that can use fingerprint");
194
- // }
195
- // // 지문 인증 사용을 거부한 경우
196
- // else if (ContextCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED)
197
- // {
198
- // Log.d("fingerprint", "permission denied");
199
- // }
200
- // else if (!keyguardManager.isKeyguardSecure()) // 잠금 화면이 설정되지 않은 경우
201
- // {
202
- // Log.d("fingerprint", "please set lock screen");
203
- // }
204
- // else if (!fingerprintManager.hasEnrolledFingerprints()) // 등록된 지문이 없는 경우
205
- // {
206
- // Log.d("fingerprint", "please enroll fingerprint");
207
- // }
208
- // else
209
- if (canAuthenticate(activity))
210
- {
180
+
181
+ if (canAuthenticate(activity)) {
211
182
  Log.d("fingerprint", "requirement fingerprint needed all pass");
212
183
 
213
184
  keyManager.generateKey();
214
185
 
215
- if (keyManager.cipherInit())
216
- {
186
+ if (keyManager.cipherInit()) {
217
187
 
218
188
  Cipher cipher = keyManager.getCipher();
219
189
 
@@ -224,31 +194,40 @@ public class BioAuthManager {
224
194
  public void onAuthenticationError(int errorCode, CharSequence errString) {
225
195
  super.onAuthenticationError(errorCode, errString);
226
196
  Log.d("fingerprint", String.valueOf(errorCode));
197
+ if(callback != null) {
198
+ callback.onFail(errString.toString());
199
+ }
227
200
  }
228
201
 
229
202
  @Override
230
203
  public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
231
204
  super.onAuthenticationSucceeded(result);
232
205
  Log.d("fingerprint", "auth success");
233
-
206
+ if(callback != null) {
207
+ callback.onSuccess();
208
+ }
234
209
  }
235
210
 
236
211
  @Override
237
212
  public void onAuthenticationFailed() {
238
213
  super.onAuthenticationFailed();
239
214
  Log.d("fingerprint", "auth failed");
240
-
215
+ if(callback != null) {
216
+ callback.onFail("auth failed");
217
+ }
241
218
  }
242
219
 
243
220
  @Override
244
221
  public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
245
222
  super.onAuthenticationHelp(helpCode, helpString);
246
223
  Log.d("fingerprint", helpString.toString());
224
+ if(callback != null) {
225
+ callback.onFail(helpString.toString());
226
+ }
247
227
  }
248
228
 
249
229
  }, null);
250
230
  }
251
-
252
231
  }
253
232
  }
254
233
  }
@@ -21,7 +21,7 @@ public class BioPlugin extends Plugin{
21
21
  }
22
22
 
23
23
  @PluginMethod
24
- public void authenticate(PluginCall call) {
24
+ public void auth(PluginCall call) {
25
25
  if(implementation == null) {
26
26
  implementation = new Bio();
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanwha-ss1/plugin",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",