I'm facing a weird crash in the Samsung device only.
See the stacktrace below,
Fatal Exception: com.pilabs.musicplayer.tageditor.TagEditFailedException: Tag edit failed : Changing volume from /storage/3964-3431/Music/Bujji-MassTamilan.io.mp3 to /storage/emulated/0/Music/.pending-1608532169-Bujji-MassTamilan.io.mp3 not allowed
at com.pilabs.musicplayer.tageditor.PiTagEditor.handleException(PiTagEditor.java:643)
at com.pilabs.musicplayer.tageditor.PiTagEditor.editTrackTagInfoImpl(PiTagEditor.java:217)
at com.pilabs.musicplayer.tageditor.PiTagEditor.access$setUiCallback$p(PiTagEditor.java:37)
at com.pilabs.musicplayer.tageditor.PiTagEditor$editTrackTagInfo$1.invokeSuspend(PiTagEditor.java:79)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:238)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$createdWorkers(CoroutineScheduler.java:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.java:742)
Where TagEditFailedException
is my own Written Exception. Actual exception being,
java.lang.IllegalArgumentException: Changing volume from /storage/3964-3431/Music/Bujji-MassTamilan.io.mp3 to /storage/emulated/0/Music/.pending-1608532169-Bujji-MassTamilan.io.mp3 not allowed
More than anything, look for
Changing volume from /storage/3964-3431/Music/Bujji-MassTamilan.io.mp3 to /storage/emulated/0/Music/.pending-1608532169-Bujji-MassTamilan.io.mp3 not allowed
I debugged the code and found that the app is crashing when updating IS_PENDING before updating other metadata.
private fun updateNameChangesInAndroidDb(application: Application, editTrackTagInfo: EditTrackTagInfo) {
val uri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
editTrackTagInfo.trackId.toLong())
val contentValues = ContentValues()
if (hasQ()) {
contentValues.put(MediaStore.Audio.Media.IS_PENDING, 1)
application.contentResolver.update(uri, contentValues, null, null)
}
contentValues.clear()
if (hasQ())
contentValues.put(MediaStore.Audio.Media.IS_PENDING, 0)
with(editTrackTagInfo) {
title?.let { it -> contentValues.put(MediaStore.Audio.Media.TITLE, it) }
album?.let { it -> contentValues.put(MediaStore.Audio.Media.ALBUM, it) }
artist?.let { it -> contentValues.put(MediaStore.Audio.Media.ARTIST, it) }
}
val rowsUpdated = application.contentResolver.update(uri, contentValues,
null, null)
app crashes at
application.contentResolver.update(uri, contentValues, null, null)
while updating IS_PENDING to 1 in
if (hasQ()) {
contentValues.put(MediaStore.Audio.Media.IS_PENDING, 1)
application.contentResolver.update(uri, contentValues, null, null)
}
I don't understand why updating is_pending would change the volume from SD_Card to internal storage (/storage/emulated/0...).
- App crashes only on Android 11 devices. That too on Samsung device only. That too when the track I'm trying to edit is from SD-CARD.
- I have tried with Android 11 pixel devices and it works fine.
- The track which I'm trying to edit is in SdCard at location
/storage/3964-3431/Music/Bujji-MassTamilan.mp3
- I don't understand why while updating IS_PENDING to 1 in samsung android 11 device, root location of media is changing to internal storage
/storage/emulated/0/Music/...
Summary - App crashes only in Android 11 Samsung device when media-file is from SD-Card.