blob: bad249133737cb522bd8a371e296cd8d6d94a5e7 [file] [log] [blame]
Dan Albert287553d2017-02-16 10:47:51 -08001/*
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
17
18#ifndef ANDROID_STORAGE_MANAGER_H
19#define ANDROID_STORAGE_MANAGER_H
20
21#include <stdint.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27struct AStorageManager;
28typedef struct AStorageManager AStorageManager;
29
30enum {
31 /*
32 * The OBB container is now mounted and ready for use. Can be returned
33 * as the status for callbacks made during asynchronous OBB actions.
34 */
35 AOBB_STATE_MOUNTED = 1,
36
37 /*
38 * The OBB container is now unmounted and not usable. Can be returned
39 * as the status for callbacks made during asynchronous OBB actions.
40 */
41 AOBB_STATE_UNMOUNTED = 2,
42
43 /*
44 * There was an internal system error encountered while trying to
45 * mount the OBB. Can be returned as the status for callbacks made
46 * during asynchronous OBB actions.
47 */
48 AOBB_STATE_ERROR_INTERNAL = 20,
49
50 /*
51 * The OBB could not be mounted by the system. Can be returned as the
52 * status for callbacks made during asynchronous OBB actions.
53 */
54 AOBB_STATE_ERROR_COULD_NOT_MOUNT = 21,
55
56 /*
57 * The OBB could not be unmounted. This most likely indicates that a
58 * file is in use on the OBB. Can be returned as the status for
59 * callbacks made during asynchronous OBB actions.
60 */
61 AOBB_STATE_ERROR_COULD_NOT_UNMOUNT = 22,
62
63 /*
64 * A call was made to unmount the OBB when it was not mounted. Can be
65 * returned as the status for callbacks made during asynchronous OBB
66 * actions.
67 */
68 AOBB_STATE_ERROR_NOT_MOUNTED = 23,
69
70 /*
71 * The OBB has already been mounted. Can be returned as the status for
72 * callbacks made during asynchronous OBB actions.
73 */
74 AOBB_STATE_ERROR_ALREADY_MOUNTED = 24,
75
76 /*
77 * The current application does not have permission to use this OBB.
78 * This could be because the OBB indicates it's owned by a different
79 * package. Can be returned as the status for callbacks made during
80 * asynchronous OBB actions.
81 */
82 AOBB_STATE_ERROR_PERMISSION_DENIED = 25,
83};
84
85/**
86 * Obtains a new instance of AStorageManager.
87 */
88AStorageManager* AStorageManager_new();
89
90/**
91 * Release AStorageManager instance.
92 */
93void AStorageManager_delete(AStorageManager* mgr);
94
95/**
96 * Callback function for asynchronous calls made on OBB files.
97 */
98typedef void (*AStorageManager_obbCallbackFunc)(const char* filename, const int32_t state, void* data);
99
100/**
101 * Attempts to mount an OBB file. This is an asynchronous operation.
102 */
103void AStorageManager_mountObb(AStorageManager* mgr, const char* filename, const char* key,
104 AStorageManager_obbCallbackFunc cb, void* data);
105
106/**
107 * Attempts to unmount an OBB file. This is an asynchronous operation.
108 */
109void AStorageManager_unmountObb(AStorageManager* mgr, const char* filename, const int force,
110 AStorageManager_obbCallbackFunc cb, void* data);
111
112/**
113 * Check whether an OBB is mounted.
114 */
115int AStorageManager_isObbMounted(AStorageManager* mgr, const char* filename);
116
117/**
118 * Get the mounted path for an OBB.
119 */
120const char* AStorageManager_getMountedObbPath(AStorageManager* mgr, const char* filename);
121
122
123#ifdef __cplusplus
124};
125#endif
126
127#endif // ANDROID_STORAGE_MANAGER_H