ProcessingTask.java revision 57d2f873a78807bca84d4846e39cb2b73a0c8f82
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 17package com.android.camera.processing; 18 19import android.content.Context; 20 21import com.android.camera.app.CameraServices; 22import com.android.camera.session.CaptureSession; 23 24/** 25 * An interface for tasks to be processed by a {@code ProcessingService}. 26 */ 27public interface ProcessingTask { 28 /** 29 * The result returned by a {@code ProcessingTask}. 30 */ 31 public class ProcessingResult { 32 public final boolean mSuccess; 33 public final CaptureSession mSession; 34 35 /** 36 * @param success whether the processing was successful. 37 * @param session the capture session for the processed task. 38 */ 39 public ProcessingResult(boolean success, CaptureSession session) { 40 mSuccess = success; 41 mSession = session; 42 } 43 } 44 45 /** 46 * Classes implementing this interface can be informed when a task is done 47 * processing. 48 */ 49 public interface ProcessingTaskDoneListener { 50 /** 51 * Called when a task is done processing. 52 * 53 * @param result the processing result. 54 */ 55 public void onDone(ProcessingResult result); 56 } 57 58 /** 59 * Processes the given task. This will be usually called by a service. 60 * 61 * @param context the caller {@code Context} 62 * @param services the available {@code CameraServices} 63 * @param session the {@code CaptureSession} 64 * @return the {@code ProcessResult} with the result of the processing 65 */ 66 public ProcessingResult process(Context context, CameraServices services, 67 CaptureSession session); 68 69 /** 70 * @return the name of the task. It can be null to indicate that the task 71 * has no name. 72 */ 73 public String getName(); 74 75 /** Sets a listener that is informed when this task is done processing. */ 76 public void setDoneListener(ProcessingTaskDoneListener listener); 77} 78