diff options
author | mingwax <mingwax@codeaurora.org> | 2016-12-14 15:42:58 +0800 |
---|---|---|
committer | mingwax <mingwax@codeaurora.org> | 2016-12-14 17:41:52 +0800 |
commit | f015351c73740b25cd65d934dfc6a44c7367dc1c (patch) | |
tree | e0b2d64cd1ffed8102019d906bf74728beadf62e /src/com/android/camera/ui | |
parent | 568dfe8fb8d7150e242ec778b039458d4e6e0b29 (diff) | |
download | android_packages_apps_Snap-f015351c73740b25cd65d934dfc6a44c7367dc1c.tar.gz android_packages_apps_Snap-f015351c73740b25cd65d934dfc6a44c7367dc1c.tar.bz2 android_packages_apps_Snap-f015351c73740b25cd65d934dfc6a44c7367dc1c.zip |
SnapdragonCamera: Fix FC NullpointerException in PanoCapture
Add mutex lock to ensure the mBitmapstream value is not changed
to null.
CRs-Fixed: 1101177
Change-Id: I3095a3d2f0b25a5ba929f16ebc75af81a8950653
Diffstat (limited to 'src/com/android/camera/ui')
-rw-r--r-- | src/com/android/camera/ui/PanoCaptureProcessView.java | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/com/android/camera/ui/PanoCaptureProcessView.java b/src/com/android/camera/ui/PanoCaptureProcessView.java index 2b37fd61e..95e9a095f 100644 --- a/src/com/android/camera/ui/PanoCaptureProcessView.java +++ b/src/com/android/camera/ui/PanoCaptureProcessView.java @@ -120,6 +120,7 @@ public class PanoCaptureProcessView extends View implements SensorEventListener private static final boolean DEBUG = false; //TODO: This has to be false before release private BitmapArrayOutputStream mBitmapStream; private static boolean mIsSupported = false; + private Object mBitmapStreamLock = new Object(); private boolean mIsFrameProcessing = false; enum PANO_STATUS { @@ -337,13 +338,15 @@ public class PanoCaptureProcessView extends View implements SensorEventListener public void onPause() { mSensorManager.unregisterListener(this, mRotationSensor); - if(mBitmapStream != null) { - try { - mBitmapStream.close(); - } catch (IOException e) { - //Ignore + synchronized (mBitmapStreamLock) { + if(mBitmapStream != null) { + try { + mBitmapStream.close(); + } catch (IOException e) { + //Ignore + } + mBitmapStream = null; } - mBitmapStream = null; } } @@ -510,13 +513,16 @@ public class PanoCaptureProcessView extends View implements SensorEventListener } private void doTask(BitmapTask bitmapTask) { - if(mBitmapStream == null) { - mBitmapStream = new BitmapArrayOutputStream(1024*1204); + int rtv = -1; + synchronized (mBitmapStreamLock) { + if(mBitmapStream == null) { + mBitmapStream = new BitmapArrayOutputStream(1024*1204); + } + mBitmapStream.reset(); + bitmapTask.bitmap.compress(Bitmap.CompressFormat.JPEG, 100, mBitmapStream); + rtv = callNativeProcessKeyFrame(mBitmapStream.toByteArray(), mBitmapStream.size(), + bitmapTask.x, bitmapTask.y, 0, bitmapTask.dir); } - mBitmapStream.reset(); - bitmapTask.bitmap.compress(Bitmap.CompressFormat.JPEG, 100, mBitmapStream); - int rtv = callNativeProcessKeyFrame(mBitmapStream.toByteArray(), mBitmapStream.size(), - bitmapTask.x, bitmapTask.y, 0, bitmapTask.dir); if(rtv < 0) { mShouldFinish = true; stopPano(false, mActivity.getResources().getString(R.string.panocapture_direction_is_changed)); |