Merge "Handle InterruptedException in waitDone" into gb-ub-photos-bryce
diff --git a/src/com/android/camera/CameraManager.java b/src/com/android/camera/CameraManager.java
index b1161cd..be82ea6 100644
--- a/src/com/android/camera/CameraManager.java
+++ b/src/com/android/camera/CameraManager.java
@@ -420,12 +420,20 @@
}
public void setParameters(Parameters params) {
- // TODO: check if this synchronous version is necessary
+ if (params == null) {
+ Log.v(TAG, "null parameters in setParameters()");
+ return;
+ }
mParametersIsDirty = true;
mCameraHandler.obtainMessage(SET_PARAMETERS, params).sendToTarget();
}
public void setParametersAsync(Parameters params) {
+ // TODO: remove this.
+ if (params == null) {
+ Log.v(TAG, "null parameters in setParameters()");
+ return;
+ }
mParametersIsDirty = true;
mCameraHandler.removeMessages(SET_PARAMETERS_ASYNC);
mCameraHandler.obtainMessage(SET_PARAMETERS_ASYNC, params).sendToTarget();
@@ -434,8 +442,7 @@
public Parameters getParameters() {
if (mParametersIsDirty || mParameters == null) {
mCameraHandler.sendEmptyMessage(GET_PARAMETERS);
- waitDone();
- mParametersIsDirty = false;
+ if (waitDone()) mParametersIsDirty = false;
}
return mParameters;
}
@@ -445,7 +452,8 @@
ENABLE_SHUTTER_SOUND, (enable ? 1 : 0), 0).sendToTarget();
}
- public void waitDone() {
+ // return false if cancelled.
+ public boolean waitDone() {
final Object waitDoneLock = new Object();
final Runnable unlockRunnable = new Runnable() {
@Override
@@ -462,8 +470,10 @@
waitDoneLock.wait();
} catch (InterruptedException ex) {
Log.v(TAG, "waitDone interrupted");
+ return false;
}
}
+ return true;
}
}
}