storage_manager.h 4.4 KB

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