Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion atox/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
Expand All @@ -19,7 +20,13 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service android:name=".ToxService" android:exported="false"/>
<service android:name=".ToxService"
android:exported="false"
android:foregroundServiceType="specialUse">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="serverless peer-to-peer messaging" />
</service>

<receiver android:name=".BootReceiver" android:enabled="false" android:exported="false">
<intent-filter>
Expand Down
14 changes: 12 additions & 2 deletions atox/src/main/kotlin/ToxService.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2023 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2019-2024 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2021-2022 aTox contributors
//
// SPDX-License-Identifier: GPL-3.0-only
Expand All @@ -10,6 +10,7 @@ import android.app.Notification
import android.app.PendingIntent
import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ServiceInfo
import android.os.Build
import android.util.Log
import androidx.core.app.ActivityCompat
Expand Down Expand Up @@ -126,7 +127,16 @@ class ToxService : LifecycleService() {
}

createNotificationChannel()
startForeground(NOTIFICATION_ID, notificationFor(connectionStatus))

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(
NOTIFICATION_ID,
notificationFor(connectionStatus),
ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE,
)
} else {
startForeground(NOTIFICATION_ID, notificationFor(connectionStatus))
}

lifecycleScope.launch(Dispatchers.Default) {
userRepository.get(tox.publicKey.string())
Expand Down
4 changes: 2 additions & 2 deletions atox/src/main/kotlin/ui/AvatarImageView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class AvatarImageView @JvmOverloads constructor(context: Context, attrs: Attribu
invalidate()
}

override fun onDraw(canvas: Canvas?) {
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
if (canvas == null || !statusIndicatorVisible) return
if (!statusIndicatorVisible) return

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

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
sdk-min = "19"
sdk-target = "33"
sdk-target = "34"

kotlin = "2.0.20"
ksp = "2.0.20-1.0.25"
Expand Down