Remove DefaultContainerService usage in StorageManagerService.
StorageManagerService uses DefaultContainerService to obtain ObbInfo
for files passed through mountObb() transaction. This change moves this
logic to client side and so ObbInfo will be passed as part of mountObb()
transaction.
Bug: 111838160
Test: atest src/android/os/storage/cts/StorageManagerTest.java
Test: atest core/tests/coretests/src/android/os/storage/StorageManagerIntegrationTest.java
Test: atest services/tests/servicestests/src/com/android/server/MountServiceTests.java
Change-Id: I29aee3aa54a45057df96aae289888161a3e3af71
diff --git a/native/android/storage_manager.cpp b/native/android/storage_manager.cpp
index bf15b8d..2272525 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 @@
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 @@
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) {