ApiHelper: kill it
Change-Id: Icecc218a606dd792907ece4a97b0b828d4a0c983
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java
index 414ff81..14f0504 100644
--- a/src/com/android/camera/AndroidCameraManagerImpl.java
+++ b/src/com/android/camera/AndroidCameraManagerImpl.java
@@ -26,7 +26,6 @@
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.AutoFocusMoveCallback;
-import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.ErrorCallback;
import android.hardware.Camera.FaceDetectionListener;
import android.hardware.Camera.OnZoomChangeListener;
@@ -44,7 +43,7 @@
import android.hardware.Camera.CameraDataCallback;
import android.hardware.Camera.CameraMetaDataCallback;
import com.android.camera.app.CameraApp;
-import com.android.camera.util.ApiHelper;
+
import android.os.ConditionVariable;
import java.lang.reflect.Method;
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index c7b6d06..3c70476 100755
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -18,8 +18,6 @@
package com.android.camera;
import android.hardware.camera2.CameraAccessException;
-import android.os.Parcel;
-import android.os.Parcelable;
import android.view.Display;
import android.graphics.Point;
import android.Manifest;
@@ -36,7 +34,6 @@
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
-import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.Cursor;
@@ -57,8 +54,6 @@
import android.net.Uri;
import android.media.ThumbnailUtils;
import android.nfc.NfcAdapter;
-import android.nfc.NfcAdapter.CreateBeamUrisCallback;
-import android.nfc.NfcEvent;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@@ -111,13 +106,11 @@
import com.android.camera.ui.FilmStripView.ImageData;
import com.android.camera.ui.PanoCaptureProcessView;
import com.android.camera.ui.RotateTextToast;
-import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.FeatureHelper;
import com.android.camera.util.GcamHelper;
import com.android.camera.util.IntentHelper;
import com.android.camera.util.PersistUtil;
-import com.android.camera.util.PhotoSphereHelper;
import com.android.camera.util.PhotoSphereHelper.PanoramaViewHelper;
import com.android.camera.util.UsageStatistics;
import org.codeaurora.snapcam.R;
@@ -736,19 +729,8 @@
return;
}
- if (!ApiHelper.HAS_SET_BEAM_PUSH_URIS) {
- // Disable beaming
- adapter.setNdefPushMessage(null, CameraActivity.this);
- return;
- }
-
adapter.setBeamPushUris(null, CameraActivity.this);
- adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() {
- @Override
- public Uri[] createBeamUris(NfcEvent event) {
- return mNfcPushUris;
- }
- }, CameraActivity.this);
+ adapter.setBeamPushUrisCallback(event -> mNfcPushUris, CameraActivity.this);
}
private void setNfcBeamPushUri(Uri uri) {
@@ -1633,10 +1615,7 @@
if (mActionBar != null) {
mActionBar.addOnMenuVisibilityListener(this);
}
-
- if (ApiHelper.HAS_ROTATION_ANIMATION) {
- setRotationAnimation();
- }
+ setRotationAnimation();
mMainHandler = new MainHandler(getMainLooper());
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 5af2d8b..916a755 100755
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -36,7 +36,6 @@
import java.util.HashMap;
import android.util.Log;
-import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.GcamHelper;
import com.android.camera.util.PersistUtil;
@@ -315,13 +314,7 @@
//video encoders
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H263, "h263");
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H264, "h264");
- int h265 = ApiHelper.getIntFieldIfExists(MediaRecorder.VideoEncoder.class,
- "HEVC", null, MediaRecorder.VideoEncoder.DEFAULT);
- if (h265 == MediaRecorder.VideoEncoder.DEFAULT) {
- h265 = ApiHelper.getIntFieldIfExists(MediaRecorder.VideoEncoder.class,
- "H265", null, MediaRecorder.VideoEncoder.DEFAULT);
- }
- VIDEO_ENCODER_TABLE.put(h265, "h265");
+ VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.HEVC, "h265");
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.MPEG_4_SP, "m4v");
//video qualities
@@ -1248,14 +1241,12 @@
if (videoEffect != null) {
filterUnsupportedOptions(group, videoEffect, null);
}
- if (cameraHdr != null && (!ApiHelper.HAS_CAMERA_HDR
- || !CameraUtil.isCameraHdrSupported(mParameters))) {
+ if (cameraHdr != null && !CameraUtil.isCameraHdrSupported(mParameters)) {
removePreference(group, cameraHdr.getKey());
}
int frontCameraId = CameraHolder.instance().getFrontCameraId();
boolean isFrontCamera = (frontCameraId == mCameraId);
- if (cameraHdrPlus != null && (!ApiHelper.HAS_CAMERA_HDR_PLUS ||
- !GcamHelper.hasGcamCapture() || isFrontCamera)) {
+ if (cameraHdrPlus != null && (!GcamHelper.hasGcamCapture() || isFrontCamera)) {
removePreference(group, cameraHdrPlus.getKey());
}
if (powerShutter != null && CameraUtil.hasCameraKey()) {
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 6a5e5c2..9119069 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -26,13 +26,16 @@
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.ImageFormat;
import android.graphics.Matrix;
+import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -61,13 +64,13 @@
import android.media.EncoderCapabilities.VideoEncoderCap;
import android.media.Image;
import android.media.ImageReader;
-import android.media.MediaFormat;
-import android.media.MediaMetadataRetriever;
-import android.media.MediaRecorder;
import android.media.MediaCodecInfo;
import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.MediaCodecInfo.VideoCapabilities;
import android.media.MediaCodecList;
+import android.media.MediaFormat;
+import android.media.MediaMetadataRetriever;
+import android.media.MediaRecorder;
import android.net.Uri;
import android.os.Bundle;
import android.os.Debug;
@@ -77,8 +80,8 @@
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.SystemClock;
-import android.os.SystemProperties;
import android.provider.MediaStore;
+import android.util.AttributeSet;
import android.util.Log;
import android.util.Range;
import android.util.Size;
@@ -90,27 +93,23 @@
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
+import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
-import android.widget.FrameLayout;
-import android.graphics.Paint;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.util.AttributeSet;
+import com.android.camera.PhotoModule.NamedImages;
+import com.android.camera.PhotoModule.NamedImages.NamedEntity;
import com.android.camera.deepportrait.CamGLRenderObserver;
import com.android.camera.deepportrait.CamGLRenderer;
import com.android.camera.deepportrait.DPImage;
import com.android.camera.deepportrait.GLCameraPreview;
import com.android.camera.exif.ExifInterface;
+import com.android.camera.imageprocessor.FrameProcessor;
+import com.android.camera.imageprocessor.PostProcessor;
import com.android.camera.imageprocessor.filter.BlurbusterFilter;
import com.android.camera.imageprocessor.filter.ChromaflashFilter;
import com.android.camera.imageprocessor.filter.DeepPortraitFilter;
import com.android.camera.imageprocessor.filter.ImageFilter;
-import com.android.camera.imageprocessor.PostProcessor;
-import com.android.camera.imageprocessor.FrameProcessor;
-import com.android.camera.PhotoModule.NamedImages;
-import com.android.camera.PhotoModule.NamedImages.NamedEntity;
import com.android.camera.imageprocessor.filter.SharpshooterFilter;
import com.android.camera.imageprocessor.filter.StillmoreFilter;
import com.android.camera.imageprocessor.filter.UbifocusFilter;
@@ -119,14 +118,12 @@
import com.android.camera.ui.ProMode;
import com.android.camera.ui.RotateTextToast;
import com.android.camera.ui.TrackingFocusRenderer;
-import com.android.camera.util.ApiHelper;
+import com.android.camera.util.AccessibilityUtils;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.PersistUtil;
import com.android.camera.util.SettingTranslation;
-import com.android.camera.util.AccessibilityUtils;
import com.android.camera.util.VendorTagUtil;
import com.android.internal.util.MemInfoReader;
-
import com.shift.camera.CaptureRequestKey;
import com.shift.camera.Metadata.HDR;
import com.shift.camera.Metadata.LowLightShot;
@@ -141,6 +138,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -148,12 +146,11 @@
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.Executor;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.Executor;
-import java.lang.reflect.Method;
import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
import androidx.heifwriter.HeifWriter;
@@ -1687,23 +1684,21 @@
list.add(mRawImageReader[id].getSurface());
}
- List<OutputConfiguration> outputConfigurations = null;
- if (ApiHelper.isAndroidPOrHigher()) {
- outputConfigurations = new ArrayList<OutputConfiguration>();
- for (Surface s : list) {
- outputConfigurations.add(new OutputConfiguration(s));
- }
+ List<OutputConfiguration> outputConfigurations = new ArrayList<>();
+ for (Surface s : list) {
+ outputConfigurations.add(new OutputConfiguration(s));
+ }
- mIsFormatHeif = false;
- if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT ) {
- if (mInitHeifWriter != null) {
- mHeifOutput = new OutputConfiguration(mInitHeifWriter.getInputSurface());
- mHeifOutput.enableSurfaceSharing();
- outputConfigurations.add(mHeifOutput);
- mIsFormatHeif = true;
- }
+ mIsFormatHeif = false;
+ if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) {
+ if (mInitHeifWriter != null) {
+ mHeifOutput = new OutputConfiguration(mInitHeifWriter.getInputSurface());
+ mHeifOutput.enableSurfaceSharing();
+ outputConfigurations.add(mHeifOutput);
+ mIsFormatHeif = true;
}
}
+
if(mChosenImageFormat == ImageFormat.YUV_420_888 || mChosenImageFormat == ImageFormat.PRIVATE) {
if (mPostProcessor.isZSLEnabled()) {
mPreviewRequestBuilder[id].addTarget(mImageReader[id].getSurface());
@@ -1723,7 +1718,7 @@
}
}
} else {
- if (ApiHelper.isAndroidPOrHigher() && outputConfigurations != null) {
+ if (outputConfigurations != null) {
createCameraSessionWithSessionConfiguration(id, outputConfigurations, captureSessionCallback,
mCameraHandler, mPreviewRequestBuilder[id].build());
} else {
@@ -4809,94 +4804,13 @@
}
- if (ApiHelper.isAndroidPOrHigher()) {
- if (mHighSpeedCapture && ((int) mHighSpeedFPSRange.getUpper() > NORMAL_SESSION_MAX_FPS)) {
- CaptureRequest initialRequest = mVideoRequestBuilder.build();
- buildConstrainedCameraSession(mCameraDevice[cameraId], surfaces,
- mSessionListener, mCameraHandler, initialRequest);
-
- } else {
- configureCameraSessionWithParameters(cameraId, surfaces,
- mSessionListener, mCameraHandler, mVideoRequestBuilder.build());
- }
+ if (mHighSpeedCapture && ((int) mHighSpeedFPSRange.getUpper() > NORMAL_SESSION_MAX_FPS)) {
+ CaptureRequest initialRequest = mVideoRequestBuilder.build();
+ buildConstrainedCameraSession(mCameraDevice[cameraId], surfaces,
+ mSessionListener, mCameraHandler, initialRequest);
} else {
- if (mHighSpeedCapture && ((int) mHighSpeedFPSRange.getUpper() > NORMAL_SESSION_MAX_FPS)) {
- mCameraDevice[cameraId].createConstrainedHighSpeedCaptureSession(surfaces, new
- CameraConstrainedHighSpeedCaptureSession.StateCallback() {
-
- @Override
- public void onConfigured(CameraCaptureSession cameraCaptureSession) {
- mCurrentSession = cameraCaptureSession;
- Log.v(TAG, "createConstrainedHighSpeedCaptureSession onConfigured");
- mCaptureSession[cameraId] = cameraCaptureSession;
- CameraConstrainedHighSpeedCaptureSession session =
- (CameraConstrainedHighSpeedCaptureSession) mCurrentSession;
- try {
- setUpVideoCaptureRequestBuilder(mVideoRequestBuilder, cameraId);
- List list = CameraUtil
- .createHighSpeedRequestList(mVideoRequestBuilder.build());
- session.setRepeatingBurst(list, mCaptureCallback, mCameraHandler);
- } catch (CameraAccessException e) {
- Log.e(TAG, "Failed to start high speed video recording "
- + e.getMessage());
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Failed to start high speed video recording "
- + e.getMessage());
- e.printStackTrace();
- } catch (IllegalStateException e) {
- Log.e(TAG, "Failed to start high speed video recording "
- + e.getMessage());
- e.printStackTrace();
- }
- if (!mFrameProcessor.isFrameListnerEnabled() && !startMediaRecorder()) {
- startRecordingFailed();
- return;
- }
- mUI.getFocusRing().stopFocusAnimations();
- mUI.resetPauseButton();
- mRecordingTotalTime = 0L;
- mRecordingStartTime = SystemClock.uptimeMillis();
- mUI.enableShutter(false);
- mUI.showRecordingUI(true, false);
- updateRecordingTime();
- keepScreenOn();
- }
-
- @Override
- public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
- Toast.makeText(mActivity, "Failed", Toast.LENGTH_SHORT).show();
- }
- }, null);
- } else {
- surfaces.add(mVideoSnapshotImageReader.getSurface());
- String zzHDR = mSettingsManager.getValue(SettingsManager.KEY_VIDEO_HDR_VALUE);
- boolean zzHdrStatue = zzHDR.equals("1");
- // if enable ZZHDR mode, don`t call the setOpModeForVideoStream method.
- if (!zzHdrStatue) {
- setOpModeForVideoStream(cameraId);
- }
- String value = mSettingsManager.getValue(SettingsManager.KEY_FOVC_VALUE);
- if (value != null && Boolean.parseBoolean(value)) {
- mStreamConfigOptMode = mStreamConfigOptMode | STREAM_CONFIG_MODE_FOVC;
- }
- if (zzHdrStatue) {
- mStreamConfigOptMode = STREAM_CONFIG_MODE_ZZHDR;
- }
-
- Log.v(TAG, "createCustomCaptureSession mStreamConfigOptMode: " + mStreamConfigOptMode);
-
- if (mStreamConfigOptMode == 0) {
- mCameraDevice[cameraId].createCaptureSession(surfaces, mCCSSateCallback, null);
- } else {
- List<OutputConfiguration> outConfigurations = new ArrayList<>(surfaces.size());
- for (Surface sface : surfaces) {
- outConfigurations.add(new OutputConfiguration(sface));
- }
- mCameraDevice[cameraId].createCustomCaptureSession(null, outConfigurations,
- mStreamConfigOptMode, mCCSSateCallback, null);
- }
- }
+ configureCameraSessionWithParameters(cameraId, surfaces,
+ mSessionListener, mCameraHandler, mVideoRequestBuilder.build());
}
} catch (CameraAccessException e) {
e.printStackTrace();
@@ -5267,17 +5181,7 @@
mRecordingStartTime = SystemClock.uptimeMillis();
updateRecordingTime();
setEndOfStream(true, false);
- if (!ApiHelper.HAS_RESUME_SUPPORTED){
- mMediaRecorder.start();
- Log.d(TAG, "StartRecordingVideo done.");
- } else {
- try {
- Method resumeRec = Class.forName("android.media.MediaRecorder").getMethod("resume");
- resumeRec.invoke(mMediaRecorder);
- } catch (Exception e) {
- Log.v(TAG, "resume method not implemented");
- }
- }
+ mMediaRecorder.resume();
}
private void setEndOfStream(boolean isResume, boolean isStopRecord) {
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 856bd93..bee5e77 100755
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -31,18 +31,14 @@
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
-import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
-import android.hardware.Camera;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.media.AudioAttributes;
-import android.media.AudioManager;
import android.media.CameraProfile;
import android.media.SoundPool;
import android.net.Uri;
@@ -83,7 +79,6 @@
import com.android.camera.ui.CountDownView.OnCountDownFinishedListener;
import com.android.camera.ui.ModuleSwitcher;
import com.android.camera.ui.RotateTextToast;
-import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.GcamHelper;
import com.android.camera.util.PersistUtil;
@@ -106,7 +101,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Arrays;
import java.lang.NumberFormatException;
import java.util.List;
import java.util.Vector;
@@ -321,9 +315,7 @@
private final AutoFocusCallback mAutoFocusCallback =
new AutoFocusCallback();
private final Object mAutoFocusMoveCallback =
- ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK
- ? new AutoFocusMoveCallback()
- : null;
+ new AutoFocusMoveCallback();
private final CameraErrorCallback mErrorCallback = new CameraErrorCallback();
private final StatsCallback mStatsCallback = new StatsCallback();
@@ -4362,7 +4354,7 @@
}
}
- if (mContinuousFocusSupported && ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK) {
+ if (mContinuousFocusSupported) {
updateAutoFocusMoveCallback();
}
diff --git a/src/com/android/camera/SoundClips.java b/src/com/android/camera/SoundClips.java
index 812734e..01d8d3b 100644
--- a/src/com/android/camera/SoundClips.java
+++ b/src/com/android/camera/SoundClips.java
@@ -19,14 +19,12 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.media.AudioAttributes;
-import android.media.AudioManager;
import android.media.MediaActionSound;
import android.media.SoundPool;
import android.os.Build;
import android.util.Log;
import org.codeaurora.snapcam.R;
-import com.android.camera.util.ApiHelper;
/*
* This class controls the sound playback according to the API level.
@@ -44,11 +42,7 @@
}
public static Player getPlayer(Context context) {
- if (ApiHelper.HAS_MEDIA_ACTION_SOUND) {
- return new MediaActionSoundPlayer();
- } else {
- return new SoundPoolPlayer(context);
- }
+ return new MediaActionSoundPlayer();
}
/**
diff --git a/src/com/android/camera/SoundPlayer.java b/src/com/android/camera/SoundPlayer.java
index 6e76eb5..8301f23 100644
--- a/src/com/android/camera/SoundPlayer.java
+++ b/src/com/android/camera/SoundPlayer.java
@@ -18,12 +18,9 @@
import android.content.Context;
import android.media.AudioAttributes;
-import android.media.AudioManager;
import android.media.SoundPool;
import android.util.SparseIntArray;
-import com.android.camera.util.ApiHelper;
-
/**
* Loads a plays custom sounds. For playing system-standard sounds for various
* camera actions, please refer to {@link SoundClips}.
diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java
index 8658474..e61eca9 100755
--- a/src/com/android/camera/Storage.java
+++ b/src/com/android/camera/Storage.java
@@ -16,31 +16,21 @@
package com.android.camera;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.ContentValues;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.location.Location;
import android.net.Uri;
-import android.os.Build;
import android.os.Environment;
-import android.os.Handler;
import android.os.StatFs;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Images.ImageColumns;
import android.provider.MediaStore.MediaColumns;
import android.util.Log;
-import com.android.camera.data.LocalData;
import com.android.camera.exif.ExifInterface;
-import com.android.camera.util.ApiHelper;
-import androidx.heifwriter.HeifWriter;
-import android.graphics.ImageFormat;
+
+import java.io.File;
+import java.io.FileOutputStream;
public class Storage {
private static final String TAG = "CameraStorage";
@@ -72,13 +62,9 @@
sSaveSDCard = saveSDCard;
}
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private static void setImageSize(ContentValues values, int width, int height) {
- // The two fields are available since ICS but got published in JB
- if (ApiHelper.HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT) {
- values.put(MediaColumns.WIDTH, width);
- values.put(MediaColumns.HEIGHT, height);
- }
+ values.put(MediaColumns.WIDTH, width);
+ values.put(MediaColumns.HEIGHT, height);
}
public static int writeFile(String path, byte[] jpeg, ExifInterface exif,
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index a1c5cfb..b58dd7a 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -30,8 +30,6 @@
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.ImageFormat;
-import android.hardware.Camera;
-import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
import android.location.Location;
@@ -66,13 +64,10 @@
import com.android.camera.CameraManager.CameraProxy;
import com.android.camera.app.OrientationManager;
import com.android.camera.exif.ExifInterface;
-import com.android.camera.ui.RotateImageView;
import com.android.camera.ui.RotateTextToast;
import com.android.camera.util.AccessibilityUtils;
-import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
-import com.android.camera.PhotoModule;
import org.codeaurora.snapcam.R;
import org.codeaurora.snapcam.wrapper.ParametersWrapper;
@@ -85,7 +80,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.HashMap;
-import java.lang.reflect.Method;
import java.util.regex.Pattern;
public class VideoModule implements CameraModule,
@@ -349,13 +343,7 @@
VIDEO_ENCODER_TABLE.put("h263", MediaRecorder.VideoEncoder.H263);
VIDEO_ENCODER_TABLE.put("h264", MediaRecorder.VideoEncoder.H264);
- int h265 = ApiHelper.getIntFieldIfExists(MediaRecorder.VideoEncoder.class,
- "HEVC", null, MediaRecorder.VideoEncoder.DEFAULT);
- if (h265 == MediaRecorder.VideoEncoder.DEFAULT) {
- h265 = ApiHelper.getIntFieldIfExists(MediaRecorder.VideoEncoder.class,
- "H265", null, MediaRecorder.VideoEncoder.DEFAULT);
- }
- VIDEO_ENCODER_TABLE.put("h265", h265);
+ VIDEO_ENCODER_TABLE.put("h265", MediaRecorder.VideoEncoder.HEVC);
VIDEO_ENCODER_TABLE.put("m4v", MediaRecorder.VideoEncoder.MPEG_4_SP);
VIDEO_ENCODER_TABLE.putDefault(MediaRecorder.VideoEncoder.DEFAULT);
@@ -493,12 +481,6 @@
}
}
- private void initializeSurfaceView() {
- if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) { // API level < 16
- mUI.initializeSurfaceView();
- }
- }
-
public void reinit() {
mPreferences = ComboPreferences.get(mActivity);
if (mPreferences == null) {
@@ -553,7 +535,6 @@
// Surface texture is from camera screen nail and startPreview needs it.
// This must be done before startPreview.
mIsVideoCaptureIntent = isVideoCaptureIntent();
- initializeSurfaceView();
// Make sure camera device is opened.
try {
@@ -853,7 +834,7 @@
}
} else if (!recordFail){
// Start capture animation.
- if (!mPaused && ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
+ if (!mPaused) {
// The capture animation is disabled on ICS because we use SurfaceView
// for preview during recording. When the recording is done, we switch
// back to use SurfaceTexture for preview and we need to stop then start
@@ -1433,12 +1414,6 @@
mFaceDetectionStarted = false;
}
- private void releasePreviewResources() {
- if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
- mUI.hideSurfaceView();
- }
- }
-
@Override
public void onPauseBeforeSuper() {
mPaused = true;
@@ -1455,9 +1430,6 @@
closeVideoFileDescriptor();
-
- releasePreviewResources();
-
if (mReceiver != null) {
mActivity.unregisterReceiver(mReceiver);
mReceiver = null;
@@ -1642,25 +1614,6 @@
private void setupMediaRecorderPreviewDisplay() {
mFocusManager.resetTouchFocus();
- // Nothing to do here if using SurfaceTexture.
- if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
- // We stop the preview here before unlocking the device because we
- // need to change the SurfaceTexture to SurfaceView for preview.
- stopPreview();
- mCameraDevice.setPreviewDisplay(mUI.getSurfaceHolder());
- // The orientation for SurfaceTexture is different from that for
- // SurfaceView. For SurfaceTexture we don't need to consider the
- // display rotation. Just consider the sensor's orientation and we
- // will set the orientation correctly when showing the texture.
- // Gallery will handle the orientation for the preview. For
- // SurfaceView we will have to take everything into account so the
- // display rotation is considered.
- mCameraDevice.setDisplayOrientation(
- CameraUtil.getDisplayOrientation(mDisplayRotation, mCameraId));
- mCameraDevice.startPreview();
- mPreviewing = true;
- mMediaRecorder.setPreviewDisplay(mUI.getSurfaceHolder().getSurface());
- }
}
private int getHighSpeedVideoEncoderBitRate(CamcorderProfile profile, int targetRate) {
int bitRate;
@@ -1683,14 +1636,6 @@
// If the mCameraDevice is null, then this activity is going to finish
if (mCameraDevice == null) return;
- if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
- // Set the SurfaceView to visible so the surface gets created.
- // surfaceCreated() is called immediately when the visibility is
- // changed to visible. Thus, mSurfaceViewReady should become true
- // right after calling setVisibility().
- mUI.showSurfaceView();
- }
-
Intent intent = mActivity.getIntent();
Bundle myExtras = intent.getExtras();
@@ -2207,16 +2152,7 @@
mMediaRecorderPausing = false;
mRecordingStartTime = SystemClock.uptimeMillis();
updateRecordingTime();
- if (!ApiHelper.HAS_RESUME_SUPPORTED){
- mMediaRecorder.start();
- } else {
- try {
- Method resumeRec = Class.forName("android.media.MediaRecorder").getMethod("resume");
- resumeRec.invoke(mMediaRecorder);
- } catch (Exception e) {
- Log.v(TAG, "resume method not implemented");
- }
- }
+ mMediaRecorder.resume();
}
private boolean stopVideoRecording() {
@@ -2283,21 +2219,14 @@
releaseAudioFocus();
if (!mPaused) {
mCameraDevice.lock();
- if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
- stopPreview();
- mUI.hideSurfaceView();
- // Switch back to use SurfaceTexture for preview.
- startPreview();
- } else {
- if (is4KEnabled()) {
- int fps = CameraUtil.getMaxPreviewFps(mParameters);
- if (fps > 0) {
- mParameters.setPreviewFrameRate(fps);
- } else {
- mParameters.setPreviewFrameRate(30);
- }
- mCameraDevice.setParameters(mParameters);
+ if (is4KEnabled()) {
+ int fps = CameraUtil.getMaxPreviewFps(mParameters);
+ if (fps > 0) {
+ mParameters.setPreviewFrameRate(fps);
+ } else {
+ mParameters.setPreviewFrameRate(30);
}
+ mCameraDevice.setParameters(mParameters);
}
}
// Update the parameters here because the parameters might have been altered
diff --git a/src/com/android/camera/app/OrientationManager.java b/src/com/android/camera/app/OrientationManager.java
index 7dcd306..d9b8e46 100644
--- a/src/com/android/camera/app/OrientationManager.java
+++ b/src/com/android/camera/app/OrientationManager.java
@@ -21,13 +21,9 @@
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
-import android.provider.Settings;
-import android.util.Log;
import android.view.OrientationEventListener;
import android.view.Surface;
-import com.android.camera.util.ApiHelper;
-
public class OrientationManager {
private static final String TAG = "CAM_OrientationManager";
diff --git a/src/com/android/camera/ui/CameraRootView.java b/src/com/android/camera/ui/CameraRootView.java
index 42eebaa..e99e1c2 100644
--- a/src/com/android/camera/ui/CameraRootView.java
+++ b/src/com/android/camera/ui/CameraRootView.java
@@ -17,26 +17,16 @@
package com.android.camera.ui;
import android.annotation.SuppressLint;
-import android.app.Activity;
import android.content.Context;
-import android.content.res.Configuration;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.util.AttributeSet;
-import android.view.View;
import android.widget.FrameLayout;
-import com.android.camera.util.ApiHelper;
-import com.android.camera.util.CameraUtil;
-
@SuppressLint("NewApi")
public class CameraRootView extends FrameLayout {
- private int mTopMargin = 0;
- private int mBottomMargin = 0;
- private int mLeftMargin = 0;
- private int mRightMargin = 0;
private final Rect mCurrentInsets = new Rect(0, 0, 0, 0);
private int mOffset = 0;
private Object mDisplayListener;
@@ -74,23 +64,24 @@
}
public void initDisplayListener() {
- if (ApiHelper.HAS_DISPLAY_LISTENER) {
- mDisplayListener = new DisplayListener() {
+ mDisplayListener = new DisplayListener() {
+ @Override
+ public void onDisplayAdded(int arg0) {
+ // empty
+ }
- @Override
- public void onDisplayAdded(int arg0) {}
-
- @Override
- public void onDisplayChanged(int arg0) {
- if (mListener != null) {
- mListener.onDisplayChanged();
- }
+ @Override
+ public void onDisplayChanged(int arg0) {
+ if (mListener != null) {
+ mListener.onDisplayChanged();
}
+ }
- @Override
- public void onDisplayRemoved(int arg0) {}
- };
- }
+ @Override
+ public void onDisplayRemoved(int arg0) {
+ // empty
+ }
+ };
}
public void removeDisplayChangeListener() {
@@ -104,19 +95,15 @@
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
- if (ApiHelper.HAS_DISPLAY_LISTENER) {
- ((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE))
- .registerDisplayListener((DisplayListener) mDisplayListener, null);
- }
+ final DisplayManager displayManager = getContext().getSystemService(DisplayManager.class);
+ displayManager.registerDisplayListener((DisplayListener) mDisplayListener, null);
}
@Override
- public void onDetachedFromWindow () {
+ public void onDetachedFromWindow() {
super.onDetachedFromWindow();
- if (ApiHelper.HAS_DISPLAY_LISTENER) {
- ((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE))
- .unregisterDisplayListener((DisplayListener) mDisplayListener);
- }
+ final DisplayManager displayManager = getContext().getSystemService(DisplayManager.class);
+ displayManager.unregisterDisplayListener((DisplayListener) mDisplayListener);
}
/*
@Override
diff --git a/src/com/android/camera/ui/motion/InterpolatorHelper.java b/src/com/android/camera/ui/motion/InterpolatorHelper.java
index 84114cb..6028660 100644
--- a/src/com/android/camera/ui/motion/InterpolatorHelper.java
+++ b/src/com/android/camera/ui/motion/InterpolatorHelper.java
@@ -18,11 +18,8 @@
import android.content.Context;
import android.view.animation.AnimationUtils;
-import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
-import com.android.camera.util.ApiHelper;
-
public class InterpolatorHelper {
private static Interpolator LINEAR_OUT_SLOW_IN = null;
diff --git a/src/com/android/camera/util/AccessibilityUtils.java b/src/com/android/camera/util/AccessibilityUtils.java
index 543c7ff..8934240 100644
--- a/src/com/android/camera/util/AccessibilityUtils.java
+++ b/src/com/android/camera/util/AccessibilityUtils.java
@@ -1,36 +1,16 @@
package com.android.camera.util;
-import android.content.Context;
-import android.support.v4.view.accessibility.AccessibilityRecordCompat;
import android.view.View;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
/**
* AccessibilityUtils provides functions needed in accessibility mode. All the functions
* in this class are made compatible with gingerbread and later API's
-*/
+ */
public class AccessibilityUtils {
public static void makeAnnouncement(View view, CharSequence announcement) {
- if (view == null)
+ if (view == null) {
return;
- if (ApiHelper.HAS_ANNOUNCE_FOR_ACCESSIBILITY) {
- view.announceForAccessibility(announcement);
- } else {
- // For API 15 and earlier, we need to construct an accessibility event
- Context ctx = view.getContext();
- AccessibilityManager am = (AccessibilityManager) ctx.getSystemService(
- Context.ACCESSIBILITY_SERVICE);
- if (!am.isEnabled()) return;
- AccessibilityEvent event = AccessibilityEvent.obtain(
- AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
- AccessibilityRecordCompat arc = new AccessibilityRecordCompat(event);
- arc.setSource(view);
- event.setClassName(view.getClass().getName());
- event.setPackageName(view.getContext().getPackageName());
- event.setEnabled(view.isEnabled());
- event.getText().add(announcement);
- am.sendAccessibilityEvent(event);
}
+ view.announceForAccessibility(announcement);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/camera/util/ApiHelper.java b/src/com/android/camera/util/ApiHelper.java
deleted file mode 100755
index 2812a97..0000000
--- a/src/com/android/camera/util/ApiHelper.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.util;
-
-import android.os.Build;
-
-import java.lang.reflect.Field;
-
-public class ApiHelper {
- public static final boolean AT_LEAST_16 = Build.VERSION.SDK_INT >= 16;
-
- public static final boolean HAS_APP_GALLERY =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1;
-
- public static final boolean HAS_ANNOUNCE_FOR_ACCESSIBILITY =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
- public static final boolean HAS_AUTO_FOCUS_MOVE_CALLBACK =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
- public static final boolean HAS_MEDIA_ACTION_SOUND =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
- public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
- public static final boolean HAS_SET_BEAM_PUSH_URIS =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
- public static final boolean HAS_SURFACE_TEXTURE_RECORDING =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
-
- public static final boolean HAS_CAMERA_HDR_PLUS = isKitKatOrHigher();
- public static final boolean HAS_CAMERA_HDR =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
- public static final boolean HAS_DISPLAY_LISTENER =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
-
- public static final boolean HAS_ORIENTATION_LOCK =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
- public static final boolean HAS_ROTATION_ANIMATION =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
- public static final boolean HAS_FINE_RESOLUTION_QUALITY_LEVELS =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
- public static final boolean HAS_HIDEYBARS = isKitKatOrHigher();
-
- public static final boolean HAS_RESUME_SUPPORTED =
- Build.VERSION.SDK_INT > Build.VERSION_CODES.M;
-
- public static int getIntFieldIfExists(Class<?> klass, String fieldName,
- Class<?> obj, int defaultVal) {
- try {
- Field f = klass.getDeclaredField(fieldName);
- return f.getInt(obj);
- } catch (Exception e) {
- return defaultVal;
- }
- }
-
- public static boolean isKitKatOrHigher() {
- // TODO: Remove CODENAME check as soon as VERSION_CODES.KITKAT is final.
- return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
- || "KeyLimePie".equals(Build.VERSION.CODENAME);
- }
-
- public static boolean isAndroidPOrHigher() {
- return Build.VERSION.SDK_INT >= 28;
- }
-}
diff --git a/src/com/android/camera/util/SettingTranslation.java b/src/com/android/camera/util/SettingTranslation.java
index 4fd9952..c27c066 100644
--- a/src/com/android/camera/util/SettingTranslation.java
+++ b/src/com/android/camera/util/SettingTranslation.java
@@ -46,13 +46,7 @@
VIDEO_ENCODER_TABLE.put("default", MediaRecorder.VideoEncoder.DEFAULT);
VIDEO_ENCODER_TABLE.put("h263", MediaRecorder.VideoEncoder.H263);
VIDEO_ENCODER_TABLE.put("h264", MediaRecorder.VideoEncoder.H264);
- int h265 = ApiHelper.getIntFieldIfExists(MediaRecorder.VideoEncoder.class,
- "HEVC", null, MediaRecorder.VideoEncoder.DEFAULT);
- if (h265 == MediaRecorder.VideoEncoder.DEFAULT) {
- h265 = ApiHelper.getIntFieldIfExists(MediaRecorder.VideoEncoder.class,
- "H265", null, MediaRecorder.VideoEncoder.DEFAULT);
- }
- VIDEO_ENCODER_TABLE.put("h265", h265);
+ VIDEO_ENCODER_TABLE.put("h265", MediaRecorder.VideoEncoder.HEVC);
VIDEO_ENCODER_TABLE.put("mpeg-4-sp", MediaRecorder.VideoEncoder.MPEG_4_SP);
VIDEO_ENCODER_TABLE.put("vp8", MediaRecorder.VideoEncoder.VP8);