diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 71ccf5b234..ef71c10dd5 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -635,6 +635,8 @@ ${app_name} needs permission to access your microphone to perform audio calls. ${app_name} needs permission to access your camera and your microphone to perform video calls.\n\nPlease allow access on the next pop-ups to be able to make the call. + + ${app_name} needs permission to display notifications. Notifications can display your messages, your invitations, etc.\n\nPlease allow access on the next pop-ups to be able to view notification. To scan a QR code, you need to allow camera access. Allow permission to access your contacts. @@ -854,7 +856,9 @@ System Settings. Notifications are enabled in the system settings. Notifications are disabled in the system settings.\nPlease check system settings. + ${app_name} needs the permission to show notifications.\nPlease grant the permission. Open Settings + Grant Permission Account Settings. Notifications are enabled for your account. diff --git a/tools/adb/notification.sh b/tools/adb/notification.sh new file mode 100755 index 0000000000..3c3c76c787 --- /dev/null +++ b/tools/adb/notification.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +## From https://developer.android.com/develop/ui/views/notifications/notification-permission#test + +PACKAGE_NAME=im.vector.app.debug + +# App is newly installed on a device that runs Android 13 or higher: + +adb shell pm revoke ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS +adb shell pm clear-permission-flags ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS user-set +adb shell pm clear-permission-flags ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS user-fixed + +# The user keeps notifications enabled when the app is installed on a device that runs 12L or lower, +# then the device upgrades to Android 13 or higher: + +# adb shell pm grant ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS +# adb shell pm set-permission-flags ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS user-set +# adb shell pm clear-permission-flags ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS user-fixed + +# The user manually disables notifications when the app is installed on a device that runs 12L or lower, +# then the device upgrades to Android 13 or higher: + +# adb shell pm revoke ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS +# adb shell pm set-permission-flags ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS user-set +# adb shell pm clear-permission-flags ${PACKAGE_NAME} android.permission.POST_NOTIFICATIONS user-fixed diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt index a9be5512e4..2b1b66e672 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt @@ -22,6 +22,7 @@ import android.os.Build import android.widget.Toast import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat +import androidx.core.view.isVisible import dagger.hilt.android.AndroidEntryPoint import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.utils.checkPermissions @@ -46,7 +47,15 @@ class DebugPermissionActivity : VectorBaseActivity { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + listOf(Manifest.permission.POST_NOTIFICATIONS) + } else { + emptyList() + } + } private var lastPermissions = emptyList() @@ -77,6 +86,14 @@ class DebugPermissionActivity : VectorBaseActivity= Build.VERSION_CODES.TIRAMISU) { + views.notification.setOnClickListener { + lastPermissions = listOf(Manifest.permission.POST_NOTIFICATIONS) + checkPerm() + } + } else { + views.notification.isVisible = false + } } private fun checkPerm() { diff --git a/vector-app/src/debug/res/layout/activity_debug_permission.xml b/vector-app/src/debug/res/layout/activity_debug_permission.xml index 6340d8faa7..0f1fef0b9b 100644 --- a/vector-app/src/debug/res/layout/activity_debug_permission.xml +++ b/vector-app/src/debug/res/layout/activity_debug_permission.xml @@ -30,43 +30,43 @@ android:id="@+id/camera" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="CAMERA" - android:textAllCaps="false" /> + android:text="CAMERA" />