summaryrefslogtreecommitdiff
path: root/native/android/storage_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'native/android/storage_manager.cpp')
-rw-r--r--native/android/storage_manager.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/native/android/storage_manager.cpp b/native/android/storage_manager.cpp
index bf15b8d075e7..22725254fef6 100644
--- a/native/android/storage_manager.cpp
+++ b/native/android/storage_manager.cpp
@@ -18,7 +18,9 @@
#include <android/storage_manager.h>
#include <storage/IMountService.h>
+#include <storage/ObbInfo.h>
+#include <androidfw/ObbFile.h>
#include <binder/Binder.h>
#include <binder/IServiceManager.h>
#include <cutils/atomic.h>
@@ -29,7 +31,6 @@
#include <utils/Vector.h>
#include <utils/threads.h>
-
using namespace android;
struct ObbActionListener : public BnObbActionListener {
@@ -79,6 +80,20 @@ protected:
return cb;
}
+ ObbInfo* getObbInfo(char* canonicalPath) {
+ sp<ObbFile> obbFile = new ObbFile();
+ if (!obbFile->readFrom(canonicalPath)) {
+ return nullptr;
+ }
+
+ String16 fileName(obbFile->getFileName());
+ String16 packageName(obbFile->getPackageName());
+ size_t length;
+ const unsigned char* salt = obbFile->getSalt(&length);
+ return new ObbInfo(fileName, packageName,
+ obbFile->getVersion(), obbFile->getFlags(), length, salt);
+ }
+
public:
AStorageManager()
{
@@ -134,11 +149,18 @@ public:
return;
}
+ sp<ObbInfo> obbInfo = getObbInfo(canonicalPath);
+ if (obbInfo == nullptr) {
+ ALOGE("Couldn't get obb info for %s: %s", canonicalPath, strerror(errno));
+ return;
+ }
+
ObbCallback* cb = registerObbCallback(func, data);
String16 rawPath16(rawPath);
String16 canonicalPath16(canonicalPath);
String16 key16(key);
- mMountService->mountObb(rawPath16, canonicalPath16, key16, mObbActionListener, cb->nonce);
+ mMountService->mountObb(rawPath16, canonicalPath16, key16, mObbActionListener,
+ cb->nonce, obbInfo);
}
void unmountObb(const char* filename, const bool force, AStorageManager_obbCallbackFunc func, void* data) {