Merge "make manual exposure compensation settings work acrss different devices bug: 13967706" into ub-camera-everglades
diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml
index 8932a55..8d9d062 100644
--- a/res/values-fi/strings.xml
+++ b/res/values-fi/strings.xml
@@ -352,6 +352,5 @@
     <string name="setting_summary_x_megapixels" msgid="6533463462760866830">"%1$s megapikseliä"</string>
     <string name="cling_text_for_refocus_editor_button" msgid="86205552045250053">"Muokkaa linssin sumennusta käytt. kuvaa klikkaamalla tätä."</string>
     <string name="pref_category_advanced" msgid="5921085080077574872">"Lisäasetukset"</string>
-    <!-- no translation found for pref_camera_exposure_compensation (4143245817259719147) -->
-    <skip />
+    <string name="pref_camera_exposure_compensation" msgid="4143245817259719147">"Manuaalinen valotus"</string>
 </resources>
diff --git a/res/values-ka-rGE/strings.xml b/res/values-ka-rGE/strings.xml
index 2a804a4..0cef96c 100644
--- a/res/values-ka-rGE/strings.xml
+++ b/res/values-ka-rGE/strings.xml
@@ -352,6 +352,5 @@
     <string name="setting_summary_x_megapixels" msgid="6533463462760866830">"%1$s მეგაპიქსელი"</string>
     <string name="cling_text_for_refocus_editor_button" msgid="86205552045250053">"დააწკაპუნეთ აქ დაბინდული ობიექტივის სურათის შესაცვლელად."</string>
     <string name="pref_category_advanced" msgid="5921085080077574872">"გაფართოებული"</string>
-    <!-- no translation found for pref_camera_exposure_compensation (4143245817259719147) -->
-    <skip />
+    <string name="pref_camera_exposure_compensation" msgid="4143245817259719147">"ექსპოზიცია ხელით"</string>
 </resources>
diff --git a/res/values-ms-rMY/strings.xml b/res/values-ms-rMY/strings.xml
index e890b91..165d8bd 100644
--- a/res/values-ms-rMY/strings.xml
+++ b/res/values-ms-rMY/strings.xml
@@ -352,6 +352,5 @@
     <string name="setting_summary_x_megapixels" msgid="6533463462760866830">"%1$s megapiksel"</string>
     <string name="cling_text_for_refocus_editor_button" msgid="86205552045250053">"Klik di sini untuk mengedit imej kabur lensa."</string>
     <string name="pref_category_advanced" msgid="5921085080077574872">"Lanjutan"</string>
-    <!-- no translation found for pref_camera_exposure_compensation (4143245817259719147) -->
-    <skip />
+    <string name="pref_camera_exposure_compensation" msgid="4143245817259719147">"Dedahan manual"</string>
 </resources>
diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml
index 9642736..d9645b6 100644
--- a/res/values-ro/strings.xml
+++ b/res/values-ro/strings.xml
@@ -352,6 +352,5 @@
     <string name="setting_summary_x_megapixels" msgid="6533463462760866830">"%1$s megapixeli"</string>
     <string name="cling_text_for_refocus_editor_button" msgid="86205552045250053">"Dați clic aici pentru a edita imaginea cu fundal încețoșat."</string>
     <string name="pref_category_advanced" msgid="5921085080077574872">"Avansat"</string>
-    <!-- no translation found for pref_camera_exposure_compensation (4143245817259719147) -->
-    <skip />
+    <string name="pref_camera_exposure_compensation" msgid="4143245817259719147">"Expunere manuală"</string>
 </resources>
diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml
index 2ffba4a..fcea855 100644
--- a/res/values-tr/strings.xml
+++ b/res/values-tr/strings.xml
@@ -323,8 +323,8 @@
     <string name="torch_off_desc" msgid="8304675202998742618">"Işık kapalı"</string>
     <string name="camera_id_back_desc" msgid="3566327490758890635">"Arka kamera"</string>
     <string name="camera_id_front_desc" msgid="7497517948130254220">"Ön kamera"</string>
-    <string name="grid_lines_off_desc" msgid="2022385817190451353">"Izgara çizgileri kapalı"</string>
-    <string name="grid_lines_on_desc" msgid="4601540461914364817">"Izgara çizgileri açık"</string>
+    <string name="grid_lines_off_desc" msgid="2022385817190451353">"Kılavuz çizgileri kapalı"</string>
+    <string name="grid_lines_on_desc" msgid="4601540461914364817">"Kılavuz çizgileri açık"</string>
     <string name="more_options_desc" msgid="4628738800610478353">"Diğer Seçenekler"</string>
     <string name="cancel_button_description" msgid="3801167024006905033">"İptal"</string>
     <string name="done_button_description" msgid="1334963435441544592">"Bitti"</string>
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index a630ecc..a9399d7 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -33,6 +33,7 @@
 import android.location.Location;
 import android.media.CameraProfile;
 import android.net.Uri;
+import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
@@ -842,8 +843,14 @@
                 }
             }
 
-            // Send the taken photo to remote shutter listeners, if any are registered.
-            getServices().getRemoteShutterListener().onPictureTaken(jpegData);
+            // Send the taken photo to remote shutter listeners, if any are
+            // registered.
+            AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
+                @Override
+                public void run() {
+                    getServices().getRemoteShutterListener().onPictureTaken(jpegData);
+                }
+            });
 
             // Check this in advance of each shot so we don't add to shutter
             // latency. It's true that someone else could write to the SD card
