Merge "Fix media scan NPE"
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index fbbcb0a..7768a61 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -958,7 +958,9 @@
// If the rowId of the inserted file is needed, it gets inserted immediately,
// bypassing the bulk inserter.
if (inserter == null || needToSetSettings) {
- inserter.flushAll();
+ if (inserter != null) {
+ inserter.flushAll();
+ }
result = mMediaProvider.insert(tableUri, values);
} else if (entry.mFormat == MtpConstants.FORMAT_ASSOCIATION) {
inserter.insertwithPriority(tableUri, values);