-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: MediaStore scan crash on OxygenOS 11 (#171)
- Loading branch information
1 parent
b3d5396
commit 0221cc8
Showing
4 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/src/main/java/deltazero/amarok/utils/MediaStoreHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package deltazero.amarok.utils; | ||
|
||
import android.content.Context; | ||
import android.media.MediaScannerConnection; | ||
import android.util.Log; | ||
|
||
import java.util.Set; | ||
|
||
public class MediaStoreHelper { | ||
private static final String TAG = "MediaStoreHelper"; | ||
|
||
public static void scan(Context context, Set<String> dirs) { | ||
try { | ||
MediaScannerConnection.scanFile(context, dirs.toArray(new String[0]), null, | ||
(ignore, ignore2) -> Log.d(TAG, "MediaStore cache refreshed")); | ||
} catch (Exception e) { | ||
// MediaScannerConnection.scanFile may throw ArrayIndexOutOfBoundsException on OxygenOS 11 | ||
// See https://github.com/deltazefiro/Amarok-Hider/issues/171#issuecomment-2225104851 | ||
Log.w(TAG, "Error while rescanning media store", e); | ||
} | ||
} | ||
} |