@@ -948,6 +955,7 @@
             return false;
         }
         mCaptureStartTime = System.currentTimeMillis();
+
         mPostViewPictureCallbackTime = 0;
         mJpegImageData = null;
 
diff --git a/src/com/android/camera/data/CameraDataAdapter.java b/src/com/android/camera/data/CameraDataAdapter.java
index a689d27..b9f6c44 100644
--- a/src/com/android/camera/data/CameraDataAdapter.java
+++ b/src/com/android/camera/data/CameraDataAdapter.java
@@ -264,7 +264,6 @@
         for (; pos < mImages.size()
                 && comp.compare(data, mImages.get(pos)) > 0; pos++);
         mImages.add(pos, data);
-        updateMetadata(pos);
         if (mListener != null) {
             mListener.onDataInserted(pos, data);
         }
@@ -330,9 +329,12 @@
          */
         @Override
         protected List<LocalData> doInBackground(ContentResolver... contentResolvers) {
-            final ContentResolver cr = contentResolvers[0];
-            return LocalMediaData.PhotoData.query(cr, LocalMediaData.PhotoData.CONTENT_URI,
-                    mMinPhotoId);
+            if (mMinPhotoId != LocalMediaData.QUERY_ALL_MEDIA_ID) {
+                final ContentResolver cr = contentResolvers[0];
+                return LocalMediaData.PhotoData.query(cr, LocalMediaData.PhotoData.CONTENT_URI,
+                        mMinPhotoId);
+            }
+            return new ArrayList<LocalData>(0);
         }
 
         @Override
@@ -419,6 +421,9 @@
             if (mDoneCallback != null) {
                 mDoneCallback.onCallback(null);
             }
+            // Now check for any photos added since this task was kicked off
+            LoadNewPhotosTask ltask = new LoadNewPhotosTask(mLastPhotoId);
+            ltask.execute(mContext.getContentResolver());
         }
     }
 
diff --git a/src/com/android/camera/session/PlaceholderManager.java b/src/com/android/camera/session/PlaceholderManager.java
index 7403c7f..6bd906e 100644
--- a/src/com/android/camera/session/PlaceholderManager.java
+++ b/src/com/android/camera/session/PlaceholderManager.java
@@ -140,7 +140,9 @@
                 new String[] {
                         MediaStore.Images.Media.DATE_TAKEN, MediaStore.Images.Media.DISPLAY_NAME,
                 }, null, null, null);
-        if (cursor == null) {
+        // The count could be 0 if the original media item was deleted before
+        // the session was created.
+        if (cursor == null || cursor.getCount() == 0) {
             return null;
         }
         int dateIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_TAKEN);
diff --git a/src/com/android/camera/settings/SettingsUtil.java b/src/com/android/camera/settings/SettingsUtil.java
index 93613a1..c913190 100644
--- a/src/com/android/camera/settings/SettingsUtil.java
+++ b/src/com/android/camera/settings/SettingsUtil.java
@@ -294,9 +294,9 @@
         // getNextSupportedQuality will throw an exception.
         // If only one quality is supported, then all three selected qualities
         // will be the same.
-        int largeIndex = getNextSupportedVideoQualityIndex(cameraId, 0);
-        int mediumIndex = getNextSupportedVideoQualityIndex(cameraId, largeIndex + 1);
-        int smallIndex = getNextSupportedVideoQualityIndex(cameraId, mediumIndex + 1);
+        int largeIndex = getNextSupportedVideoQualityIndex(cameraId, -1);
+        int mediumIndex = getNextSupportedVideoQualityIndex(cameraId, largeIndex);
+        int smallIndex = getNextSupportedVideoQualityIndex(cameraId, mediumIndex);
 
         SelectedVideoQualities selectedQualities = new SelectedVideoQualities();
         selectedQualities.large = sVideoQualities[largeIndex];
@@ -311,28 +311,23 @@
      * quality.
      */
     private static int getNextSupportedVideoQualityIndex(int cameraId, int start) {
-        int i = start;
+        int i = start + 1;
         for (; i < sVideoQualities.length; ++i) {
             if (CamcorderProfile.hasProfile(cameraId, sVideoQualities[i])) {
-                break;
+              // We found a new supported quality.
+              return i;
             }
         }
 
-        // Were we not able to find a supported quality?
-        if (i >= sVideoQualities.length) {
-            if (start == 0) {
-                // This means we couldn't find any supported quality.
-                throw new IllegalArgumentException("Could not find supported video qualities.");
-            } else {
-                // We get here if start is larger than zero then we found a
-                // larger size already previously. In this edge case, just
-                // return the same index as the previous size.
-                return start;
-            }
+        // Failed to find another supported quality.
+        if (start < 0 || start >= sVideoQualities.length) {
+          // This means we couldn't find any supported quality.
+          throw new IllegalArgumentException("Could not find supported video qualities.");
         }
 
-        // We found a new supported quality.
-        return i;
+        // We previously found a larger supported size. In this edge case, just
+        // return the same index as the previous size.
+        return start;
     }
 
     /**