Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Android 34 (#642) #644

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class UploadService : Service() {

if (UploadServiceConfig.isForegroundService && uploadTasksMap.isEmpty()) {
UploadServiceLogger.debug(TAG, NA) { "All tasks completed, stopping foreground execution" }
stopForeground(true)
stopForeground(STOP_FOREGROUND_REMOVE)
shutdownIfThereArentAnyActiveTasks()
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ class UploadService : Service() {

if (UploadServiceConfig.isForegroundService) {
UploadServiceLogger.debug(TAG, NA) { "Stopping foreground execution" }
stopForeground(true)
stopForeground(STOP_FOREGROUND_REMOVE)
}

wakeLock.safeRelease()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.gotev.uploadservice.data

import android.content.Intent
import android.os.Build
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import net.gotev.uploadservice.UploadServiceConfig
Expand All @@ -17,7 +18,11 @@ internal data class BroadcastData @JvmOverloads constructor(
private const val paramName = "broadcastData"

fun fromIntent(intent: Intent): BroadcastData? {
return intent.getParcelableExtra(paramName)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableExtra(paramName, BroadcastData::class.java)
} else {
intent.getParcelableExtra(paramName)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package net.gotev.uploadservice.observer.request

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Context.RECEIVER_NOT_EXPORTED
import android.content.Intent
import android.os.Build
import net.gotev.uploadservice.UploadServiceConfig
import net.gotev.uploadservice.data.BroadcastData
import net.gotev.uploadservice.data.UploadInfo
Expand Down Expand Up @@ -33,7 +35,13 @@ open class BaseRequestObserver(
}

open fun register() {
context.registerReceiver(this, UploadServiceConfig.broadcastStatusIntentFilter)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(
this, UploadServiceConfig.broadcastStatusIntentFilter, RECEIVER_NOT_EXPORTED
)
} else {
context.registerReceiver(this, UploadServiceConfig.broadcastStatusIntentFilter)
}
}

open fun unregister() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package net.gotev.uploadservice.observer.request
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Build
import net.gotev.uploadservice.UploadService
import net.gotev.uploadservice.UploadServiceConfig
import net.gotev.uploadservice.UploadServiceConfig.broadcastNotificationAction
import net.gotev.uploadservice.UploadServiceConfig.broadcastNotificationActionIntentFilter
import net.gotev.uploadservice.extensions.uploadIdToCancel
Expand All @@ -28,7 +30,13 @@ open class NotificationActionsObserver(
}

fun register() {
context.registerReceiver(this, broadcastNotificationActionIntentFilter)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(
this, broadcastNotificationActionIntentFilter, Context.RECEIVER_NOT_EXPORTED
)
} else {
context.registerReceiver(this, broadcastNotificationActionIntentFilter)
}
UploadServiceLogger.debug(NotificationActionsObserver::class.java.simpleName, NA) {
"registered"
}
Expand Down
Loading