request the new READ_MEDIA_AUDIO permission on Android 13+
This commit is contained in:
parent
0f605be6d9
commit
78f98ba92d
5 changed files with 13 additions and 5 deletions
|
@ -6,8 +6,11 @@
|
|||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.USE_FINGERPRINT"
|
||||
|
|
|
@ -67,7 +67,7 @@ class MainActivity : SimpleActivity() {
|
|||
storeStateVariables()
|
||||
setupTabs()
|
||||
|
||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
||||
handlePermission(getPermissionToRequest()) {
|
||||
if (it) {
|
||||
initActivity()
|
||||
} else {
|
||||
|
|
|
@ -366,7 +366,7 @@ class TracksActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
handlePermission(PERMISSION_WRITE_STORAGE) { granted ->
|
||||
handlePermission(getPermissionToRequest()) { granted ->
|
||||
if (granted) {
|
||||
ExportPlaylistDialog(this, config.lastExportPath, false) { file ->
|
||||
getFileOutputStream(file.toFileDirItem(this), true) { outputStream ->
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue