From 49ce6546e4484cbd5e64b8a9f401f62358b01dc7 Mon Sep 17 00:00:00 2001 From: xiaoqiny Date: Thu, 3 Apr 2014 17:23:12 +0800 Subject: Gallery2: Fix force close issue when mute some videos - catch exception when failed to mute video Change-Id: Ib0901e9f27bdfb0b06f7a8968ca5bcffad63578d CRs-Fixed: 641477 --- src/com/android/gallery3d/app/MuteVideo.java | 16 +++++++++++++--- src/com/android/gallery3d/app/VideoUtils.java | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/com/android/gallery3d/app/MuteVideo.java mode change 100644 => 100755 src/com/android/gallery3d/app/VideoUtils.java (limited to 'src') diff --git a/src/com/android/gallery3d/app/MuteVideo.java b/src/com/android/gallery3d/app/MuteVideo.java old mode 100644 new mode 100755 index a385fbb9f..dd05397d2 --- a/src/com/android/gallery3d/app/MuteVideo.java +++ b/src/com/android/gallery3d/app/MuteVideo.java @@ -87,9 +87,19 @@ public class MuteVideo { VideoUtils.startMute(mFilePath, mDstFileInfo); SaveVideoFileUtils.insertContent( mDstFileInfo, mActivity.getContentResolver(), mUri); - } catch (IOException e) { - Toast.makeText(mActivity, mActivity.getString(R.string.video_mute_err), - Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + mHandler.post(new Runnable() { + @Override + public void run() { + Toast.makeText(mActivity, mActivity.getString(R.string.video_mute_err), + Toast.LENGTH_SHORT).show(); + if (mMuteProgress != null) { + mMuteProgress.dismiss(); + mMuteProgress = null; + } + } + }); + return; } // After muting is done, trigger the UI changed. mHandler.post(new Runnable() { diff --git a/src/com/android/gallery3d/app/VideoUtils.java b/src/com/android/gallery3d/app/VideoUtils.java old mode 100644 new mode 100755 index 76d5d1e02..4f551a67d --- a/src/com/android/gallery3d/app/VideoUtils.java +++ b/src/com/android/gallery3d/app/VideoUtils.java @@ -226,6 +226,11 @@ public class VideoUtils { } catch (IllegalStateException e) { // Swallow the exception due to malformed source. Log.w(LOGTAG, "The source video file is malformed"); + File f = new File(dstPath); + if (f.exists()) { + f.delete(); + } + throw e; } finally { muxer.release(); } -- cgit v1.2.3