Methods Summary |
---|
public synchronized int | getState()Obtain the current state.
return mState;
|
public synchronized void | invalidate()Change the state to be invalid. Once invalidated, the state will be invalid forever.
mInvalid = true;
|
public synchronized boolean | isInvalid()Whether the state is invalid.
return mInvalid;
|
public synchronized void | setState(int state)Change to a new state.
if (mState != state) {
Log.v(TAG, "setState - state = " + Integer.toBinaryString(state));
}
mState = state;
this.notifyAll();
|
private boolean | waitForCondition(com.android.ex.camera2.portability.CameraStateHolder$ConditionChecker stateChecker, long timeoutMs)A helper method used by {@link #waitToAvoidStates(int)} and
{@link #waitForStates(int)}. This method will wait until the
condition is successful.
long timeBound = SystemClock.uptimeMillis() + timeoutMs;
synchronized (this) {
while (!stateChecker.success()) {
try {
this.wait(timeoutMs);
} catch (InterruptedException ex) {
if (SystemClock.uptimeMillis() > timeBound) {
// Timeout.
Log.w(TAG, "Timeout waiting.");
}
return false;
}
}
}
return true;
|
public boolean | waitForStates(int states)Block the current thread until the state becomes one of the
specified.
Log.v(TAG, "waitForStates - states = " + Integer.toBinaryString(states));
return waitForCondition(new ConditionChecker() {
@Override
public boolean success() {
return (states | getState()) == states;
}
}, CameraAgent.CAMERA_OPERATION_TIMEOUT_MS);
|
public boolean | waitToAvoidStates(int states)Block the current thread until the state becomes NOT one of the
specified.
Log.v(TAG, "waitToAvoidStates - states = " + Integer.toBinaryString(states));
return waitForCondition(new ConditionChecker() {
@Override
public boolean success() {
return (states & getState()) == 0;
}
}, CameraAgent.CAMERA_OPERATION_TIMEOUT_MS);
|