diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 60f86921..c5d436f3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,8 +6,11 @@
-
+
+
+ handlePermission(getPermissionToRequest()) { granted ->
if (granted) {
ExportPlaylistDialog(this, config.lastExportPath, false) { file ->
getFileOutputStream(file.toFileDirItem(this), true) { outputStream ->
diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/Constants.kt
index 907fc7e1..257f82fd 100644
--- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/Constants.kt
@@ -1,7 +1,10 @@
package com.simplemobiletools.musicplayer.helpers
import android.net.Uri
+import com.simplemobiletools.commons.helpers.PERMISSION_READ_MEDIA_AUDIO
+import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.isQPlus
+import com.simplemobiletools.commons.helpers.isTiramisuPlus
const val PROGRESS = "progress"
const val EDITED_TRACK = "edited_track"
@@ -120,3 +123,5 @@ const val MIME_TYPE_M3U = "audio/x-mpegurl"
const val M3U_HEADER = "#EXTM3U"
const val M3U_ENTRY = "#EXTINF:"
const val M3U_DURATION_SEPARATOR = ","
+
+fun getPermissionToRequest() = if (isTiramisuPlus()) PERMISSION_READ_MEDIA_AUDIO else PERMISSION_WRITE_STORAGE
diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/services/MusicService.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/services/MusicService.kt
index d4cb8c73..d23cd7bb 100644
--- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/services/MusicService.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/services/MusicService.kt
@@ -113,7 +113,7 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
mOreoFocusHandler = OreoAudioFocusHandler(applicationContext)
}
- if (!isQPlus() && !hasPermission(PERMISSION_WRITE_STORAGE)) {
+ if (!isQPlus() && !hasPermission(getPermissionToRequest())) {
EventBus.getDefault().post(Events.NoStoragePermission())
}
}
@@ -130,7 +130,7 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
}
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
- if (!isQPlus() && !hasPermission(PERMISSION_WRITE_STORAGE)) {
+ if (!isQPlus() && !hasPermission(getPermissionToRequest())) {
return START_NOT_STICKY
}