@@ -407,27 +407,29 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
407
407
private fun testInterception () {
408
408
app.trackEvent(" Button" , " test-interception" )
409
409
410
- // If there's a supported browser available, make sure we use it. This prioritises
411
- // the default browser, and only returns null if no known supported browser is installed.
412
- val testBrowserPackage = getTestBrowserPackage(this )
413
-
414
410
val certIsSystemTrusted = whereIsCertTrusted(
415
411
this .currentProxyConfig!! // Safe!! because you can only run tests while connected
416
412
) == " system"
417
413
414
+ val testBrowser = if (certIsSystemTrusted) {
415
+ null // If we have a system cert, we can safely always use the system browser
416
+ } else {
417
+ // If not, and there is a supported browser available, we use it. This prioritises
418
+ // the default browser, and only returns null if no known supported browser exists.
419
+ getTestBrowserPackage(this )
420
+ }
421
+
418
422
val browserIntent = Intent (
419
423
Intent .ACTION_VIEW ,
420
424
Uri .parse(
421
425
(
422
- // We test with just plain HTTP if there's no user-cert-trusting browser
423
- // installed , to reduce confusing failures.
424
- if (testBrowserPackage == null && ! certIsSystemTrusted) " http" else " https"
426
+ // We test with just plain HTTP if we don't have system injection setup and
427
+ // there's no user-cert-trusting browser , to reduce confusing failures.
428
+ if (testBrowser == null && ! certIsSystemTrusted) " http" else " https"
425
429
) + " ://amiusing.httptoolkit.tech"
426
430
)
427
431
).apply {
428
- if (testBrowserPackage != null ) {
429
- setPackage(testBrowserPackage)
430
- }
432
+ if (testBrowser != null ) setPackage(testBrowser)
431
433
}
432
434
startActivity(browserIntent)
433
435
}
0 commit comments