| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2010 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 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 17 | /** | 
 | 18 |  * @addtogroup Storage | 
 | 19 |  * @{ | 
 | 20 |  */ | 
 | 21 |  | 
 | 22 | /** | 
 | 23 |  * @file storage_manager.h | 
 | 24 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 25 |  | 
 | 26 | #ifndef ANDROID_STORAGE_MANAGER_H | 
 | 27 | #define ANDROID_STORAGE_MANAGER_H | 
 | 28 |  | 
 | 29 | #include <stdint.h> | 
 | 30 |  | 
 | 31 | #ifdef __cplusplus | 
 | 32 | extern "C" { | 
 | 33 | #endif | 
 | 34 |  | 
 | 35 | struct AStorageManager; | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 36 | /** | 
 | 37 |  * {@link AStorageManager} manages application OBB storage, a pointer | 
 | 38 |  * can be obtained with AStorageManager_new(). | 
 | 39 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 40 | typedef struct AStorageManager AStorageManager; | 
 | 41 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 42 | /** | 
 | 43 |  * The different states of a OBB storage passed to AStorageManager_obbCallbackFunc(). | 
 | 44 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 45 | enum { | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 46 |     /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 47 |      * The OBB container is now mounted and ready for use. Can be returned | 
 | 48 |      * as the status for callbacks made during asynchronous OBB actions. | 
 | 49 |      */ | 
 | 50 |     AOBB_STATE_MOUNTED = 1, | 
 | 51 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 52 |     /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 53 |      * The OBB container is now unmounted and not usable. Can be returned | 
 | 54 |      * as the status for callbacks made during asynchronous OBB actions. | 
 | 55 |      */ | 
 | 56 |     AOBB_STATE_UNMOUNTED = 2, | 
 | 57 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 58 |     /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 59 |      * There was an internal system error encountered while trying to | 
 | 60 |      * mount the OBB. Can be returned as the status for callbacks made | 
 | 61 |      * during asynchronous OBB actions. | 
 | 62 |      */ | 
 | 63 |     AOBB_STATE_ERROR_INTERNAL = 20, | 
 | 64 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 65 |     /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 66 |      * The OBB could not be mounted by the system. Can be returned as the | 
 | 67 |      * status for callbacks made during asynchronous OBB actions. | 
 | 68 |      */ | 
 | 69 |     AOBB_STATE_ERROR_COULD_NOT_MOUNT = 21, | 
 | 70 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 71 |     /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 72 |      * The OBB could not be unmounted. This most likely indicates that a | 
 | 73 |      * file is in use on the OBB. Can be returned as the status for | 
 | 74 |      * callbacks made during asynchronous OBB actions. | 
 | 75 |      */ | 
 | 76 |     AOBB_STATE_ERROR_COULD_NOT_UNMOUNT = 22, | 
 | 77 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 78 |     /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 79 |      * A call was made to unmount the OBB when it was not mounted. Can be | 
 | 80 |      * returned as the status for callbacks made during asynchronous OBB | 
 | 81 |      * actions. | 
 | 82 |      */ | 
 | 83 |     AOBB_STATE_ERROR_NOT_MOUNTED = 23, | 
 | 84 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 85 |     /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 86 |      * The OBB has already been mounted. Can be returned as the status for | 
 | 87 |      * callbacks made during asynchronous OBB actions. | 
 | 88 |      */ | 
 | 89 |     AOBB_STATE_ERROR_ALREADY_MOUNTED = 24, | 
 | 90 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 91 |     /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 92 |      * The current application does not have permission to use this OBB. | 
 | 93 |      * This could be because the OBB indicates it's owned by a different | 
 | 94 |      * package. Can be returned as the status for callbacks made during | 
 | 95 |      * asynchronous OBB actions. | 
 | 96 |      */ | 
 | 97 |     AOBB_STATE_ERROR_PERMISSION_DENIED = 25, | 
 | 98 | }; | 
 | 99 |  | 
 | 100 | /** | 
 | 101 |  * Obtains a new instance of AStorageManager. | 
 | 102 |  */ | 
 | 103 | AStorageManager* AStorageManager_new(); | 
 | 104 |  | 
 | 105 | /** | 
 | 106 |  * Release AStorageManager instance. | 
 | 107 |  */ | 
 | 108 | void AStorageManager_delete(AStorageManager* mgr); | 
 | 109 |  | 
 | 110 | /** | 
 | 111 |  * Callback function for asynchronous calls made on OBB files. | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 112 |  * | 
 | 113 |  * "state" is one of the following constants: | 
 | 114 |  * - {@link AOBB_STATE_MOUNTED} | 
 | 115 |  * - {@link AOBB_STATE_UNMOUNTED} | 
 | 116 |  * - {@link AOBB_STATE_ERROR_INTERNAL} | 
 | 117 |  * - {@link AOBB_STATE_ERROR_COULD_NOT_MOUNT} | 
 | 118 |  * - {@link AOBB_STATE_ERROR_COULD_NOT_UNMOUNT} | 
 | 119 |  * - {@link AOBB_STATE_ERROR_NOT_MOUNTED} | 
 | 120 |  * - {@link AOBB_STATE_ERROR_ALREADY_MOUNTED} | 
 | 121 |  * - {@link AOBB_STATE_ERROR_PERMISSION_DENIED} | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 122 |  */ | 
 | 123 | typedef void (*AStorageManager_obbCallbackFunc)(const char* filename, const int32_t state, void* data); | 
 | 124 |  | 
 | 125 | /** | 
 | 126 |  * Attempts to mount an OBB file. This is an asynchronous operation. | 
 | 127 |  */ | 
 | 128 | void AStorageManager_mountObb(AStorageManager* mgr, const char* filename, const char* key, | 
 | 129 |         AStorageManager_obbCallbackFunc cb, void* data); | 
 | 130 |  | 
 | 131 | /** | 
 | 132 |  * Attempts to unmount an OBB file. This is an asynchronous operation. | 
 | 133 |  */ | 
 | 134 | void AStorageManager_unmountObb(AStorageManager* mgr, const char* filename, const int force, | 
 | 135 |         AStorageManager_obbCallbackFunc cb, void* data); | 
 | 136 |  | 
 | 137 | /** | 
 | 138 |  * Check whether an OBB is mounted. | 
 | 139 |  */ | 
 | 140 | int AStorageManager_isObbMounted(AStorageManager* mgr, const char* filename); | 
 | 141 |  | 
 | 142 | /** | 
 | 143 |  * Get the mounted path for an OBB. | 
 | 144 |  */ | 
 | 145 | const char* AStorageManager_getMountedObbPath(AStorageManager* mgr, const char* filename); | 
 | 146 |  | 
 | 147 |  | 
 | 148 | #ifdef __cplusplus | 
 | 149 | }; | 
 | 150 | #endif | 
 | 151 |  | 
 | 152 | #endif      // ANDROID_STORAGE_MANAGER_H | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 153 |  | 
 | 154 | /** @} */ |