From: Soren Stoutner Date: Mon, 31 Oct 2022 23:24:59 +0000 (-0700) Subject: Fix possibly blocking OutputStream calls. https://redmine.stoutner.com/issues/914 X-Git-Tag: v3.12~13 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=83fa40449d1160836c4066c99fe3c141d982917a;p=PrivacyBrowserAndroid.git Fix possibly blocking OutputStream calls. https://redmine.stoutner.com/issues/914 --- diff --git a/app/src/main/assets/de/guide_tracking_ids.html b/app/src/main/assets/de/guide_tracking_ids.html index d5e00d40..2d19367a 100644 --- a/app/src/main/assets/de/guide_tracking_ids.html +++ b/app/src/main/assets/de/guide_tracking_ids.html @@ -54,6 +54,6 @@

Die Android-Systemkomponente WebView sendet mit jeder Anfrage einen X-Requested-With-Header an den betreffenden Internet-Server. Der Wert im X-Requested-With-Header entspricht dabei der Applikations-ID - im Fall von Privacy Browser com.stoutner.privacybrowser.standard. - This can be disabled by using WebView's DevTools.

+ This can be disabled using WebView's DevTools.

diff --git a/app/src/main/assets/en/guide_tracking_ids.html b/app/src/main/assets/en/guide_tracking_ids.html index 54e7f8aa..9b12a1c4 100644 --- a/app/src/main/assets/en/guide_tracking_ids.html +++ b/app/src/main/assets/en/guide_tracking_ids.html @@ -47,6 +47,6 @@

Google programmed Android’s WebView to send an X-Requested-With header with every request. The value of the X-Requested-With header is set to the application ID, which in the case of Privacy Browser is com.stoutner.privacybrowser.standard. - This can be disabled by using WebView's DevTools.

+ This can be disabled using WebView's DevTools.

diff --git a/app/src/main/assets/es/guide_tracking_ids.html b/app/src/main/assets/es/guide_tracking_ids.html index fdafda6e..0f82a1bd 100644 --- a/app/src/main/assets/es/guide_tracking_ids.html +++ b/app/src/main/assets/es/guide_tracking_ids.html @@ -49,6 +49,6 @@

Google ha programado WebView de Android para que envíe una cabecera X-Requested-With con cada solicitud. El valor de la cabecera X-Requested-With se establece con el ID de la aplicación, que en el caso de Navegador Privado es com.stoutner.privacybrowser.standard. - This can be disabled by using WebView's DevTools.

+ This can be disabled using WebView's DevTools.

diff --git a/app/src/main/assets/fr/guide_tracking_ids.html b/app/src/main/assets/fr/guide_tracking_ids.html index 371d591c..5ca74ecf 100644 --- a/app/src/main/assets/fr/guide_tracking_ids.html +++ b/app/src/main/assets/fr/guide_tracking_ids.html @@ -49,6 +49,6 @@

Google a programmé WebView d'Android pour envoyer un en-tête X-Requested-With avec chaque requête. La valeur de l'en-tête X-Requested-With est définie par l'ID de l'application, qui dans le cas de Privacy Browser est com.stoutner.privacybrowser.standard. - This can be disabled by using WebView's DevTools.

+ This can be disabled using WebView's DevTools.

\ No newline at end of file diff --git a/app/src/main/assets/it/guide_tracking_ids.html b/app/src/main/assets/it/guide_tracking_ids.html index 9f5358de..63b18038 100644 --- a/app/src/main/assets/it/guide_tracking_ids.html +++ b/app/src/main/assets/it/guide_tracking_ids.html @@ -49,6 +49,6 @@

Google ha programmato la webview di Android per inviare un'intestazione X-Requested-With con ogni richiesta. Il valore dell'intestazione X-Requested-With è impostato sulla ID della applicazione, ovvero nel caso di Privacy Browser, è com.stoutner.privacybrowser.standard. - This can be disabled by using WebView's DevTools.

+ This can be disabled using WebView's DevTools.

diff --git a/app/src/main/assets/pt-rBR/guide_tracking_ids.html b/app/src/main/assets/pt-rBR/guide_tracking_ids.html index 7da4fe98..6c231806 100644 --- a/app/src/main/assets/pt-rBR/guide_tracking_ids.html +++ b/app/src/main/assets/pt-rBR/guide_tracking_ids.html @@ -50,6 +50,6 @@

