Merge "Fixing the CursorWindow error log for cloud albums." into udc-mainline-prod
diff --git a/src/com/android/providers/media/photopicker/PickerDataLayer.java b/src/com/android/providers/media/photopicker/PickerDataLayer.java
index 759602b..575f950 100644
--- a/src/com/android/providers/media/photopicker/PickerDataLayer.java
+++ b/src/com/android/providers/media/photopicker/PickerDataLayer.java
@@ -579,6 +579,7 @@
 
         @NonNull static final Map<String, Integer> COLUMN_NAME_TO_INDEX_MAP;
         static final int AUTHORITY_COLUMN_INDEX;
+
         static {
             final Map<String, Integer> map = new HashMap<>();
             for (int columnIndex = 0; columnIndex < ALL_PROJECTION.length; columnIndex++) {
@@ -663,6 +664,23 @@
             // is stored in the cursor.
             return mAuthority;
         }
+
+        @Override
+        public int getType(int columnIndex) {
+            // 1. Get value from the underlying cursor.
+            final int cursorColumnIndex = mColumnIndexToCursorColumnIndexArray[columnIndex];
+            final int cursorValue = cursorColumnIndex != -1
+                    ? getWrappedCursor().getType(cursorColumnIndex) : Cursor.FIELD_TYPE_NULL;
+
+            // 2a. If this is NOT the AUTHORITY column: just return the value.
+            if (columnIndex != AUTHORITY_COLUMN_INDEX) {
+                return cursorValue;
+            }
+
+            // 2b. If this IS the AUTHORITY column: "override" whatever value (which may be 0)
+            // is stored in the cursor.
+            return Cursor.FIELD_TYPE_STRING;
+        }
     }
 
     /**