Skip to content

Commit c0c9b97

Browse files
author
Dmitry Kazantsev
committed
Basic support for Android TV. Startup without cert.
1 parent 0bf3e06 commit c0c9b97

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
applicationId "tech.httptoolkit.android.v1"
1010
minSdkVersion 21
1111
targetSdkVersion 33
12-
versionCode 33
13-
versionName "1.4.0"
12+
versionCode 34
13+
versionName "1.4.1"
1414

1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616

app/src/main/java/tech/httptoolkit/android/MainActivity.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import java.security.cert.X509Certificate
4343

4444

4545
const val START_VPN_REQUEST = 123
46+
const val START_VPN_REQUEST_NO_CERT = 124
4647
const val INSTALL_CERT_REQUEST = 456
4748
const val SCAN_REQUEST = 789
4849
const val PICK_APPS_REQUEST = 499
@@ -362,7 +363,11 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
362363
}
363364
}
364365
.setNegativeButton("Continue without certificate") { _, _ ->
365-
onActivityResult(INSTALL_CERT_REQUEST, RESULT_OK, null)
366+
if (vpnNotConfigured) {
367+
startActivityForResult(vpnIntent, START_VPN_REQUEST_NO_CERT)
368+
} else {
369+
onActivityResult(START_VPN_REQUEST_NO_CERT, RESULT_OK, null)
370+
}
366371
}
367372
.show()
368373
}
@@ -500,6 +505,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
500505
Log.i(TAG, "onActivityResult: " + (
501506
when (requestCode) {
502507
START_VPN_REQUEST -> "start-vpn"
508+
START_VPN_REQUEST_NO_CERT -> "start-vpn-nocrt"
503509
INSTALL_CERT_REQUEST -> "install-cert"
504510
SCAN_REQUEST -> "scan-request"
505511
PICK_APPS_REQUEST -> "pick-apps"
@@ -516,6 +522,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
516522
if (requestCode == START_VPN_REQUEST && currentProxyConfig != null) {
517523
Log.i(TAG, "Installing cert...")
518524
ensureCertificateTrusted(currentProxyConfig!!)
525+
} else if (requestCode == START_VPN_REQUEST_NO_CERT && currentProxyConfig != null) {
526+
Log.i(TAG, "Ignore cert...")
527+
onActivityResult(INSTALL_CERT_REQUEST, RESULT_OK, null)
519528
} else if (requestCode == INSTALL_CERT_REQUEST) {
520529
Log.i(TAG ,"Cert installed, checking notification perms...")
521530
ensureNotificationsEnabled()

0 commit comments

Comments
 (0)