Google programmed Android’s WebView to send an X-Requested-With header with every request. The value of the X-Requested-With header is set to the application ID, which in the case of Privacy Browser is com.stoutner.privacybrowser.standard. - This can be disabled by using WebView's DevTools.

+ This can be disabled using WebView's DevTools.

diff --git a/app/src/main/assets/ru/guide_tracking_ids.html b/app/src/main/assets/ru/guide_tracking_ids.html index fe18e41e..2a7aa629 100644 --- a/app/src/main/assets/ru/guide_tracking_ids.html +++ b/app/src/main/assets/ru/guide_tracking_ids.html @@ -47,6 +47,6 @@

Google запрограммировал WebView в Android на отправку <заголовка X-Requested-With при каждом запросе. Значение заголовка X-Requested-With устанавливается как идентификатор приложения, который в случае Privacy Browser является com.stoutner.privacybrowser.standard. - This can be disabled by using WebView's DevTools.

+ This can be disabled using WebView's DevTools.

diff --git a/app/src/main/assets/tr/guide_tracking_ids.html b/app/src/main/assets/tr/guide_tracking_ids.html index ef2c6f0e..2388e855 100644 --- a/app/src/main/assets/tr/guide_tracking_ids.html +++ b/app/src/main/assets/tr/guide_tracking_ids.html @@ -47,6 +47,6 @@

Google programmed Android’s WebView to send an X-Requested-With header with every request. The value of the X-Requested-With header is set to the application ID, which in the case of Privacy Browser is com.stoutner.privacybrowser.standard. - This can be disabled by using WebView's DevTools.

+ This can be disabled using WebView's DevTools.

diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt index 75efc825..25c2bfc6 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt @@ -43,6 +43,11 @@ import com.stoutner.privacybrowser.BuildConfig import com.stoutner.privacybrowser.R +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext + import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader @@ -72,11 +77,16 @@ class LogcatActivity : AppCompatActivity() { // Open an output stream. val outputStream = contentResolver.openOutputStream(fileUri)!! - // Write the logcat string to the output stream. - outputStream.write(logcatString.toByteArray(StandardCharsets.UTF_8)) + // Save the logcat using a coroutine with Dispatchers.IO. + CoroutineScope(Dispatchers.Main).launch { + withContext(Dispatchers.IO) { + // Write the logcat string to the output stream. + outputStream.write(logcatString.toByteArray(StandardCharsets.UTF_8)) - // Close the output stream. - outputStream.close() + // Close the output stream. + outputStream.close() + } + } // Initialize the file name string from the file URI last path segment. var fileNameString = fileUri.lastPathSegment diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt b/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt index c4c52274..0078fcc1 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2022 Soren Stoutner . + * Copyright 2016-2022 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -55,6 +55,11 @@ import com.stoutner.privacybrowser.R import com.stoutner.privacybrowser.BuildConfig import com.stoutner.privacybrowser.asynctasks.SaveAboutVersionImage +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext + import java.io.ByteArrayInputStream import java.io.InputStream import java.lang.Exception @@ -165,11 +170,16 @@ class AboutVersionFragment : Fragment() { // Open an output stream. val outputStream = requireActivity().contentResolver.openOutputStream(fileUri)!! - // Write the about version string to the output stream. - outputStream.write(aboutVersionString.toByteArray(StandardCharsets.UTF_8)) + // Save about version using a coroutine with Dispatchers.IO. + CoroutineScope(Dispatchers.Main).launch { + withContext(Dispatchers.IO) { + // Write the about version string to the output stream. + outputStream.write(aboutVersionString.toByteArray(StandardCharsets.UTF_8)) - // Close the output stream. - outputStream.close() + // Close the output stream. + outputStream.close() + } + } // Initialize the file name string from the file URI last path segment. var fileNameString = fileUri.lastPathSegment @@ -895,4 +905,4 @@ class AboutVersionFragment : Fragment() { // Return the string. return aboutVersionStringBuilder.toString() } -} \ No newline at end of file +}