blob: 7f2ee08d62c34720c492f0aa3ed8bf205c51da43 [file] [log] [blame]
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001/*
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 Euphrosinebf6d5e02015-03-27 17:15:43 -070017/**
18 * @addtogroup Storage
19 * @{
20 */
21
22/**
23 * @file storage_manager.h
24 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070025
26#ifndef ANDROID_STORAGE_MANAGER_H
27#define ANDROID_STORAGE_MANAGER_H
28
29#include <stdint.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35struct AStorageManager;
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070036/**
37 * {@link AStorageManager} manages application OBB storage, a pointer
38 * can be obtained with AStorageManager_new().
39 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070040typedef struct AStorageManager AStorageManager;
41
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070042/**
43 * The different states of a OBB storage passed to AStorageManager_obbCallbackFunc().
44 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070045enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070046 /**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070047 * 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 Euphrosinebf6d5e02015-03-27 17:15:43 -070052 /**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070053 * 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 Euphrosinebf6d5e02015-03-27 17:15:43 -070058 /**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070059 * 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 Euphrosinebf6d5e02015-03-27 17:15:43 -070065 /**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070066 * 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 Euphrosinebf6d5e02015-03-27 17:15:43 -070071 /**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070072 * 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 Euphrosinebf6d5e02015-03-27 17:15:43 -070078 /**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070079 * 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 Euphrosinebf6d5e02015-03-27 17:15:43 -070085 /**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070086 * 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 Euphrosinebf6d5e02015-03-27 17:15:43 -070091 /**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070092 * 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 */
103AStorageManager* AStorageManager_new();
104
105/**
106 * Release AStorageManager instance.
107 */
108void AStorageManager_delete(AStorageManager* mgr);
109
110/**
111 * Callback function for asynchronous calls made on OBB files.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700112 *
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 Agopiane1c61d32012-03-23 14:19:36 -0700122 */
123typedef 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 */
128void 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 */
134void 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 */
140int AStorageManager_isObbMounted(AStorageManager* mgr, const char* filename);
141
142/**
143 * Get the mounted path for an OBB.
144 */
145const char* AStorageManager_getMountedObbPath(AStorageManager* mgr, const char* filename);
146
147
148#ifdef __cplusplus
149};
150#endif
151
152#endif // ANDROID_STORAGE_MANAGER_H
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700153
154/** @} */