Bug 1511839 - Return the generated file if the camera result has "inline-data" action; r=VladBaicu a=jcristau
authorPetru Lingurar <petru.lingurar@softvision.ro>
Thu, 23 May 2019 12:17:34 +0000
changeset 533397 5234a4220bae688d165edcd04567936f9d8ee823
parent 533396 22734638bdcb7d90cdcce00aacaffad82cb8e3b7
child 533398 fa195c94dc1082186356e97094feb62e4e1f5b01
push id11308
push usernbeleuzu@mozilla.com
push dateFri, 24 May 2019 19:41:29 +0000
treeherdermozilla-beta@298f7d8bb0c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersVladBaicu, jcristau
bugs1511839
milestone68.0
Bug 1511839 - Return the generated file if the camera result has "inline-data" action; r=VladBaicu a=jcristau Handle the case when Camera would actually save a new photo but would return just a thumbnail and not the full image https://github.com/aosp-mirror/platform_packages_apps_camera/blob/33c59af04ab44eff0e3806f140d472252300646a/src/com/android/camera/PhotoModule.java#L1345-L1371 Differential Revision: https://phabricator.services.mozilla.com/D32307
mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
--- a/mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
+++ b/mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
@@ -29,16 +29,17 @@ import android.support.v4.content.Cursor
 import android.support.v4.content.Loader;
 import android.text.TextUtils;
 import android.text.format.Time;
 import android.util.Log;
 
 class FilePickerResultHandler implements ActivityResultHandler {
     private static final String LOGTAG = "GeckoFilePickerResultHandler";
     private static final String UPLOADS_DIR = "uploads";
+    private static final String ACTION_INLINE_DATA = "inline-data";
 
     private final FilePicker.ResultHandler handler;
     private final int tabId;
     private final File cacheDir;
 
     // this code is really hacky and doesn't belong anywhere so I'm putting it here for now
     // until I can come up with a better solution.
     private String mImageName = "";
@@ -72,17 +73,20 @@ class FilePickerResultHandler implements
     public void onActivityResult(int resultCode, Intent intent) {
         if (resultCode != Activity.RESULT_OK) {
             sendResult("");
             return;
         }
 
         // Camera results won't return an Intent. Use the file name we passed to the original intent.
         // In Android M, camera results return an empty Intent rather than null.
-        if (intent == null || (intent.getAction() == null && intent.getData() == null)) {
+        final boolean emptyResult = intent == null || (intent.getAction() == null && intent.getData() == null);
+        // Camera returned a thumbnail of the photo. Use the file name we passed to the original intent.
+        final boolean haveThumbnail = intent != null && intent.getAction() != null && intent.getAction().equals(ACTION_INLINE_DATA);
+        if (emptyResult || haveThumbnail) {
             if (mImageName != null) {
                 File file = new File(Environment.getExternalStorageDirectory(), mImageName);
                 sendResult(file.getAbsolutePath());
             } else {
                 sendResult("");
             }
             return;
         }