diff options
-rwxr-xr-x | assets/dependency.json | 3 | ||||
-rwxr-xr-x | src/com/android/camera/CameraActivity.java | 45 | ||||
-rwxr-xr-x | src/com/android/camera/CaptureModule.java | 87 | ||||
-rwxr-xr-x | src/com/android/camera/CaptureUI.java | 6 | ||||
-rwxr-xr-x | src/com/android/camera/MediaSaveService.java | 2 | ||||
-rwxr-xr-x | src/com/android/camera/SettingsActivity.java | 3 | ||||
-rwxr-xr-x | src/com/android/camera/SettingsManager.java | 10 | ||||
-rwxr-xr-x | src/com/android/camera/Storage.java | 1 | ||||
-rwxr-xr-x | src/com/android/camera/ui/CountDownView.java | 22 | ||||
-rwxr-xr-x | version.mk | 2 |
10 files changed, 104 insertions, 77 deletions
diff --git a/assets/dependency.json b/assets/dependency.json index f332aebda..7402d4fe4 100755 --- a/assets/dependency.json +++ b/assets/dependency.json @@ -113,7 +113,8 @@ "pref_camera2_longshot_key":"off"} , "109": - {"pref_camera2_coloreffect_key":"0"} + {"pref_camera2_coloreffect_key":"0", + "pref_camera2_flashmode_key":"off"} , "110": {"pref_camera2_coloreffect_key":"0", diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 958a2cd51..9f225d1c7 100755 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -726,6 +726,22 @@ public class CameraActivity extends Activity return s; } + private int getOrientationFromUri(Uri uri) { + String[] projection = { + MediaStore.Images.Media.ORIENTATION + }; + Cursor cursor = getContentResolver().query(uri, projection, null, null, null); + if (cursor == null) + return 0; + int orientation_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.ORIENTATION); + int ori = 0; + if (cursor.moveToFirst()) { + ori = cursor.getInt(orientation_index); + } + cursor.close(); + return ori; + } + public void updateThumbnail(final byte[] jpegData) { if (mUpdateThumbnailTask != null) mUpdateThumbnailTask.cancel(true); mUpdateThumbnailTask = new UpdateThumbnailTask(jpegData, true); @@ -790,6 +806,7 @@ public class CameraActivity extends Activity private class UpdateThumbnailTask extends AsyncTask<Void, Void, Bitmap> { private byte[] mJpegData; private boolean mCheckOrientation; + private int mOrientation = -1; public UpdateThumbnailTask(final byte[] jpegData, boolean checkOrientation) { mJpegData = jpegData; @@ -810,8 +827,10 @@ public class CameraActivity extends Activity String path = getPathFromUri(uri); if (path == null) { return null; - } - else { + } else { + if (path.endsWith(Storage.HEIF_POSTFIX)) { + mOrientation = getOrientationFromUri(uri); + } if (img.isPhoto()) { return decodeImageCenter(path); } else { @@ -851,16 +870,20 @@ public class CameraActivity extends Activity // saves jpeg with orientation tag set. int orientation = 0; if (mCheckOrientation) { - ExifInterface exif = new ExifInterface(); - try { - if (mJpegData != null) { - exif.readExif(mJpegData); - } else { - exif.readExif(path); + if (mOrientation != -1) { + orientation = mOrientation; + } else { + ExifInterface exif = new ExifInterface(); + try { + if (mJpegData != null) { + exif.readExif(mJpegData); + } else { + exif.readExif(path); + } + orientation = Exif.getOrientation(exif); + } catch (IOException e) { + // ignore } - orientation = Exif.getOrientation(exif); - } catch (IOException e) { - // ignore } } diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 13e5ee8af..0c4106675 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -590,7 +590,7 @@ public class CaptureModule implements CameraModule, PhotoController, private static final int SELFIE_FLASH_DURATION = 680; private static final int SESSION_CONFIGURE_TIMEOUT_MS = 3000; - private MediaActionSound mSound; + private SoundClips.Player mSoundPlayer; private Size mSupportedMaxPictureSize; private Size mSupportedRawPictureSize; @@ -1893,9 +1893,9 @@ public class CaptureModule implements CameraModule, PhotoController, Log.d(TAG, "takePicture"); mUI.enableShutter(false); if ((mSettingsManager.isZSLInHALEnabled() && - !isFlashOn(getMainCameraId()) && + !isFlashOn(getMainCameraId()) && (mPreviewCaptureResult != null && mPreviewCaptureResult.get(CaptureResult.CONTROL_AE_STATE) != - CameraMetadata.CONTROL_AE_STATE_FLASH_REQUIRED) || + CameraMetadata.CONTROL_AE_STATE_FLASH_REQUIRED)) || isActionImageCapture()) { takeZSLPictureInHAL(); } else { @@ -2145,7 +2145,7 @@ public class CaptureModule implements CameraModule, PhotoController, Message message = mCameraHandler.obtainMessage(CANCEL_TOUCH_FOCUS, id, 0, mCameraId[id]); mCameraHandler.sendMessageDelayed(message, CANCEL_TOUCH_FOCUS_DELAY); - } catch (CameraAccessException | IllegalStateException e) { + } catch (CameraAccessException | IllegalStateException | IllegalArgumentException e) { e.printStackTrace(); } } @@ -2497,6 +2497,10 @@ public class CaptureModule implements CameraModule, PhotoController, captureBuilder.set(CaptureRequest.JPEG_THUMBNAIL_QUALITY, (byte)80); applyVideoSnapshot(captureBuilder, id); applyZoom(captureBuilder, id); + if (mHighSpeedCapture) { + captureBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, + mHighSpeedFPSRange); + } if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { long captureTime = System.currentTimeMillis(); @@ -3122,8 +3126,6 @@ public class CaptureModule implements CameraModule, PhotoController, } private void applySettingsForJpegInformation(CaptureRequest.Builder builder, int id) { - if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) - return; Location location = mLocationManager.getCurrentLocation(); if(location != null) { // make copy so that we don't alter the saved location since we may re-use it @@ -3268,9 +3270,9 @@ public class CaptureModule implements CameraModule, PhotoController, if (mIsRecordingVideo) { stopRecordingVideo(getMainCameraId()); } - if (mSound != null) { - mSound.release(); - mSound = null; + if (mSoundPlayer != null) { + mSoundPlayer.release(); + mSoundPlayer = null; } if (selfieThread != null) { selfieThread.interrupt(); @@ -3515,8 +3517,9 @@ public class CaptureModule implements CameraModule, PhotoController, updatePreviewSize(); mCameraIdList = new ArrayList<>(); - if (mSound == null) { - mSound = new MediaActionSound(); + // Set up sound playback for shutter button, video record and video stop + if (mSoundPlayer == null) { + mSoundPlayer = SoundClips.getPlayer(mActivity); } updateSaveStorageState(); @@ -3845,7 +3848,8 @@ public class CaptureModule implements CameraModule, PhotoController, @Override public void onSingleTapUp(View view, int x, int y) { if (mPaused || !mCamerasOpened || !mFirstTimeInitialized || !mAutoFocusRegionSupported - || !mAutoExposureRegionSupported || !isTouchToFocusAllowed()) { + || !mAutoExposureRegionSupported || !isTouchToFocusAllowed() + || mCaptureSession[getMainCameraId()] == null) { return; } if (DEBUG) { @@ -4358,10 +4362,7 @@ public class CaptureModule implements CameraModule, PhotoController, e.printStackTrace(); } if (!mFrameProcessor.isFrameListnerEnabled() && !startMediaRecorder()) { - mUI.showUIafterRecording(); - releaseMediaRecorder(); - mFrameProcessor.setVideoOutputSurface(null); - restartSession(true); + startRecordingFailed(); return; } @@ -4538,13 +4539,6 @@ public class CaptureModule implements CameraModule, PhotoController, for (Surface surface : outputSurfaces) { outConfigurations.add(new OutputConfiguration(surface)); } - if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT && - mLiveShotInitHeifWriter != null) { - mLiveShotOutput = new OutputConfiguration( - mLiveShotInitHeifWriter.getInputSurface()); - mLiveShotOutput .enableSurfaceSharing(); - outConfigurations.add(mLiveShotOutput); - } Method method_setSessionParameters = null; Method method_createCaptureSession = null; Object sessionConfig = null; @@ -4691,10 +4685,7 @@ public class CaptureModule implements CameraModule, PhotoController, e.printStackTrace(); } if (!mFrameProcessor.isFrameListnerEnabled() && !startMediaRecorder()) { - mUI.showUIafterRecording(); - releaseMediaRecorder(); - mFrameProcessor.setVideoOutputSurface(null); - restartSession(true); + startRecordingFailed(); return; } mUI.clearFocus(); @@ -4762,6 +4753,18 @@ public class CaptureModule implements CameraModule, PhotoController, return true; } + private void startRecordingFailed() { + releaseMediaRecorder(); + mHandler.post(new Runnable() { + @Override + public void run() { + mUI.showUIafterRecording(); + mFrameProcessor.setVideoOutputSurface(null); + restartSession(true); + } + }); + } + private void quitRecordingWithError(String msg) { Toast.makeText(mActivity,"Could not start media recorder.\n " + msg, Toast.LENGTH_LONG).show(); @@ -4806,15 +4809,7 @@ public class CaptureModule implements CameraModule, PhotoController, public void startMediaRecording() { if (!startMediaRecorder()) { - mActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - mUI.showUIafterRecording(); - } - }); - releaseMediaRecorder(); - mFrameProcessor.setVideoOutputSurface(null); - restartSession(true); + startRecordingFailed(); } } @@ -6515,9 +6510,9 @@ public class CaptureModule implements CameraModule, PhotoController, private void checkAndPlayRecordSound(int id, boolean isStarted) { if (id == getMainCameraId()) { String value = mSettingsManager.getValue(SettingsManager.KEY_SHUTTER_SOUND); - if (value != null && value.equals("on") && mSound != null) { - mSound.play(isStarted? MediaActionSound.START_VIDEO_RECORDING - : MediaActionSound.STOP_VIDEO_RECORDING); + if (value != null && value.equals("on") && mSoundPlayer != null) { + mSoundPlayer.play(isStarted? SoundClips.START_VIDEO_RECORDING + : SoundClips.STOP_VIDEO_RECORDING); } } } @@ -6525,8 +6520,8 @@ public class CaptureModule implements CameraModule, PhotoController, public void checkAndPlayShutterSound(int id) { if (id == getMainCameraId()) { String value = mSettingsManager.getValue(SettingsManager.KEY_SHUTTER_SOUND); - if (value != null && value.equals("on") && mSound != null) { - mSound.play(MediaActionSound.SHUTTER_CLICK); + if (value != null && value.equals("on") && mSoundPlayer != null) { + mSoundPlayer.play(SoundClips.SHUTTER_CLICK); } } } @@ -7208,9 +7203,13 @@ public class CaptureModule implements CameraModule, PhotoController, Log.v(TAG, "Releasing media recorder."); if (mMediaRecorder != null) { cleanupEmptyFile(); - mMediaRecorder.reset(); - mMediaRecorder.release(); - mMediaRecorder = null; + try{ + mMediaRecorder.reset(); + mMediaRecorder.release(); + mMediaRecorder = null; + }catch (IllegalStateException e) { + e.printStackTrace(); + } } mVideoFilename = null; } diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java index 85ac9e293..c5875327d 100755 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -1551,7 +1551,11 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } public void initCountDownView() { - if (mCountDownView == null) initializeCountDown(); + if (mCountDownView == null) { + initializeCountDown(); + } else { + mCountDownView.initSoundPool(); + } } public void releaseSoundPool() { diff --git a/src/com/android/camera/MediaSaveService.java b/src/com/android/camera/MediaSaveService.java index 078a9c427..5f172843d 100755 --- a/src/com/android/camera/MediaSaveService.java +++ b/src/com/android/camera/MediaSaveService.java @@ -391,7 +391,7 @@ public class MediaSaveService extends Service { @Override protected void onPostExecute(Uri uri) { - boolean previouslyFull = isQueueFull(); + if (listener != null) listener.onMediaSaved(uri); } } diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java index f69332f51..4cff72f75 100755 --- a/src/com/android/camera/SettingsActivity.java +++ b/src/com/android/camera/SettingsActivity.java @@ -125,7 +125,8 @@ public class SettingsActivity extends PreferenceActivity { UpdateManualExposureSettings(); } - if ( pref.getKey().equals(SettingsManager.KEY_QCFA) ) { + if ( pref.getKey().equals(SettingsManager.KEY_QCFA) || + pref.getKey().equals(SettingsManager.KEY_PICTURE_FORMAT) ) { mSettingsManager.updateQcfaPictureSize(); updatePreference(SettingsManager.KEY_PICTURE_SIZE); } diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java index 0a8e00ecc..4fb29283b 100755 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -1345,8 +1345,10 @@ public class SettingsManager implements ListMenu.SettingsListener { public boolean isBsgcAvailable(int id) { boolean ret = false; try { - byte bsgc_available = mCharacteristics.get(id).get(CaptureModule.bsgcAvailable); - ret = bsgc_available == 1; + if (mCharacteristics.size() > 0) { + byte bsgc_available = mCharacteristics.get(id).get(CaptureModule.bsgcAvailable); + ret = bsgc_available == 1; + } } catch (IllegalArgumentException e) { e.printStackTrace(); } @@ -1381,6 +1383,7 @@ public class SettingsManager implements ListMenu.SettingsListener { List<String> res = new ArrayList<>(); boolean isDeepportrait = getDeepportraitEnabled(); + boolean isHeifEnabled = getSavePictureFormat() == HEIF_FORMAT; if (getQcfaPrefEnabled() && getIsSupportedQcfa(cameraId)) { res.add(getSupportedQcfaDimension(cameraId)); @@ -1388,6 +1391,9 @@ public class SettingsManager implements ListMenu.SettingsListener { if (sizes != null) { for (int i = 0; i < sizes.length; i++) { + if (isHeifEnabled && (Math.min(sizes[i].getWidth(),sizes[i].getHeight()) < 512)) { + continue; + } if (isDeepportrait && (Math.min(sizes[i].getWidth(),sizes[i].getHeight()) < 720 || Math.max(sizes[i].getWidth(),sizes[i].getHeight()) <= 1024)) { diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java index 1f5671c97..05589bcc9 100755 --- a/src/com/android/camera/Storage.java +++ b/src/com/android/camera/Storage.java @@ -51,6 +51,7 @@ public class Storage { public static final String DIRECTORY = DCIM + "/Camera"; public static final String RAW_DIRECTORY = DCIM + "/Camera/raw"; public static final String JPEG_POSTFIX = ".jpg"; + public static final String HEIF_POSTFIX = ".heic"; // Match the code in MediaProvider.computeBucketValues(). public static final String BUCKET_ID = diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java index f62c99958..0e1acc080 100755 --- a/src/com/android/camera/ui/CountDownView.java +++ b/src/com/android/camera/ui/CountDownView.java @@ -55,15 +55,19 @@ public class CountDownView extends FrameLayout { mContext = context; mCountDownAnim = AnimationUtils.loadAnimation(context, R.anim.count_down_exit); + initSoundPool(); + } + + public void initSoundPool() { if (mSoundPool == null) { // Load the beeps - if (context.getResources().getBoolean(R.bool.force_count_down_sound)) { + if (mContext.getResources().getBoolean(R.bool.force_count_down_sound)) { mSoundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM_ENFORCED, 0); } else { mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0); } - mBeepOnce = mSoundPool.load(context, R.raw.beep_once, 1); - mBeepTwice = mSoundPool.load(context, R.raw.beep_twice, 1); + mBeepOnce = mSoundPool.load(mContext, R.raw.beep_once, 1); + mBeepTwice = mSoundPool.load(mContext, R.raw.beep_twice, 1); } } @@ -98,18 +102,6 @@ public class CountDownView extends FrameLayout { mCountDownAnim.reset(); mRemainingSecondsView.clearAnimation(); mRemainingSecondsView.startAnimation(mCountDownAnim); - - if (mSoundPool == null) { - // Load the beeps - if (mContext.getResources().getBoolean(R.bool.force_count_down_sound)) { - mSoundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM_ENFORCED, 0); - } else { - mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0); - } - mBeepOnce = mSoundPool.load(mContext, R.raw.beep_once, 1); - mBeepTwice = mSoundPool.load(mContext, R.raw.beep_twice, 1); - } - // Play sound effect for the last 3 seconds of the countdown if (mPlaySound && mSoundPool != null) { if (newVal == 1) { diff --git a/version.mk b/version.mk index 4f7d3c6f3..8fcaf5490 100755 --- a/version.mk +++ b/version.mk @@ -40,7 +40,7 @@ # base_version_build is 3 digits and auto-increment for fixing CR. base_version_major := 2 base_version_minor := 02 -base_version_build := 023 +base_version_build := 024 ##################################################### ##################################################### |