Skip to content

Commit 5530600

Browse files
committed
Target Android 14
1 parent 67b0d7f commit 5530600

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

atox/src/main/AndroidManifest.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
android:installLocation="auto">
44
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
5+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/>
56
<uses-permission android:name="android.permission.INTERNET"/>
67
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
78
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
@@ -19,7 +20,13 @@
1920
android:roundIcon="@mipmap/ic_launcher_round"
2021
android:supportsRtl="true"
2122
android:theme="@style/AppTheme">
22-
<service android:name=".ToxService" android:exported="false"/>
23+
<service android:name=".ToxService"
24+
android:exported="false"
25+
android:foregroundServiceType="specialUse">
26+
<property
27+
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
28+
android:value="serverless peer-to-peer messaging" />
29+
</service>
2330

2431
<receiver android:name=".BootReceiver" android:enabled="false" android:exported="false">
2532
<intent-filter>

atox/src/main/kotlin/ToxService.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2019-2023 Robin Lindén <[email protected]>
1+
// SPDX-FileCopyrightText: 2019-2024 Robin Lindén <[email protected]>
22
// SPDX-FileCopyrightText: 2021-2022 aTox contributors
33
//
44
// SPDX-License-Identifier: GPL-3.0-only
@@ -10,6 +10,7 @@ import android.app.Notification
1010
import android.app.PendingIntent
1111
import android.content.Intent
1212
import android.content.pm.PackageManager
13+
import android.content.pm.ServiceInfo
1314
import android.os.Build
1415
import android.util.Log
1516
import androidx.core.app.ActivityCompat
@@ -126,7 +127,16 @@ class ToxService : LifecycleService() {
126127
}
127128

128129
createNotificationChannel()
129-
startForeground(NOTIFICATION_ID, notificationFor(connectionStatus))
130+
131+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
132+
startForeground(
133+
NOTIFICATION_ID,
134+
notificationFor(connectionStatus),
135+
ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE,
136+
)
137+
} else {
138+
startForeground(NOTIFICATION_ID, notificationFor(connectionStatus))
139+
}
130140

131141
lifecycleScope.launch(Dispatchers.Default) {
132142
userRepository.get(tox.publicKey.string())

atox/src/main/kotlin/ui/AvatarImageView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class AvatarImageView @JvmOverloads constructor(context: Context, attrs: Attribu
7474
invalidate()
7575
}
7676

77-
override fun onDraw(canvas: Canvas?) {
77+
override fun onDraw(canvas: Canvas) {
7878
super.onDraw(canvas)
79-
if (canvas == null || !statusIndicatorVisible) return
79+
if (!statusIndicatorVisible) return
8080

8181
val size = min(width, height).toFloat()
8282

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
sdk-min = "19"
3-
sdk-target = "33"
3+
sdk-target = "34"
44

55
kotlin = "1.9.25"
66
ksp = "1.9.25-1.0.20"

0 commit comments

Comments
 (0)