Skip to content

Commit 8ee1f31

Browse files
author
lucky
committed
biometric
1 parent e68d9ca commit 8ee1f31

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId "me.lucky.sentry"
1111
minSdk 23
1212
targetSdk 32
13-
versionCode 5
14-
versionName "1.0.4"
13+
versionCode 6
14+
versionName "1.0.5"
1515

1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1717
}

app/src/main/java/me/lucky/sentry/MainActivity.kt

+14-7
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ class MainActivity : AppCompatActivity() {
3131
super.onCreate(savedInstanceState)
3232
binding = ActivityMainBinding.inflate(layoutInflater)
3333
setContentView(binding.root)
34-
init()
34+
init1()
3535
if (initBiometric()) return
36+
init2()
3637
setup()
3738
}
3839

@@ -70,22 +71,28 @@ class MainActivity : AppCompatActivity() {
7071

7172
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
7273
super.onAuthenticationSucceeded(result)
74+
init2()
7375
setup()
7476
}
7577
})
76-
prompt.authenticate(BiometricPrompt.PromptInfo.Builder()
77-
.setTitle(getString(R.string.biometric_title))
78-
.setConfirmationRequired(false)
79-
.setAllowedAuthenticators(authenticators)
80-
.build())
78+
try {
79+
prompt.authenticate(BiometricPrompt.PromptInfo.Builder()
80+
.setTitle(getString(R.string.authentication))
81+
.setConfirmationRequired(false)
82+
.setAllowedAuthenticators(authenticators)
83+
.build())
84+
} catch (exc: Exception) { return false }
8185
return true
8286
}
8387

84-
private fun init() {
88+
private fun init1() {
8589
prefs = Preferences(this)
8690
prefsdb = Preferences(this, encrypted = false)
8791
prefs.copyTo(prefsdb)
8892
admin = DeviceAdminManager(this)
93+
}
94+
95+
private fun init2() {
8996
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S ||
9097
!admin.canUsbDataSignalingBeDisabled() ||
9198
!admin.isDeviceOwner())

app/src/main/res/layout/activity_main.xml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
tools:context=".MainActivity">
99

1010
<ScrollView
11-
android:id="@+id/scrollView"
1211
android:layout_width="match_parent"
1312
android:layout_height="wrap_content"
1413
app:layout_constraintEnd_toEndOf="parent"

app/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
<string name="usb_data_signaling_description">When disabled, USB data connections (except from charging functions) are prohibited.</string>
66
<string name="usb_data_signaling_change_failed_popup">Failed to change USB data signaling policy</string>
77
<string name="max_failed_password_attempts_description">Maximum number of failed password attempts.</string>
8-
<string name="biometric_title">Biometric login</string>
8+
<string name="authentication">Authentication</string>
99
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
biometric

0 commit comments

Comments
 (0)