@@ -407,27 +407,29 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
407407 private fun testInterception () {
408408 app.trackEvent(" Button" , " test-interception" )
409409
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-
414410 val certIsSystemTrusted = whereIsCertTrusted(
415411 this .currentProxyConfig!! // Safe!! because you can only run tests while connected
416412 ) == " system"
417413
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+
418422 val browserIntent = Intent (
419423 Intent .ACTION_VIEW ,
420424 Uri .parse(
421425 (
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"
425429 ) + " ://amiusing.httptoolkit.tech"
426430 )
427431 ).apply {
428- if (testBrowserPackage != null ) {
429- setPackage(testBrowserPackage)
430- }
432+ if (testBrowser != null ) setPackage(testBrowser)
431433 }
432434 startActivity(browserIntent)
433435 }
0 commit comments