Skip to content

Commit 39d6162

Browse files
Rufimpimterry
authored andcommitted
Basic support for Android TV startup without cert.
1 parent 2f3bdad commit 39d6162

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
2020
tools:node="remove" />
2121

22+
<uses-feature android:name="android.software.leanback"
23+
android:required="false" />
24+
<uses-feature android:name="android.hardware.touchscreen"
25+
android:required="false" />
26+
2227
<application
2328
android:name=".HttpToolkitApplication"
2429
android:allowBackup="true"
@@ -46,6 +51,7 @@
4651
<intent-filter>
4752
<action android:name="android.intent.action.MAIN" />
4853
<category android:name="android.intent.category.LAUNCHER" />
54+
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
4955
</intent-filter>
5056

5157
<intent-filter

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

Lines changed: 12 additions & 0 deletions
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
@@ -361,6 +362,13 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
361362
onActivityResult(START_VPN_REQUEST, RESULT_OK, null)
362363
}
363364
}
365+
.setNegativeButton("Continue without certificate") { _, _ ->
366+
if (vpnNotConfigured) {
367+
startActivityForResult(vpnIntent, START_VPN_REQUEST_NO_CERT)
368+
} else {
369+
onActivityResult(START_VPN_REQUEST_NO_CERT, RESULT_OK, null)
370+
}
371+
}
364372
.show()
365373
}
366374
} else if (vpnNotConfigured) {
@@ -497,6 +505,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
497505
Log.i(TAG, "onActivityResult: " + (
498506
when (requestCode) {
499507
START_VPN_REQUEST -> "start-vpn"
508+
START_VPN_REQUEST_NO_CERT -> "start-vpn-nocrt"
500509
INSTALL_CERT_REQUEST -> "install-cert"
501510
SCAN_REQUEST -> "scan-request"
502511
PICK_APPS_REQUEST -> "pick-apps"
@@ -513,6 +522,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
513522
if (requestCode == START_VPN_REQUEST && currentProxyConfig != null) {
514523
Log.i(TAG, "Installing cert...")
515524
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)
516528
} else if (requestCode == INSTALL_CERT_REQUEST) {
517529
Log.i(TAG ,"Cert installed, checking notification perms...")
518530
ensureNotificationsEnabled()

0 commit comments

Comments
 (0)