From c8ca7422e398e678473a62eac479ab66c93a2e2f Mon Sep 17 00:00:00 2001 From: yostyle Date: Mon, 11 Dec 2023 16:30:18 +0100 Subject: [PATCH] Disable APK install --- .../src/main/res/values-fr/strings_tchap.xml | 1 + .../src/main/res/values/strings_tchap.xml | 1 + .../features/home/room/detail/TimelineFragment.kt | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/library/ui-strings/src/main/res/values-fr/strings_tchap.xml b/library/ui-strings/src/main/res/values-fr/strings_tchap.xml index 91736c0d7c..e74e3f006f 100644 --- a/library/ui-strings/src/main/res/values-fr/strings_tchap.xml +++ b/library/ui-strings/src/main/res/values-fr/strings_tchap.xml @@ -50,6 +50,7 @@ Le document (%s) a été filtré par la politique de sécurité Le fichier est infecté, impossible de le télécharger. + Pour des raisons de sécurité l’installation d’application à partir de ${app_name} n’est pas autorisée. Convertir en salon privé (irréversible) diff --git a/library/ui-strings/src/main/res/values/strings_tchap.xml b/library/ui-strings/src/main/res/values/strings_tchap.xml index 9aabed5a49..c3abf1324e 100644 --- a/library/ui-strings/src/main/res/values/strings_tchap.xml +++ b/library/ui-strings/src/main/res/values/strings_tchap.xml @@ -50,6 +50,7 @@ The file (%s) has been blocked We have detected that this file is infected, so it cannot be downloaded. + For security reasons, installing applications from ${app_name} is not allowed. Convert to private room (irreversible) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index 3926766263..708a2930f7 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -628,13 +628,23 @@ class TimelineFragment : } private fun startOpenFileIntent(action: RoomDetailViewEvents.OpenFile) { - if (action.mimeType == MimeTypes.Apk) { - installApk(action) + // Tchap: Remove the ability to install an app from Tchap (https://github.com/tchapgouv/tchap-android/issues/832) + if (action.mimeType in listOf(MimeTypes.Apk, "application/x-authorware-bin")) { + showApkAlert() } else { openFile(action) } } + private fun showApkAlert() { + MaterialAlertDialogBuilder(requireContext()) + .setTitle(getString(R.string.dialog_title_warning)) + .setMessage(getString(R.string.tchap_scan_media_warning_apk)) + .setCancelable(false) + .setPositiveButton(R.string.ok, null) + .show() + } + private fun openFile(action: RoomDetailViewEvents.OpenFile) { val intent = Intent(Intent.ACTION_VIEW).apply { setDataAndTypeAndNormalize(action.uri, action.mimeType)