Added compat methods to check & request full screen intent permission + other required changes for Android 14
This commit is contained in:
parent
a19264a2bd
commit
4e396e990d
6 changed files with 91 additions and 0 deletions
|
@ -54,6 +54,11 @@
|
||||||
<!-- Needed for foreground service
|
<!-- Needed for foreground service
|
||||||
(https://developer.android.com/guide/components/foreground-services) -->
|
(https://developer.android.com/guide/components/foreground-services) -->
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||||
|
<!-- Needed for Android 14
|
||||||
|
https://developer.android.com/about/versions/14/behavior-changes-14#fgs-types -->
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".LinphoneApplication"
|
android:name=".LinphoneApplication"
|
||||||
|
|
|
@ -273,6 +273,24 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
||||||
// Don't check the following the previous permissions are being asked
|
// Don't check the following the previous permissions are being asked
|
||||||
checkTelecomManagerPermissions()
|
checkTelecomManagerPermissions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See https://developer.android.com/about/versions/14/behavior-changes-14#fgs-types
|
||||||
|
if (Version.sdkAboveOrEqual(Version.API34_ANDROID_14_UPSIDE_DOWN_CAKE)) {
|
||||||
|
val fullScreenIntentPermission = Compatibility.hasFullScreenIntentPermission(
|
||||||
|
requireContext()
|
||||||
|
)
|
||||||
|
Log.i(
|
||||||
|
"[Dialer] Android 14 or above detected: full-screen intent permission is ${if (fullScreenIntentPermission) "granted" else "not granted"}"
|
||||||
|
)
|
||||||
|
if (!fullScreenIntentPermission) {
|
||||||
|
(requireActivity() as MainActivity).showSnackBar(
|
||||||
|
R.string.android_14_full_screen_intent_permission_not_granted,
|
||||||
|
R.string.android_14_go_to_full_screen_intent_permission_setting
|
||||||
|
) {
|
||||||
|
Compatibility.requestFullScreenIntentPermission(requireContext())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Version.API26_O_80)
|
@TargetApi(Version.API26_O_80)
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2023 Belledonne Communications SARL.
|
||||||
|
*
|
||||||
|
* This file is part of linphone-android
|
||||||
|
* (see https://www.linphone.org).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.linphone.compatibility
|
||||||
|
|
||||||
|
import android.annotation.TargetApi
|
||||||
|
import android.app.NotificationManager
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.provider.Settings
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
|
||||||
|
@TargetApi(34)
|
||||||
|
class Api34Compatibility {
|
||||||
|
companion object {
|
||||||
|
fun hasFullScreenIntentPermission(context: Context): Boolean {
|
||||||
|
val notificationManager = context.getSystemService(NotificationManager::class.java) as NotificationManager
|
||||||
|
// See https://developer.android.com/reference/android/app/NotificationManager#canUseFullScreenIntent%28%29
|
||||||
|
return notificationManager.canUseFullScreenIntent()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestFullScreenIntentPermission(context: Context) {
|
||||||
|
val intent = Intent()
|
||||||
|
// See https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT
|
||||||
|
intent.action = Settings.ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT
|
||||||
|
intent.data = Uri.parse("package:${context.packageName}")
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||||
|
ContextCompat.startActivity(context, intent, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -462,5 +462,20 @@ class Compatibility {
|
||||||
Api28Compatibility.clearClipboard(clipboard)
|
Api28Compatibility.clearClipboard(clipboard)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasFullScreenIntentPermission(context: Context): Boolean {
|
||||||
|
if (Version.sdkAboveOrEqual(Version.API34_ANDROID_14_UPSIDE_DOWN_CAKE)) {
|
||||||
|
return Api34Compatibility.hasFullScreenIntentPermission(context)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestFullScreenIntentPermission(context: Context): Boolean {
|
||||||
|
if (Version.sdkAboveOrEqual(Version.API34_ANDROID_14_UPSIDE_DOWN_CAKE)) {
|
||||||
|
Api34Compatibility.requestFullScreenIntentPermission(context)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,4 +788,6 @@
|
||||||
<string name="dialog_authentication_required_message">La connexion a échouée car l\'authentification est manquante ou invalide pour le compte\n%s.\n\nVous pouvez fournir le mot de passe à nouveau ou vérifier la configuration de votre compte dans les paramètres.</string>
|
<string name="dialog_authentication_required_message">La connexion a échouée car l\'authentification est manquante ou invalide pour le compte\n%s.\n\nVous pouvez fournir le mot de passe à nouveau ou vérifier la configuration de votre compte dans les paramètres.</string>
|
||||||
<string name="dialog_authentication_required_change_password_label">Confirmer</string>
|
<string name="dialog_authentication_required_change_password_label">Confirmer</string>
|
||||||
<string name="content_description_emoji_picker">Change la visibilité du selectionneur d\'emoji</string>
|
<string name="content_description_emoji_picker">Change la visibilité du selectionneur d\'emoji</string>
|
||||||
|
<string name="android_14_full_screen_intent_permission_not_granted">Permission requise pour afficher les appels entrant non accordée</string>
|
||||||
|
<string name="android_14_go_to_full_screen_intent_permission_setting">Afficher</string>
|
||||||
</resources>
|
</resources>
|
|
@ -777,6 +777,9 @@
|
||||||
<string name="dialog_authentication_required_message">Connection failed because authentication is missing or invalid for account \n%s.\n\nYou can provide password again, or check your account configuration in the settings.</string>
|
<string name="dialog_authentication_required_message">Connection failed because authentication is missing or invalid for account \n%s.\n\nYou can provide password again, or check your account configuration in the settings.</string>
|
||||||
<string name="dialog_authentication_required_change_password_label">Confirm</string>
|
<string name="dialog_authentication_required_change_password_label">Confirm</string>
|
||||||
|
|
||||||
|
<string name="android_14_full_screen_intent_permission_not_granted">Permission required to show incoming calls not granted yet</string>
|
||||||
|
<string name="android_14_go_to_full_screen_intent_permission_setting">Show</string>
|
||||||
|
|
||||||
<!-- Content description -->
|
<!-- Content description -->
|
||||||
<string name="content_description_add_sip_address_field">Add a SIP address field</string>
|
<string name="content_description_add_sip_address_field">Add a SIP address field</string>
|
||||||
<string name="content_description_add_phone_number_field">Add a phone number field</string>
|
<string name="content_description_add_phone_number_field">Add a phone number field</string>
|
||||||
|
|
Loading…
Reference in a new issue