Skip to content

Commit

Permalink
feat: set fg service type as per A14 requisite
Browse files Browse the repository at this point in the history
  • Loading branch information
iamlooper committed Nov 30, 2023
1 parent 1c072b0 commit 855745c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

<service
android:name=".service.BootService"
android:launchMode="singleTask" />
android:launchMode="singleTask"
android:foregroundServiceType="shortService" />

<provider
android:name="androidx.core.content.FileProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import java.io.File
import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.app.Notification
import android.content.pm.ServiceInfo

import androidx.preference.PreferenceManager
import androidx.preference.MultiSelectListPreference
import androidx.preference.SwitchPreferenceCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.ServiceCompat

import com.topjohnwu.superuser.Shell

Expand Down Expand Up @@ -42,7 +43,7 @@ class BootService : Service() {
.build()

// Start the foreground service.
startForeground(1, foregroundNotification)
ServiceCompat.startForeground(this, 1, foregroundNotification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE)

// Check if the app has root access.
if (Shell.isAppGrantedRoot() == true) {
Expand Down Expand Up @@ -100,7 +101,7 @@ class BootService : Service() {
}

// Stop the foreground service.
stopForeground(true)
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)

// Stop the service completely.
stopSelf()
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
gradle = "8.3.0-alpha09"
kotlin = "1.9.0"
appcompat = "1.6.0"
core = "1.10.0"
core = "1.12.0"
constraintlayout = "2.1.0"
navigation = "2.7.0"
preference = "1.2.0"
Expand Down

0 comments on commit 855745c

Please sign in to comment.