1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.camera.one.v2.commands; 18 19 import android.hardware.camera2.CameraAccessException; 20 21 import com.android.camera.one.v2.camera2proxy.CameraCaptureSessionClosedException; 22 import com.android.camera.one.v2.core.ResourceAcquisitionFailedException; 23 24 /** 25 * A generic camera command which may take an arbitrary, indefinite amount of 26 * time to execute. Camera commands typically interact with the camera device, 27 * capture session, image reader, and other resources. 28 * <p> 29 * When shutting down, it is critical that commands gracefully exit when these 30 * resources are no longer available. 31 */ 32 public interface CameraCommand { 33 /** 34 * @throws InterruptedException If interrupted while executing the command. 35 * @throws CameraAccessException If the camera is not available when 36 * accessed by the command. 37 * @throws CameraCaptureSessionClosedException If the capture session was 38 * closed and not available when accessed by the command. 39 * @throws ResourceAcquisitionFailedException If various non-camera 40 * resources required for the command to execute could not be 41 * acquired, either because they do not exist, or things are 42 * being shut down. For example, a command may throw this if it 43 * failed to allocate logical space in a shared image reader 44 * because the image reader is being closed, or because the 45 * requested space was greater than the capacity of the image 46 * reader. 47 */ 48 public void run() throws InterruptedException, CameraAccessException, 49 CameraCaptureSessionClosedException, ResourceAcquisitionFailedException; 50 } 51