summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2016-04-19 22:38:36 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-04-19 22:38:36 +0000
commita571ae23c1f05a7f7ed3c9487addce10a29def32 (patch)
treef29ab9748b97187d6c39b73ac6e6ab01b5cf6117
parentb7f7ab7de0f702b716f61a5bb792050232956e91 (diff)
parent3651aa3f8296eae150590b765fda1d87f49fb5b6 (diff)
downloadDevCamera-a571ae23c1f05a7f7ed3c9487addce10a29def32.tar.gz
Fix DevCamera name and many other things
am: 3651aa3 * commit '3651aa3f8296eae150590b765fda1d87f49fb5b6': Fix DevCamera name and many other things Change-Id: I1825387b2533df006a810426390a1d5a8c7ed90c
-rw-r--r--Android.mk18
-rw-r--r--AndroidManifest.xml19
-rw-r--r--res/drawable-hdpi/ic_launcher.pngbin5115 -> 0 bytes
-rw-r--r--res/drawable-mdpi/ic_launcher.pngbin5115 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/ic_launcher.pngbin5115 -> 0 bytes
-rw-r--r--res/layout/activity_main.xml4
-rw-r--r--res/mipmap-hdpi/logo_devcamera_color_44in48dp.pngbin0 -> 6092 bytes
-rw-r--r--res/mipmap-mdpi/logo_devcamera_color_44in48dp.pngbin0 -> 3318 bytes
-rw-r--r--res/mipmap-xhdpi/logo_devcamera_color_44in48dp.pngbin0 -> 7105 bytes
-rw-r--r--res/mipmap-xxhdpi/logo_devcamera_color_44in48dp.pngbin0 -> 13987 bytes
-rw-r--r--res/mipmap-xxxhdpi/logo_devcamera_color_44in48dp.pngbin0 -> 8577 bytes
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/android/devcamera/Api2Camera.java (renamed from src/com/google/snappy/MyApi2Camera.java)55
-rw-r--r--src/com/android/devcamera/BitmapUtility.java (renamed from src/com/google/snappy/BitmapUtility.java)17
-rw-r--r--src/com/android/devcamera/CameraDeviceReport.java (renamed from src/com/google/snappy/MyDeviceReport.java)25
-rw-r--r--src/com/android/devcamera/CameraInfoCache.java (renamed from src/com/google/snappy/CameraInfoCache.java)25
-rw-r--r--src/com/android/devcamera/CameraInterface.java (renamed from src/com/google/snappy/MyCameraInterface.java)19
-rw-r--r--src/com/android/devcamera/CameraTimer.java33
-rw-r--r--src/com/android/devcamera/DevCameraActivity.java (renamed from src/com/google/snappy/MainActivity.java)189
-rw-r--r--src/com/android/devcamera/GyroListener.java22
-rw-r--r--src/com/android/devcamera/GyroOperations.java (renamed from src/com/google/snappy/GyroOperations.java)21
-rw-r--r--src/com/android/devcamera/LoggingCallbacks.java (renamed from src/com/google/snappy/MyLoggingCallbacks.java)23
-rw-r--r--src/com/android/devcamera/MediaSaver.java (renamed from src/com/google/snappy/MediaSaver.java)17
-rw-r--r--src/com/android/devcamera/NormalizedFace.java (renamed from src/com/google/snappy/NormalizedFace.java)18
-rw-r--r--src/com/android/devcamera/PreviewOverlay.java (renamed from src/com/google/snappy/PreviewOverlay.java)25
-rw-r--r--src/com/google/snappy/GyroListener.java10
-rw-r--r--src/com/google/snappy/MyTimer.java18
27 files changed, 403 insertions, 158 deletions
diff --git a/Android.mk b/Android.mk
index 256ce47..6433b95 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2013 The Android Open Source Project
+# Copyright (C) 2016 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.
@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-ifeq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),platform)
-
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
@@ -21,20 +19,10 @@ include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SDK_VERSION := current
-# LOCAL_SDK_VERSION := 19
-
-#LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2
LOCAL_SRC_FILES := \
- $(call all-java-files-under, src) \
- $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := Snappy
+ $(call all-java-files-under, src)
-LOCAL_AAPT_FLAGS += --rename-manifest-package com.google.Snappy2
-
-LOCAL_JACK_ENABLED := disabled
+LOCAL_PACKAGE_NAME := DevCamera
include $(BUILD_PACKAGE)
-
-endif
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d9904ed..967f76e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,31 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.google.snappy"
+ package="com.android.devcamera"
android:versionCode="1"
android:versionName="1.0" >
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-feature android:name="android.hardware.camera" />
- <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
- <uses-feature android:name="android.hardware.camera.front" android:required="false"/>
- <uses-sdk
- android:minSdkVersion="21" android:targetSdkVersion="21"
- />
+ <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="23" />
+ <uses-feature android:name="android.hardware.camera.any" />
+ <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
+ android:icon="@mipmap/logo_devcamera_color_44in48dp"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
android:label="@string/app_name" >
<activity
android:screenOrientation="portrait"
- android:name="com.google.snappy.MainActivity">
+ android:name=".DevCameraActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -34,6 +30,3 @@
</application>
</manifest>
-
-<!---android:targetSdkVersion="20"-->
-
diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 16dfd55..0000000
--- a/res/drawable-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 16dfd55..0000000
--- a/res/drawable-mdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 16dfd55..0000000
--- a/res/drawable-xhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
index c54786f..6d15ca6 100644
--- a/res/layout/activity_main.xml
+++ b/res/layout/activity_main.xml
@@ -20,7 +20,7 @@
android:layout_height="fill_parent"
android:background="#FF000000" />
- <com.google.snappy.PreviewOverlay
+ <com.android.devcamera.PreviewOverlay
android:id="@+id/preview_overlay_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
@@ -229,4 +229,4 @@
</HorizontalScrollView>
-</LinearLayout> \ No newline at end of file
+</LinearLayout>
diff --git a/res/mipmap-hdpi/logo_devcamera_color_44in48dp.png b/res/mipmap-hdpi/logo_devcamera_color_44in48dp.png
new file mode 100644
index 0000000..5c8b8aa
--- /dev/null
+++ b/res/mipmap-hdpi/logo_devcamera_color_44in48dp.png
Binary files differ
diff --git a/res/mipmap-mdpi/logo_devcamera_color_44in48dp.png b/res/mipmap-mdpi/logo_devcamera_color_44in48dp.png
new file mode 100644
index 0000000..29d6047
--- /dev/null
+++ b/res/mipmap-mdpi/logo_devcamera_color_44in48dp.png
Binary files differ
diff --git a/res/mipmap-xhdpi/logo_devcamera_color_44in48dp.png b/res/mipmap-xhdpi/logo_devcamera_color_44in48dp.png
new file mode 100644
index 0000000..78b3406
--- /dev/null
+++ b/res/mipmap-xhdpi/logo_devcamera_color_44in48dp.png
Binary files differ
diff --git a/res/mipmap-xxhdpi/logo_devcamera_color_44in48dp.png b/res/mipmap-xxhdpi/logo_devcamera_color_44in48dp.png
new file mode 100644
index 0000000..85a2169
--- /dev/null
+++ b/res/mipmap-xxhdpi/logo_devcamera_color_44in48dp.png
Binary files differ
diff --git a/res/mipmap-xxxhdpi/logo_devcamera_color_44in48dp.png b/res/mipmap-xxxhdpi/logo_devcamera_color_44in48dp.png
new file mode 100644
index 0000000..acf86ed
--- /dev/null
+++ b/res/mipmap-xxxhdpi/logo_devcamera_color_44in48dp.png
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cf216cf..b91721a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">Snappy2</string>
+ <string name="app_name">DevCamera</string>
<string name="action_settings">Settings</string>
- <string name="hello_world">This is a snappy app!</string>
<string name="jpeg_capture">JPEG</string>
<string name="aftrig">AF trig</string>
<string name="nr_unknown">NR --</string>
diff --git a/src/com/google/snappy/MyApi2Camera.java b/src/com/android/devcamera/Api2Camera.java
index 8f2f306..1c61cb0 100644
--- a/src/com/google/snappy/MyApi2Camera.java
+++ b/src/com/android/devcamera/Api2Camera.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.content.Context;
import android.graphics.ImageFormat;
@@ -35,7 +50,7 @@ import javax.microedition.khronos.opengles.GL10;
/**
- * MyApi2Camera : a camera2 implementation
+ * Api2Camera : a camera2 implementation
*
* The goal here is to make the simplest possible API2 camera,
* where individual streams and capture options (e.g. edge enhancement,
@@ -43,8 +58,8 @@ import javax.microedition.khronos.opengles.GL10;
*
*/
-public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAvailableListener {
- private static final String TAG = "SNAPPY_API2";
+public class Api2Camera implements CameraInterface, SurfaceTexture.OnFrameAvailableListener {
+ private static final String TAG = "DevCamera_API2";
// Nth frame to log; put 10^6 if you don't want logging.
private static int LOG_NTH_FRAME = 30;
@@ -113,7 +128,7 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
/**
* Constructor.
*/
- public MyApi2Camera(Context context, boolean useFrontCamera) {
+ public Api2Camera(Context context, boolean useFrontCamera) {
mContext = context;
mCameraIsFront = useFrontCamera;
mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
@@ -286,7 +301,7 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
mOpsHandler.post(new Runnable() {
@Override
public void run() {
- MyTimer.t_open_start = SystemClock.elapsedRealtime();
+ CameraTimer.t_open_start = SystemClock.elapsedRealtime();
try {
mCameraManager.openCamera(mCameraInfoCache.getCameraId(), mCameraStateCallback, null);
} catch (CameraAccessException e) {
@@ -318,13 +333,13 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
tryToStartCaptureSession();
}
- private CameraDevice.StateCallback mCameraStateCallback = new MyLoggingCallbacks.DeviceStateCallback() {
+ private CameraDevice.StateCallback mCameraStateCallback = new LoggingCallbacks.DeviceStateCallback() {
@Override
public void onOpened(CameraDevice camera) {
- MyTimer.t_open_end = SystemClock.elapsedRealtime();
+ CameraTimer.t_open_end = SystemClock.elapsedRealtime();
mCameraDevice = camera;
Log.v(TAG, "STARTUP_REQUIREMENT Done opening camera " + mCameraInfoCache.getCameraId() +
- ". HAL open took: (" + (MyTimer.t_open_end - MyTimer.t_open_start) + " ms)");
+ ". HAL open took: (" + (CameraTimer.t_open_end - CameraTimer.t_open_start) + " ms)");
super.onOpened(camera);
tryToStartCaptureSession();
@@ -345,7 +360,7 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
// Create CameraCaptureSession. Callback will start repeating request with current parameters.
private void startCaptureSession() {
- MyTimer.t_session_go = SystemClock.elapsedRealtime();
+ CameraTimer.t_session_go = SystemClock.elapsedRealtime();
Log.v(TAG, "Configuring session..");
List<Surface> outputSurfaces = new ArrayList<Surface>(3);
@@ -400,10 +415,10 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
ImageWriter mImageWriter;
- private CameraCaptureSession.StateCallback mSessionStateCallback = new MyLoggingCallbacks.SessionStateCallback() {
+ private CameraCaptureSession.StateCallback mSessionStateCallback = new LoggingCallbacks.SessionStateCallback() {
@Override
public void onReady(CameraCaptureSession session) {
- Log.v(TAG, "capture session onReady(). HAL capture session took: (" + (SystemClock.elapsedRealtime() - MyTimer.t_session_go) + " ms)");
+ Log.v(TAG, "capture session onReady(). HAL capture session took: (" + (SystemClock.elapsedRealtime() - CameraTimer.t_session_go) + " ms)");
mCurrentCaptureSession = session;
issuePreviewCaptureRequest(false);
@@ -469,7 +484,7 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
}
public void issuePreviewCaptureRequest(boolean AFtrigger) {
- MyTimer.t_burst = SystemClock.elapsedRealtime();
+ CameraTimer.t_burst = SystemClock.elapsedRealtime();
Log.v(TAG, "issuePreviewCaptureRequest...");
try {
CaptureRequest.Builder b1 = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
@@ -632,7 +647,7 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
final ByteBuffer buffer = plane0.getBuffer();
Log.v(TAG, "Raw buffer available, Frame #=" + mRawImageCounter + "w=" + img.getWidth()
+ " h=" + img.getHeight()
- + " format=" + MyDeviceReport.getFormatName(img.getFormat())
+ + " format=" + CameraDeviceReport.getFormatName(img.getFormat())
+ " time=" + img.getTimestamp()
+ " size=" + buffer.capacity()
+ " getRowStride()=" + plane0.getRowStride());
@@ -646,15 +661,15 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
* CaptureResult metadata processing *
*************************************/
- private CameraCaptureSession.CaptureCallback mCaptureCallback = new MyLoggingCallbacks.SessionCaptureCallback() {
+ private CameraCaptureSession.CaptureCallback mCaptureCallback = new LoggingCallbacks.SessionCaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
if (!mFirstFrameArrived) {
mFirstFrameArrived = true;
long now = SystemClock.elapsedRealtime();
- long dt = now - MyTimer.t0;
- long camera_dt = now - MyTimer.t_session_go + MyTimer.t_open_end - MyTimer.t_open_start;
- long repeating_req_dt = now - MyTimer.t_burst;
+ long dt = now - CameraTimer.t0;
+ long camera_dt = now - CameraTimer.t_session_go + CameraTimer.t_open_end - CameraTimer.t_open_start;
+ long repeating_req_dt = now - CameraTimer.t_burst;
Log.v(TAG, "App control to first frame: (" + dt + " ms)");
Log.v(TAG, "HAL request to first frame: (" + repeating_req_dt + " ms) " + " Total HAL wait: (" + camera_dt + " ms)");
mMyCameraCallback.receivedFirstFrame();
@@ -668,7 +683,7 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
};
// Reprocessing capture completed.
- private CameraCaptureSession.CaptureCallback mReprocessingCaptureCallback = new MyLoggingCallbacks.SessionCaptureCallback() {
+ private CameraCaptureSession.CaptureCallback mReprocessingCaptureCallback = new LoggingCallbacks.SessionCaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
Log.v(TAG, "Reprocessing onCaptureCompleted()");
@@ -790,4 +805,4 @@ public class MyApi2Camera implements MyCameraInterface, SurfaceTexture.OnFrameAv
}
return Integer.toString(mode);
}
-} \ No newline at end of file
+}
diff --git a/src/com/google/snappy/BitmapUtility.java b/src/com/android/devcamera/BitmapUtility.java
index 682bcaa..683b6a7 100644
--- a/src/com/google/snappy/BitmapUtility.java
+++ b/src/com/android/devcamera/BitmapUtility.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
diff --git a/src/com/google/snappy/MyDeviceReport.java b/src/com/android/devcamera/CameraDeviceReport.java
index 2505d30..ebd96ed 100644
--- a/src/com/google/snappy/MyDeviceReport.java
+++ b/src/com/android/devcamera/CameraDeviceReport.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.app.Activity;
import android.content.Context;
@@ -20,12 +35,8 @@ import android.util.SizeF;
import android.view.SurfaceHolder;
import android.view.WindowManager;
-/**
- * Created by andyhuibers on 6/24/14.
- */
-
-public class MyDeviceReport {
- private static final String TAG = "SNAPPY_INFO";
+public class CameraDeviceReport {
+ private static final String TAG = "DevCamera_INFO";
// Note: we actually need the activity to get window information
public static void printReport(Activity activity, boolean firstCameraOnly) {
diff --git a/src/com/google/snappy/CameraInfoCache.java b/src/com/android/devcamera/CameraInfoCache.java
index 9de5464..03d27a4 100644
--- a/src/com/google/snappy/CameraInfoCache.java
+++ b/src/com/android/devcamera/CameraInfoCache.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.graphics.ImageFormat;
import android.graphics.Rect;
@@ -16,7 +31,7 @@ import android.util.Size;
*/
public class CameraInfoCache {
- private static final String TAG = "SNAPPY_CAMINFO";
+ private static final String TAG = "DevCamera_CAMINFO";
public static final boolean IS_NEXUS_5 = "hammerhead".equalsIgnoreCase(Build.DEVICE);
public static final boolean IS_NEXUS_6 = "shamu".equalsIgnoreCase(Build.DEVICE);
@@ -100,8 +115,10 @@ public class CameraInfoCache {
noiseModes = mCameraCharacteristics.get(CameraCharacteristics.NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES);
// Misc stuff.
- mCamera2FullModeAvailable = mCameraCharacteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL) ==
- CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL;
+ int hwLevel = mCameraCharacteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+
+ mCamera2FullModeAvailable = (hwLevel != CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY)
+ && (hwLevel >= CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
mSensorOrientation = mCameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
}
diff --git a/src/com/google/snappy/MyCameraInterface.java b/src/com/android/devcamera/CameraInterface.java
index d6a1be7..61c1a63 100644
--- a/src/com/google/snappy/MyCameraInterface.java
+++ b/src/com/android/devcamera/CameraInterface.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.util.Size;
import android.view.Surface;
@@ -6,7 +21,7 @@ import android.view.Surface;
/**
* This is a simple camera interface not specific to API1 or API2.
*/
-public interface MyCameraInterface {
+public interface CameraInterface {
/**
* Return preview size to use pass thru from camera API.
*/
diff --git a/src/com/android/devcamera/CameraTimer.java b/src/com/android/devcamera/CameraTimer.java
new file mode 100644
index 0000000..1ecac50
--- /dev/null
+++ b/src/com/android/devcamera/CameraTimer.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 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.devcamera;
+
+/**
+ * A global spot to store some times.
+ */
+public class CameraTimer {
+ // Got control in onCreate()
+ public static long t0;
+ // Sent open() to camera.
+ public static long t_open_start;
+ // Open from camera done.
+ public static long t_open_end;
+ // Told camera to configure capture session.
+ public static long t_session_go;
+ // Told session to do repeating request.
+ public static long t_burst;
+
+}
diff --git a/src/com/google/snappy/MainActivity.java b/src/com/android/devcamera/DevCameraActivity.java
index 63704aa..fe49a3a 100644
--- a/src/com/google/snappy/MainActivity.java
+++ b/src/com/android/devcamera/DevCameraActivity.java
@@ -1,7 +1,25 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
+import android.Manifest;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.graphics.Color;
+import android.hardware.camera2.CaptureResult;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.app.Activity;
@@ -28,14 +46,17 @@ import android.widget.ToggleButton;
* A minimum camera app.
* To keep it simple: portrait mode only.
*/
-public class MainActivity extends Activity implements MyCameraInterface.MyCameraCallback, SurfaceHolder.Callback {
- private static final String TAG = "SNAPPY_UI";
+public class DevCameraActivity extends Activity implements CameraInterface.MyCameraCallback, SurfaceHolder.Callback {
+ private static final String TAG = "DevCamera_UI";
private static final boolean LOG_FRAME_DATA = false;
private static final int AF_TRIGGER_HOLD_MILLIS = 4000;
private static final boolean STARTUP_FULL_YUV_ON = true;
private static final boolean START_WITH_FRONT_CAMERA = false;
+ private static final int PERMISSIONS_REQUEST_CAMERA = 1;
+ private boolean mPermissionCheckActive = false;
+
private SurfaceView mPreviewView;
private SurfaceHolder mPreviewHolder;
private PreviewOverlay mPreviewOverlay;
@@ -58,7 +79,7 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
private ToggleButton mToggleSaveSdCard;
private LinearLayout mReprocessingGroup;
private Handler mMainHandler;
- private MyCameraInterface mCamera;
+ private CameraInterface mCamera;
// Used for saving JPEGs.
private HandlerThread mUtilityThread;
@@ -71,7 +92,7 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
// set capture flow.
if (view == mToggleYuvFull || view == mToggleYuvVga || view == mToggleRaw ||
view == mButtonNoiseMode || view == mButtonEdgeMode || view == mToggleFace || view == null)
- mCamera.setCaptureFlow(
+ mCamera.setCaptureFlow(
mToggleYuvFull.isChecked(),
mToggleYuvVga.isChecked(),
mToggleRaw.isChecked(),
@@ -113,10 +134,12 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.v(TAG, "onCreate");
- MyTimer.t0 = SystemClock.elapsedRealtime();
+ CameraTimer.t0 = SystemClock.elapsedRealtime();
- // Go speed racer.
- openCamera(START_WITH_FRONT_CAMERA);
+ if (checkPermissions()) {
+ // Go speed racer.
+ openCamera(START_WITH_FRONT_CAMERA);
+ }
// Initialize UI.
setContentView(R.layout.activity_main);
@@ -173,7 +196,7 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
@Override
public void onClick(View view) {
Log.v(TAG, "switchCamera()");
- MyTimer.t0 = SystemClock.elapsedRealtime();
+ CameraTimer.t0 = SystemClock.elapsedRealtime();
// ToggleButton isChecked state will determine which camera is started.
openCamera(mToggleFrontCam.isChecked());
startCamera();
@@ -195,16 +218,13 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
mMainHandler = new Handler(this.getApplicationContext().getMainLooper());
- // Can start camera now that we have the above initialized.
- startCamera();
-
// General utility thread for e.g. saving JPEGs.
mUtilityThread = new HandlerThread("UtilityThread");
mUtilityThread.start();
mUtilityHandler = new Handler(mUtilityThread.getLooper());
// --- PRINT REPORT ---
- //MyDeviceReport.printReport(this, false);
+ //CameraDeviceReport.printReport(this, false);
super.onCreate(savedInstanceState);
}
@@ -215,7 +235,7 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
mCamera.closeCamera();
}
// --- SET UP CAMERA ---
- mCamera = new MyApi2Camera(this, frontCamera);
+ mCamera = new Api2Camera(this, frontCamera);
mCamera.setCallback(this);
mCamera.openCamera();
}
@@ -253,8 +273,10 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
@Override
public synchronized void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Log.v(TAG, String.format("surfaceChanged: format=%x w=%d h=%d", format, width, height));
- mPreviewSurfaceValid = true;
- mCamera.startPreview(mPreviewHolder.getSurface());
+ if (checkPermissions()) {
+ mPreviewSurfaceValid = true;
+ mCamera.startPreview(mPreviewHolder.getSurface());
+ }
}
Runnable mReturnToCafRunnable = new Runnable() {
@@ -283,24 +305,75 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
}
@Override
- public void onResume() {
- Log.v(TAG, "onResume");
- super.onResume();
+ public void onStart() {
+ Log.v(TAG, "onStart");
+ super.onStart();
// Leave screen on.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+
+ if (!checkPermissions()) return;
+
+ // Can start camera now that we have the above initialized.
+ if (mCamera == null) {
+ openCamera(mToggleFrontCam.isChecked());
+ }
+ startCamera();
+ }
+
+ private boolean checkPermissions() {
+ if (mPermissionCheckActive) return false;
+
+ // Check for all runtime permissions
+ if ((checkSelfPermission(Manifest.permission.CAMERA)
+ != PackageManager.PERMISSION_GRANTED )
+ || (checkSelfPermission(Manifest.permission.RECORD_AUDIO)
+ != PackageManager.PERMISSION_GRANTED)
+ || (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
+ != PackageManager.PERMISSION_GRANTED)) {
+ Log.i(TAG, "Requested camera/video permissions");
+ requestPermissions(new String[] {
+ Manifest.permission.CAMERA,
+ Manifest.permission.RECORD_AUDIO,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE},
+ PERMISSIONS_REQUEST_CAMERA);
+ mPermissionCheckActive = true;
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions,
+ int[] grantResults) {
+ mPermissionCheckActive = false;
+ if (requestCode == PERMISSIONS_REQUEST_CAMERA) {
+ for (int i = 0; i < grantResults.length; i++) {
+ if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
+ Log.i(TAG, "At least one permission denied, can't continue: " + permissions[i]);
+ finish();
+ return;
+ }
+ }
+
+ Log.i(TAG, "All permissions granted");
+ openCamera(mToggleFrontCam.isChecked());
+ startCamera();
+ }
}
@Override
- public void onPause() {
- Log.v(TAG, "onPause");
- mCamera.closeCamera();
+ public void onStop() {
+ Log.v(TAG, "onStop");
+ if (mCamera != null) {
+ mCamera.closeCamera();
+ mCamera = null;
+ }
// Cancel any pending AF operations.
mMainHandler.removeCallbacks(mReturnToCafRunnable);
stopGyroDisplay(); // No-op if not running.
- super.onPause();
- // Close app.
- finish();
+ super.onStop();
}
public void noCamera2Full() {
@@ -395,9 +468,9 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
}
});
// Build info string.
- String ae = aeModeToString(aeState);
- String af = afModeToString(afState);
- String awb = awbModeToString(awbState);
+ String ae = aeStateToString(aeState);
+ String af = afStateToString(afState);
+ String awb = awbStateToString(awbState);
final String info = String.format(" %2.0f FPS%5d ISO AF:%s AE:%s AWB:%s", fps, iso, af, ae, awb);
mLastInfo = info;
@@ -513,33 +586,59 @@ public class MainActivity extends Activity implements MyCameraInterface.MyCamera
* UTILITY FUNCTIONS *
*********************/
- private static String awbModeToString(int mode) {
+ private static String awbStateToString(int mode) {
switch (mode) {
- case 1:
- return "scan";
- case 2:
+ case CaptureResult.CONTROL_AWB_STATE_INACTIVE:
+ return "inactive";
+ case CaptureResult.CONTROL_AWB_STATE_SEARCHING:
+ return "searching";
+ case CaptureResult.CONTROL_AWB_STATE_CONVERGED:
+ return "converged";
+ case CaptureResult.CONTROL_AWB_STATE_LOCKED:
return "lock";
+ default:
+ return "unknown " + Integer.toString(mode);
}
- return Integer.toString(mode);
}
- private static String aeModeToString(int mode) {
+ private static String aeStateToString(int mode) {
switch (mode) {
- case 1:
- return "scan";
- case 2:
+ case CaptureResult.CONTROL_AE_STATE_INACTIVE:
+ return "inactive";
+ case CaptureResult.CONTROL_AE_STATE_SEARCHING:
+ return "searching";
+ case CaptureResult.CONTROL_AE_STATE_PRECAPTURE:
+ return "precapture";
+ case CaptureResult.CONTROL_AE_STATE_CONVERGED:
+ return "converged";
+ case CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED:
+ return "flashReq";
+ case CaptureResult.CONTROL_AE_STATE_LOCKED:
return "lock";
+ default:
+ return "unknown " + Integer.toString(mode);
}
- return Integer.toString(mode);
}
- private static String afModeToString(int mode) {
- /* switch (mode) {
- case 1: return "scan";
- case 2: return "good";
- case 6: return "bad";
- } */
- return Integer.toString(mode);
+ private static String afStateToString(int mode) {
+ switch (mode) {
+ case CaptureResult.CONTROL_AF_STATE_INACTIVE:
+ return "inactive";
+ case CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN:
+ return "passiveScan";
+ case CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED:
+ return "passiveFocused";
+ case CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED:
+ return "passiveUnfocused";
+ case CaptureResult.CONTROL_AF_STATE_ACTIVE_SCAN:
+ return "activeScan";
+ case CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED:
+ return "focusedLock";
+ case CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED:
+ return "notFocusedLock";
+ default:
+ return "unknown" + Integer.toString(mode);
+ }
}
}
diff --git a/src/com/android/devcamera/GyroListener.java b/src/com/android/devcamera/GyroListener.java
new file mode 100644
index 0000000..cdc1888
--- /dev/null
+++ b/src/com/android/devcamera/GyroListener.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2016 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.devcamera;
+
+public interface GyroListener {
+
+ void updateGyroAngles(float[] gyroAngles);
+
+}
diff --git a/src/com/google/snappy/GyroOperations.java b/src/com/android/devcamera/GyroOperations.java
index a3326bb..a89eafb 100644
--- a/src/com/google/snappy/GyroOperations.java
+++ b/src/com/android/devcamera/GyroOperations.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
@@ -9,12 +24,10 @@ import android.util.Log;
import java.util.ArrayDeque;
/**
- * Created by andyhuibers on 7/21/15.
- *
* Put all the Gyro stuff here.
*/
public class GyroOperations {
- private static final String TAG = "SNAPPY_GYRO";
+ private static final String TAG = "DevCamera_GYRO";
private SensorManager mSensorManager;
private GyroListener mListener;
diff --git a/src/com/google/snappy/MyLoggingCallbacks.java b/src/com/android/devcamera/LoggingCallbacks.java
index d95e635..0644699 100644
--- a/src/com/google/snappy/MyLoggingCallbacks.java
+++ b/src/com/android/devcamera/LoggingCallbacks.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraDevice;
@@ -11,11 +26,11 @@ import android.util.Log;
/**
* Static utility class that logs various camera2 callbacks.
*
- * The only reason this exists as a separate class is void cluttering up MyApi2Camera.
+ * The only reason this exists as a separate class is void cluttering up Api2Camera.
*/
-public class MyLoggingCallbacks {
- private static final String TAG = "SNAPPY_LOG2";
+public class LoggingCallbacks {
+ private static final String TAG = "DevCamera_LOG2";
private static final Boolean LOG_EVERY_FRAME = false;
private static final Boolean LOG_NON_ERRORS = false;
diff --git a/src/com/google/snappy/MediaSaver.java b/src/com/android/devcamera/MediaSaver.java
index 1cf04e4..4929e33 100644
--- a/src/com/google/snappy/MediaSaver.java
+++ b/src/com/android/devcamera/MediaSaver.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.content.ContentResolver;
import android.content.ContentValues;
diff --git a/src/com/google/snappy/NormalizedFace.java b/src/com/android/devcamera/NormalizedFace.java
index 42d890c..546fe12 100644
--- a/src/com/google/snappy/NormalizedFace.java
+++ b/src/com/android/devcamera/NormalizedFace.java
@@ -1,11 +1,25 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.graphics.PointF;
import android.graphics.RectF;
import android.hardware.camera2.params.Face;
/**
- * Created by andyhuibers on 7/7/15.
*
* Face coordinates. Normalized 0 to 1, and in native sensor orientation, which so far seems to be
* landscape.
diff --git a/src/com/google/snappy/PreviewOverlay.java b/src/com/android/devcamera/PreviewOverlay.java
index 803d824..dff60e9 100644
--- a/src/com/google/snappy/PreviewOverlay.java
+++ b/src/com/android/devcamera/PreviewOverlay.java
@@ -1,4 +1,19 @@
-package com.google.snappy;
+/*
+ * Copyright (C) 2016 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.devcamera;
import android.content.Context;
import android.content.res.Resources;
@@ -9,12 +24,8 @@ import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
-/**
- * Created by andyhuibers on 9/18/14.
- */
-
public class PreviewOverlay extends View {
- private static final String TAG = "SNAPPY_FACE";
+ private static final String TAG = "DevCamera_FACE";
private boolean mShow3AInfo;
private boolean mShowGyroGrid;
@@ -212,5 +223,3 @@ public class PreviewOverlay extends View {
super.onDraw(canvas);
}
}
-
-
diff --git a/src/com/google/snappy/GyroListener.java b/src/com/google/snappy/GyroListener.java
deleted file mode 100644
index 2d70a06..0000000
--- a/src/com/google/snappy/GyroListener.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.google.snappy;
-
-/**
- * Created by andyhuibers on 7/21/15.
- */
-public interface GyroListener {
-
- void updateGyroAngles(float[] gyroAngles);
-
-}
diff --git a/src/com/google/snappy/MyTimer.java b/src/com/google/snappy/MyTimer.java
deleted file mode 100644
index 1460037..0000000
--- a/src/com/google/snappy/MyTimer.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.google.snappy;
-
-/**
- * A global spot to store some times.
- */
-public class MyTimer {
- // Got control in onCreate()
- public static long t0;
- // Sent open() to camera.
- public static long t_open_start;
- // Open from camera done.
- public static long t_open_end;
- // Told camera to configure capture session.
- public static long t_session_go;
- // Told session to do repeating request.
- public static long t_burst;
-
-}