Skip to content

Commit

Permalink
⚡ Release 2.13:
Browse files Browse the repository at this point in the history
- Retry in case of SSLHandshakeException caused by hcs server
  • Loading branch information
lhwdev committed Sep 10, 2021
1 parent de2fc52 commit 10339f2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.lhwdev.selfTestMacro"
minSdkVersion 19
targetSdkVersion 31
versionCode 1012
versionName "2.12"
versionCode 1013
versionName "2.13"

multiDexEnabled true

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/lhwdev/selfTestMacro/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ class MainActivity : AppCompatActivity() {

switch_isolation.setOnCheckedChangeListener { _, isChecked ->
pref.isIsolated = isChecked
if(isChecked) AlertDialog.Builder(this).apply {
setTitle("자가격리자 옵션")
setMessage("""
|가정에서 자가격리를 하고 있으신 분은 이 옵션을 선택해주세요. 즉, 자가진단 설문에서 3번 문항에 '예'를 답해야 하는 경우입니다.
|(참고) 해당 문항:
|3. 학생 본인 또는 동거인이 방역당국에 의해 현재 자가격리가 이루어지고 있나요?
|※ 동거인이 자가격리중인 경우, ① 매 등교 희망일로부터 2일 이내 진단검사 결과가 음성인 경우 또는 ② 격리 통지를 받은 ‘즉시’ 자가격리된 동거인과 접촉이 없었던 경우는 ‘아니오’ 선택
""".trimMargin())
}.show()
}


Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/com/lhwdev/selfTestMacro/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.lhwdev.selfTestMacro

import android.app.Application
import android.content.Intent
import kotlinx.coroutines.runBlocking
import javax.net.ssl.SSLHandshakeException


class MainApplication : Application() {
override fun onCreate() {
super.onCreate()

sDebugFetch = isDebugEnabled

val last = sFetchInterceptors.first()
sFetchInterceptors.add(0) { url, fetchMethod, map, session, fetchBody ->
tryAtMost(maxTrial = 10, errorFilter = { it is SSLHandshakeException }) {
last.intercept(url, fetchMethod, map, session, fetchBody)
}
}
}
}
8 changes: 7 additions & 1 deletion app/src/main/java/com/lhwdev/selfTestMacro/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ data class UserSetting(
val studentBirth: String
)

inline fun <R> tryAtMost(maxTrial: Int, onError: (th: Throwable) -> Unit = {}, block: () -> R): R {
inline fun <R> tryAtMost(
maxTrial: Int,
errorFilter: (Throwable) -> Boolean = { true },
onError: (th: Throwable) -> Unit = {},
block: () -> R
): R {
var trialCount = 0
while(true) {
try {
return block()
} catch(th: Throwable) {
if(!errorFilter(th)) throw th
trialCount++
if(trialCount >= maxTrial) throw th
onError(th)
Expand Down

0 comments on commit 10339f2

Please sign in to comment.