summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiawen Chen <jiawen@google.com>2015-04-17 14:20:08 -0700
committerEino-Ville Talvala <etalvala@google.com>2015-04-29 00:09:23 +0000
commit046ba28a082f30d56a1ac63eaa13b5cf95093db6 (patch)
tree71951e62045ffd3ca906f5476e2725258f926d1b
parentb96c229bdb5f4eab9f2f9e593e72f28626c7d4e3 (diff)
downloadandroid_frameworks_ex-046ba28a082f30d56a1ac63eaa13b5cf95093db6.tar.gz
android_frameworks_ex-046ba28a082f30d56a1ac63eaa13b5cf95093db6.tar.bz2
android_frameworks_ex-046ba28a082f30d56a1ac63eaa13b5cf95093db6.zip
DO NOT MERGE: Minor style fixes.
- BlockingCameraManager had the wrong TAG. - Added static / final to NUM_STATES. - Javadoc @param mismatch. Change-Id: I0dbe6b3d4bdcb5a51ba0aea89985c3495a59381e (cherry picked from commit 5a772174d14175474e76701b07cc0be86c3df32a)
-rw-r--r--camera2/public/src/com/android/ex/camera2/blocking/BlockingCameraManager.java14
-rw-r--r--camera2/public/src/com/android/ex/camera2/blocking/BlockingSessionCallback.java14
-rw-r--r--camera2/public/src/com/android/ex/camera2/blocking/BlockingStateCallback.java32
-rw-r--r--camera2/public/src/com/android/ex/camera2/utils/StateChangeListener.java2
-rw-r--r--camera2/public/src/com/android/ex/camera2/utils/StateWaiter.java4
5 files changed, 41 insertions, 25 deletions
diff --git a/camera2/public/src/com/android/ex/camera2/blocking/BlockingCameraManager.java b/camera2/public/src/com/android/ex/camera2/blocking/BlockingCameraManager.java
index 407a08a..f1626d6 100644
--- a/camera2/public/src/com/android/ex/camera2/blocking/BlockingCameraManager.java
+++ b/camera2/public/src/com/android/ex/camera2/blocking/BlockingCameraManager.java
@@ -34,21 +34,21 @@ import java.util.Objects;
* duplicate any functionality that is already blocking.</p>
*
* <p>Be careful when using this from UI thread! This function will typically block
- * for about 500ms when successful, and as long as {@value #OPEN_TIME_OUT}ms when timing out.</p>
+ * for about 500ms when successful, and as long as {@value #OPEN_TIME_OUT_MS}ms when timing out.</p>
*/
public class BlockingCameraManager {
- private static final String TAG = "CameraBlockingOpener";
+ private static final String TAG = "BlockingCameraManager";
private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
- private static final int OPEN_TIME_OUT = 2000; // ms time out for openCamera
+ private static final int OPEN_TIME_OUT_MS = 2000; // ms time out for openCamera
/**
* Exception thrown by {@link #openCamera} if the open fails asynchronously.
*/
public static class BlockingOpenException extends Exception {
/**
- * Suppress eclipse warning
+ * Suppress Eclipse warning
*/
private static final long serialVersionUID = 12397123891238912L;
@@ -165,7 +165,7 @@ public class BlockingCameraManager {
*
* <p>Pass-through all StateCallback changes to the proxy.</p>
*
- * <p>Time out after {@link #OPEN_TIME_OUT} and unblock. Clean up camera if it arrives
+ * <p>Time out after {@link #OPEN_TIME_OUT_MS} and unblock. Clean up camera if it arrives
* later.</p>
*/
private class OpenListener extends CameraDevice.StateCallback {
@@ -283,14 +283,14 @@ public class BlockingCameraManager {
/**
* Block until onOpened, onError, or onDisconnected
*/
- if (!mDeviceReady.block(OPEN_TIME_OUT)) {
+ if (!mDeviceReady.block(OPEN_TIME_OUT_MS)) {
synchronized (mLock) {
if (mNoReply) { // Give the async camera a fighting chance (required)
mTimedOut = true; // Clean up camera if it ever arrives later
throw new TimeoutRuntimeException(String.format(
"Timed out after %d ms while trying to open camera device %s",
- OPEN_TIME_OUT, mCameraId));
+ OPEN_TIME_OUT_MS, mCameraId));
}
}
}
diff --git a/camera2/public/src/com/android/ex/camera2/blocking/BlockingSessionCallback.java b/camera2/public/src/com/android/ex/camera2/blocking/BlockingSessionCallback.java
index e041d27..ae4f40b 100644
--- a/camera2/public/src/com/android/ex/camera2/blocking/BlockingSessionCallback.java
+++ b/camera2/public/src/com/android/ex/camera2/blocking/BlockingSessionCallback.java
@@ -66,7 +66,7 @@ public class BlockingSessionCallback extends CameraCaptureSession.StateCallback
*/
public static final int SESSION_CLOSED = 4;
- private final int NUM_STATES = 5;
+ private static final int NUM_STATES = 5;
/*
* Private fields
@@ -162,21 +162,27 @@ public class BlockingSessionCallback extends CameraCaptureSession.StateCallback
@Override
public void onConfigured(CameraCaptureSession session) {
mSessionFuture.setSession(session);
- if (mProxy != null) mProxy.onConfigured(session);
+ if (mProxy != null) {
+ mProxy.onConfigured(session);
+ }
mStateChangeListener.onStateChanged(SESSION_CONFIGURED);
}
@Override
public void onConfigureFailed(CameraCaptureSession session) {
mSessionFuture.setSession(session);
- if (mProxy != null) mProxy.onConfigureFailed(session);
+ if (mProxy != null) {
+ mProxy.onConfigureFailed(session);
+ }
mStateChangeListener.onStateChanged(SESSION_CONFIGURE_FAILED);
}
@Override
public void onReady(CameraCaptureSession session) {
mSessionFuture.setSession(session);
- if (mProxy != null) mProxy.onReady(session);
+ if (mProxy != null) {
+ mProxy.onReady(session);
+ }
mStateChangeListener.onStateChanged(SESSION_READY);
}
diff --git a/camera2/public/src/com/android/ex/camera2/blocking/BlockingStateCallback.java b/camera2/public/src/com/android/ex/camera2/blocking/BlockingStateCallback.java
index 5f93fbc..0edca85 100644
--- a/camera2/public/src/com/android/ex/camera2/blocking/BlockingStateCallback.java
+++ b/camera2/public/src/com/android/ex/camera2/blocking/BlockingStateCallback.java
@@ -56,7 +56,7 @@ public class BlockingStateCallback extends CameraDevice.StateCallback {
if (VERBOSE) Log.v(TAG, "Camera device state now " + stateToString(state));
try {
mRecentStates.put(state);
- } catch(InterruptedException e) {
+ } catch (InterruptedException e) {
throw new RuntimeException("Unable to set device state", e);
}
}
@@ -97,7 +97,7 @@ public class BlockingStateCallback extends CameraDevice.StateCallback {
/**
* Total number of reachable states
*/
- private static int NUM_STATES = 4;
+ private static final int NUM_STATES = 4;
public BlockingStateCallback() {
mProxy = null;
@@ -109,25 +109,33 @@ public class BlockingStateCallback extends CameraDevice.StateCallback {
@Override
public void onOpened(CameraDevice camera) {
- if (mProxy != null) mProxy.onOpened(camera);
+ if (mProxy != null) {
+ mProxy.onOpened(camera);
+ }
setCurrentState(STATE_OPENED);
}
@Override
public void onDisconnected(CameraDevice camera) {
- if (mProxy != null) mProxy.onDisconnected(camera);
+ if (mProxy != null) {
+ mProxy.onDisconnected(camera);
+ }
setCurrentState(STATE_DISCONNECTED);
}
@Override
public void onError(CameraDevice camera, int error) {
- if (mProxy != null) mProxy.onError(camera, error);
+ if (mProxy != null) {
+ mProxy.onError(camera, error);
+ }
setCurrentState(STATE_ERROR);
}
@Override
public void onClosed(CameraDevice camera) {
- if (mProxy != null) mProxy.onClosed(camera);
+ if (mProxy != null) {
+ mProxy.onClosed(camera);
+ }
setCurrentState(STATE_CLOSED);
}
@@ -137,7 +145,7 @@ public class BlockingStateCallback extends CameraDevice.StateCallback {
*
* <p>Note: Only one waiter allowed at a time!</p>
*
- * @param desired state to observe a transition to
+ * @param state state to observe a transition to
* @param timeout how long to wait in milliseconds
*
* @throws TimeoutRuntimeException if the desired state is not observed before timeout.
@@ -162,8 +170,10 @@ public class BlockingStateCallback extends CameraDevice.StateCallback {
*
*/
public int waitForAnyOfStates(Collection<Integer> states, final long timeout) {
- synchronized(mLock) {
- if (mWaiting) throw new IllegalStateException("Only one waiter allowed at a time");
+ synchronized (mLock) {
+ if (mWaiting) {
+ throw new IllegalStateException("Only one waiter allowed at a time");
+ }
mWaiting = true;
}
if (VERBOSE) {
@@ -190,7 +200,7 @@ public class BlockingStateCallback extends CameraDevice.StateCallback {
throw new UnsupportedOperationException("Does not support interrupts on waits", e);
}
- synchronized(mLock) {
+ synchronized (mLock) {
mWaiting = false;
}
@@ -218,7 +228,7 @@ public class BlockingStateCallback extends CameraDevice.StateCallback {
*/
public static void appendStates(StringBuilder s, Collection<Integer> states) {
boolean start = true;
- for (Integer state: states) {
+ for (Integer state : states) {
if (!start) s.append(" ");
s.append(stateToString(state));
start = false;
diff --git a/camera2/public/src/com/android/ex/camera2/utils/StateChangeListener.java b/camera2/public/src/com/android/ex/camera2/utils/StateChangeListener.java
index 48cca17..564cd90 100644
--- a/camera2/public/src/com/android/ex/camera2/utils/StateChangeListener.java
+++ b/camera2/public/src/com/android/ex/camera2/utils/StateChangeListener.java
@@ -17,5 +17,5 @@
package com.android.ex.camera2.utils;
public interface StateChangeListener {
- public void onStateChanged(int state);
+ void onStateChanged(int state);
}
diff --git a/camera2/public/src/com/android/ex/camera2/utils/StateWaiter.java b/camera2/public/src/com/android/ex/camera2/utils/StateWaiter.java
index ec57829..1eb3037 100644
--- a/camera2/public/src/com/android/ex/camera2/utils/StateWaiter.java
+++ b/camera2/public/src/com/android/ex/camera2/utils/StateWaiter.java
@@ -87,7 +87,7 @@ public final class StateWaiter {
*
* <p>Note: Only one waiter allowed at a time!</p>
*
- * @param desired state to observe a transition to
+ * @param state state to observe a transition to
* @param timeoutMs how long to wait in milliseconds
*
* @throws IllegalArgumentException if {@code state} was out of range
@@ -196,7 +196,7 @@ public final class StateWaiter {
try {
mQueuedStates.put(state);
- } catch(InterruptedException e) {
+ } catch (InterruptedException e) {
throw new UnsupportedOperationException("Unable to set current state", e);
}
}