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