Renamed the service to 'ChatAndCallMessagingService' to respect that the
service handles chat messages and calls.
Signed-off-by: Tim Krüger <t@timkrueger.me>
Request the 'BLUETOOTH_CONNECT' permissions if not already granted.
If the permission is be granted in this request, the
'MagicBluetoothManger' will be started.
See: #2132
Signed-off-by: Tim Krüger <t@timkrueger.me>
This change is needed to make the 'MagicBluetoothManager' startable
after the from Android SDK 31 introduced BLUETOOTH_CONNECT is granted by
the user.
Before this change the 'MagicBluetoothManager' was only started in
'MagicAudioManager#start'. Now the new method
'MagicAudioManager#startBluetoothManager' can be used to start the
'MagicBluetoothManager'.
This change is also a preperation to fix#1309 and #2114.
See: #2132, #1309, #2124
Signed-off-by: Tim Krüger <t@timkrueger.me>
Refactored method 'hasPermission' to 'hasNoBluetoothPermission'. The new method
respect the in SKD 31 introduced permission BLUETOOTH_CONNECT. For older SDK
versions the permission BLUETOOTH will be used.
Additionaly make methods private which need bluetooth permissions and only
called locally. For public methods which need bluetooth permissions the method
'hasNoBluetoothPermission' is called to check them.
Also add suppress lint annotation for 'MissingPermission'.
From SDK 30 to SDK 31 the bluetooth related permissions changed and it
is suggested to add the attribute 'android:maxSdkVersion="30"' to the
legacy BLUETOOTH permission in the 'AndroidManifest.xml' [1]:
> For your legacy Bluetooth-related permission declarations, set
> android:maxSdkVersion to 30. This app compatibility step helps the system
> grant your app only the Bluetooth permissions that it needs when installed
> on devices that run Android 12 or higher.
This is explicitly not done here!
During runtime (on Android 12) while starting the 'MagicBluetoothManger' the
following part in 'android.bluetooth.BluetootHeadset' constructor will be
executed and results in the previous exception:
// Preserve legacy compatibility where apps were depending on
// registerStateChangeCallback() performing a permissions check which
// has been relaxed in modern platform versions
if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.R
&& context.checkSelfPermission(android.Manifest.permission.BLUETOOTH)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Need BLUETOOTH permission");
}
In the 'build.gradle' the 'targetSdkVersion 30' and 'compileSdkVersion 31' is
configured. Because the 'MagicBluetoothManager' checks for the 'targetSdkVersion'
instead of 'Build.VERSION.SDK_INT' also on a Android 12 (SDK 31) the 'BLUETOOTH'
permission is needed.
So the solution is to don't set `android:maxSdkVersion="30"' for the BLUETOOTH
permission and request the BLUETOOTH_CONNECT permission.
Resolves: #2132
See:
[1] https://web.archive.org/web/20220416121005/https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android12-or-higher
Signed-off-by: Tim Krüger <t@timkrueger.me>
when the user status app on server is restricted to only some groups, the capabilities for users that are excluded still contains the "user_status" capability.
For the android talk app, this caused that the conversations were not shown.
With this fix, the conversations will be loaded also if the "user_status" is mistakenly set. Additionally, the option to set the status will be hidden.
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>