From f0cedcf8a4a3f964836084df8b10daac829a3439 Mon Sep 17 00:00:00 2001 From: 13574 <1357496606@qq.com> Date: Sun, 10 Sep 2023 10:47:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=20A?= =?UTF-8?q?ndroid=208/8.1=20=E5=A4=8D=E5=88=B6=E5=9B=BE=E7=89=87=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 8 +++++- .../com/lifegpc/ehf/util/ClipboardUtils.kt | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 2f46f6b..950c85b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,12 @@ - + + + "gif" else -> throw IllegalArgumentException("$mimeType is not supported") } + + /** + * 在 Android 8/8.1系统上,手动授予所有app读取uri权限 + * @param uri + * @see chromium 中的 grantUriPermission + */ + private fun grantUriPermissionWhenNeed(uri: Uri) { + if (Build.VERSION.SDK_INT !in arrayOf(Build.VERSION_CODES.O, Build.VERSION_CODES.O_MR1)) { + return + } + + @Suppress("DEPRECATION") + MyApplication.applicationContext.packageManager.getInstalledPackages(0).forEach { + MyApplication.applicationContext.grantUriPermission( + it.packageName, + uri, + Intent.FLAG_GRANT_READ_URI_PERMISSION + ) + } + + } } \ No newline at end of file