From: ztenghui Date: Mon, 14 Oct 2013 18:15:44 +0000 (-0700) Subject: Only delete the Uri coming from onMediaSaved X-Git-Tag: android-x86-6.0-r3~68^2~27^2~45^2~13^2^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3543879bf2d59feae5ded9e5709d40fe33925746;p=android-x86%2Fpackages-apps-Camera2.git Only delete the Uri coming from onMediaSaved The incoming Uri can be null, or a file Uri, which we don't want to delete. The Uri from onMediaSaved has been inserted to the MediaStore and pass null check. bug:11218007 Change-Id: Ie4b08cae94e22a8014ea2436f0a82eba2541a667 --- diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index 012376c82..83c5faf18 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -136,6 +136,7 @@ public class VideoModule implements CameraModule, // examined by the user. private String mCurrentVideoFilename; private Uri mCurrentVideoUri; + private boolean mCurrentVideoUriFromMediaSaved; private ContentValues mCurrentVideoValues; private CamcorderProfile mProfile; @@ -179,6 +180,7 @@ public class VideoModule implements CameraModule, public void onMediaSaved(Uri uri) { if (uri != null) { mCurrentVideoUri = uri; + mCurrentVideoUriFromMediaSaved = true; onVideoSaved(); mActivity.notifyNewMedia(uri); } @@ -478,11 +480,8 @@ public class VideoModule implements CameraModule, // TODO: It should be better to not even insert the URI at all before we // confirm done in review, which means we need to handle temporary video // files in a quite different way than we currently had. - // When the video capture intent doesn't contain the Uri info and the - // review is cancelled before taking a video, mCurrentVideoUri can be - // null. Also make sure we don't delete the Uri sent from the video - // capture intent. - if (mIsInReviewMode && mCurrentVideoUri != null) { + // Make sure we don't delete the Uri sent from the video capture intent. + if (mCurrentVideoUriFromMediaSaved) { mContentResolver.delete(mCurrentVideoUri, null, null); } mIsInReviewMode = false; @@ -962,6 +961,7 @@ public class VideoModule implements CameraModule, long requestedSizeLimit = 0; closeVideoFileDescriptor(); + mCurrentVideoUriFromMediaSaved = false; if (mIsVideoCaptureIntent && myExtras != null) { Uri saveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT); if (saveUri != null) {