| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.hardware.camera2.impl; |
| 17 |
|
| 18 |
import android.os.Binder; |
| 19 |
import android.hardware.camera2.CameraCaptureSession; |
| 20 |
import android.hardware.camera2.CameraDevice; |
| 21 |
import android.hardware.camera2.CaptureFailure; |
| 22 |
import android.hardware.camera2.CaptureRequest; |
| 23 |
import android.hardware.camera2.CaptureResult; |
| 24 |
import android.hardware.camera2.TotalCaptureResult; |
| 25 |
import android.view.Surface; |
| 26 |
|
| 27 |
import java.util.concurrent.Executor; |
| 28 |
|
| 29 |
import static com.android.internal.util.Preconditions.*; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class CallbackProxies { |
| 38 |
public static class SessionStateCallbackProxy |
| 39 |
extends CameraCaptureSession.StateCallback { |
| 40 |
private final Executor mExecutor; |
| 41 |
private final CameraCaptureSession.StateCallback mCallback; |
| 42 |
|
| 43 |
public SessionStateCallbackProxy(Executor executor, |
| 44 |
CameraCaptureSession.StateCallback callback) { |
| 45 |
mExecutor = checkNotNull(executor, "executor must not be null"); |
| 46 |
mCallback = checkNotNull(callback, "callback must not be null"); |
| 47 |
} |
| 48 |
|
| 49 |
@Override |
| 50 |
public void onConfigured(CameraCaptureSession session) { |
| 51 |
final long ident = Binder.clearCallingIdentity(); |
| 52 |
try { |
| 53 |
mExecutor.execute(() -> mCallback.onConfigured(session)); |
| 54 |
} finally { |
| 55 |
Binder.restoreCallingIdentity(ident); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
@Override |
| 61 |
public void onConfigureFailed(CameraCaptureSession session) { |
| 62 |
final long ident = Binder.clearCallingIdentity(); |
| 63 |
try { |
| 64 |
mExecutor.execute(() -> mCallback.onConfigureFailed(session)); |
| 65 |
} finally { |
| 66 |
Binder.restoreCallingIdentity(ident); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
@Override |
| 71 |
public void onReady(CameraCaptureSession session) { |
| 72 |
final long ident = Binder.clearCallingIdentity(); |
| 73 |
try { |
| 74 |
mExecutor.execute(() -> mCallback.onReady(session)); |
| 75 |
} finally { |
| 76 |
Binder.restoreCallingIdentity(ident); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
public void onActive(CameraCaptureSession session) { |
| 82 |
final long ident = Binder.clearCallingIdentity(); |
| 83 |
try { |
| 84 |
mExecutor.execute(() -> mCallback.onActive(session)); |
| 85 |
} finally { |
| 86 |
Binder.restoreCallingIdentity(ident); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
@Override |
| 91 |
public void onCaptureQueueEmpty(CameraCaptureSession session) { |
| 92 |
final long ident = Binder.clearCallingIdentity(); |
| 93 |
try { |
| 94 |
mExecutor.execute(() -> mCallback.onCaptureQueueEmpty(session)); |
| 95 |
} finally { |
| 96 |
Binder.restoreCallingIdentity(ident); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
@Override |
| 101 |
public void onClosed(CameraCaptureSession session) { |
| 102 |
final long ident = Binder.clearCallingIdentity(); |
| 103 |
try { |
| 104 |
mExecutor.execute(() -> mCallback.onClosed(session)); |
| 105 |
} finally { |
| 106 |
Binder.restoreCallingIdentity(ident); |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
@Override |
| 111 |
public void onSurfacePrepared(CameraCaptureSession session, Surface surface) { |
| 112 |
final long ident = Binder.clearCallingIdentity(); |
| 113 |
try { |
| 114 |
mExecutor.execute(() -> mCallback.onSurfacePrepared(session, surface)); |
| 115 |
} finally { |
| 116 |
Binder.restoreCallingIdentity(ident); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
} |
| 121 |
|
| 122 |
private CallbackProxies() { |
| 123 |
throw new AssertionError(); |
| 124 |
} |
| 125 |
} |