1a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling/* 2a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * Copyright (C) 2014 The Android Open Source Project 3a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * 4a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * Licensed under the Apache License, Version 2.0 (the "License"); 5a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * you may not use this file except in compliance with the License. 6a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * You may obtain a copy of the License at 7a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * 8a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * http://www.apache.org/licenses/LICENSE-2.0 9a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * 10a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * Unless required by applicable law or agreed to in writing, software 11a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * distributed under the License is distributed on an "AS IS" BASIS, 12a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * See the License for the specific language governing permissions and 14a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * limitations under the License. 15a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling */ 16a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling 17a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberlingpackage com.android.camera.session; 18a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling 19a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberlingimport java.io.File; 20a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberlingimport java.io.IOException; 21a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling 2263a8c9467824ef8aa2039b7e27831b0533d8e5d9Sascha Haeberlingimport javax.annotation.Nonnull; 2363a8c9467824ef8aa2039b7e27831b0533d8e5d9Sascha Haeberling 24a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling/** 25a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * Interface for the session storage manager which handles management of storage 26a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * space that can be used for temporary session files. 27a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling */ 28a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberlingpublic interface SessionStorageManager { 29a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling 30a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling /** 31a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * Returns the directory that can be used for temporary sessions of a 32a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * specific type, defined by 'subDirectory'. 33a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * <p> 34a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * Before returning, this method will make sure the returned directory is 35a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * clean of expired session data. 36a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * 37abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * @param subDirectory The subdirectory to use/create within the temporary 38abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * session space, e.g. "foo". 39a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * @return A valid file object that points to an existing directory. 40a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling * @throws IOException If the directory could not be made available. 41a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling */ 42a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling public File getSessionDirectory(String subDirectory) throws IOException; 43abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling 44abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling /** 45abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * Initializes the directories for storing the final session output 46abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * temporarily before it is copied to the final location after calling 47abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * {@link #finish()}. 48abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * <p> 49abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * This method will make sure the directories and file exists and is 50abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * writeable, otherwise it will throw an exception. 51abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * 52abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * @param title the title of this session. Will be used to create a unique 53abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * sub-directory. 54abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * @return The path to a JPEG file which can be used to write the final 55abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * output to. 56abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling * @throws IOException If the directory could not be created. 57abf1e994d236a65180eecfcb6997003ab12795dfSascha Haeberling */ 5863a8c9467824ef8aa2039b7e27831b0533d8e5d9Sascha Haeberling @Nonnull 5963a8c9467824ef8aa2039b7e27831b0533d8e5d9Sascha Haeberling public File createTemporaryOutputPath(String subDirectory, String title) throws IOException; 60a86b048709342fc53cee92aa047a15a22462c71cSascha Haeberling} 61