Dan Ballard pushed to branch tor-browser-153.1.0esr-16.0-1 at The Tor Project / Applications / Tor Browser Commits: 9857f694 by clairehurst at 2026-08-13T15:38:37-06:00 fixup! TB 34378: [android] Port external helper app prompting TB 45049, 41758, 45127: Only open pdf intents from within the app # Conflicts: # mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/DefaultDownloadFileUtils.kt - - - - - 2 changed files: - mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/DefaultDownloadFileUtils.kt - mobile/android/fenix/app/src/main/AndroidManifest.xml Changes: ===================================== mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/DefaultDownloadFileUtils.kt ===================================== @@ -28,10 +28,11 @@ import mozilla.components.support.utils.DownloadUtils.findFileInMediaStore import mozilla.components.support.utils.DownloadUtils.isDefaultDownloadDirectory import mozilla.components.support.utils.DownloadUtils.sanitizeMimeType import mozilla.components.support.utils.DownloadUtils.truncateFileName -import mozilla.components.support.utils.TorUtils import java.io.File import java.io.FileNotFoundException +import android.content.pm.PackageManager + /** * The default implementation of [DownloadFileUtils]. * @@ -62,6 +63,8 @@ class DefaultDownloadFileUtils( private const val SCHEME_CONTENT = "content://" private const val SCHEME_FILE = "file" private const val FILE_PROVIDER_EXTENSION = ".feature.downloads.fileprovider" + + const val EXTRA_IS_PDF = "mozilla.components.feature.downloads.extras.IS_PDF" } override val currentDownloadLocation: String get() = downloadLocation() @@ -103,7 +106,15 @@ class DefaultDownloadFileUtils( ) return try { - TorUtils.startActivityPrompt(context, newIntent) + if (newIntent.getBooleanExtra( + EXTRA_IS_PDF, + false, + ) || newIntent.type == INTENT_TYPE_PDF + ) { + context.startActivity(newIntent) + } else { + TorUtils.startActivityPrompt(context, newIntent) + } true } catch (_: ActivityNotFoundException) { false @@ -118,13 +129,23 @@ class DefaultDownloadFileUtils( val shareableUri = findShareableDownloadFileUri(fileName, directoryPath) return if (shareableUri != null) { - Intent(Intent.ACTION_VIEW).apply { + val newIntent = Intent(Intent.ACTION_VIEW).apply { setDataAndType( shareableUri, getSafeContentType(fileName, downloadContentType, shareableUri), ) flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION } + + val isPdf: Boolean = (downloadContentType == "application/pdf" || + fileName?.let { File(it).extension } == "pdf") + + if (isPdf) { + newIntent.setPackage(context.packageName) // Set it to open in TBA + newIntent.putExtra(EXTRA_IS_PDF, true) + } + + newIntent } else { // Fallback to opening the downloads manager if the file URI could not be determined. Intent(DownloadManager.ACTION_VIEW_DOWNLOADS).apply { ===================================== mobile/android/fenix/app/src/main/AndroidManifest.xml ===================================== @@ -557,8 +557,9 @@ android:theme="@style/Theme.Transparent" android:relinquishTaskIdentity="true" android:taskAffinity="" - android:exported="true" - android:excludeFromRecents="true" > + android:exported="false" + android:excludeFromRecents="true" + tools:ignore="AppLinkUrlError"> <intent-filter> @@ -586,7 +587,7 @@ <data android:scheme="https" /> </intent-filter> - <intent-filter> + <intent-filter tools:ignore="AppLinkUrlError"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/9857f694... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/9857f694... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help
participants (1)
-
Dan Ballard (@dan)