summaryrefslogtreecommitdiff
path: root/gsi_service.cpp
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2019-08-01 12:53:06 -0700
committerDavid Anderson <dvander@google.com>2019-08-01 18:00:43 -0700
commit551ae3aa39dbe5fcf124db4324e33242b5f7002c (patch)
tree9fdd9959a7f974ab62ab8364e113dfb2df974b96 /gsi_service.cpp
parentb00d15e8cb62163b052678214d718ab660e4aaf6 (diff)
downloadgsid-551ae3aa39dbe5fcf124db4324e33242b5f7002c.tar.gz
Add a library to wrap libfiemap differences between recovery and normal AOSP.
libsnapshot has to work both in normal boot and in recovery. Normally, we want libfiemap to be used through gsid, via binder, to consolidate the necessary SELinux permissions. However binder is not available in recovery, so instead we introduce a compile-time abstraction layer. Recovery should link to libfiemap; otherwise, libfiemap_binder should be used instead. They both present the same API. Bug: 134536978 Test: manual test Change-Id: I60370af2175723141e61f0ee301cad40d2f331c1
Diffstat (limited to 'gsi_service.cpp')
-rw-r--r--gsi_service.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/gsi_service.cpp b/gsi_service.cpp
index a208c5e..352b2c2 100644
--- a/gsi_service.cpp
+++ b/gsi_service.cpp
@@ -32,7 +32,7 @@
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
-#include <android/gsi/BnImageManager.h>
+#include <android/gsi/BnImageService.h>
#include <android/gsi/IGsiService.h>
#include <ext4_utils/ext4_utils.h>
#include <fs_mgr.h>
@@ -396,9 +396,9 @@ static binder::Status UidSecurityError() {
return binder::Status::fromExceptionCode(binder::Status::EX_SECURITY, String8(message.c_str()));
}
-class ImageManagerService : public BinderService<ImageManagerService>, public BnImageManager {
+class ImageService : public BinderService<ImageService>, public BnImageService {
public:
- ImageManagerService(GsiService* service, std::unique_ptr<ImageManager>&& impl, uid_t uid);
+ ImageService(GsiService* service, std::unique_ptr<ImageManager>&& impl, uid_t uid);
binder::Status createBackingImage(const std::string& name, int64_t size, int flags) override;
binder::Status deleteBackingImage(const std::string& name) override;
binder::Status mapImageDevice(const std::string& name, int32_t timeout_ms,
@@ -415,12 +415,10 @@ class ImageManagerService : public BinderService<ImageManagerService>, public Bn
uid_t uid_;
};
-ImageManagerService::ImageManagerService(GsiService* service, std::unique_ptr<ImageManager>&& impl,
- uid_t uid)
+ImageService::ImageService(GsiService* service, std::unique_ptr<ImageManager>&& impl, uid_t uid)
: service_(service), parent_(service->parent()), impl_(std::move(impl)), uid_(uid) {}
-binder::Status ImageManagerService::createBackingImage(const std::string& name, int64_t size,
- int flags) {
+binder::Status ImageService::createBackingImage(const std::string& name, int64_t size, int flags) {
if (!CheckUid()) return UidSecurityError();
std::lock_guard<std::mutex> guard(parent_->lock());
@@ -431,7 +429,7 @@ binder::Status ImageManagerService::createBackingImage(const std::string& name,
return binder::Status::ok();
}
-binder::Status ImageManagerService::deleteBackingImage(const std::string& name) {
+binder::Status ImageService::deleteBackingImage(const std::string& name) {
if (!CheckUid()) return UidSecurityError();
std::lock_guard<std::mutex> guard(parent_->lock());
@@ -442,8 +440,8 @@ binder::Status ImageManagerService::deleteBackingImage(const std::string& name)
return binder::Status::ok();
}
-binder::Status ImageManagerService::mapImageDevice(const std::string& name, int32_t timeout_ms,
- MappedImage* mapping) {
+binder::Status ImageService::mapImageDevice(const std::string& name, int32_t timeout_ms,
+ MappedImage* mapping) {
if (!CheckUid()) return UidSecurityError();
std::lock_guard<std::mutex> guard(parent_->lock());
@@ -454,7 +452,7 @@ binder::Status ImageManagerService::mapImageDevice(const std::string& name, int3
return binder::Status::ok();
}
-binder::Status ImageManagerService::unmapImageDevice(const std::string& name) {
+binder::Status ImageService::unmapImageDevice(const std::string& name) {
if (!CheckUid()) return UidSecurityError();
std::lock_guard<std::mutex> guard(parent_->lock());
@@ -465,8 +463,7 @@ binder::Status ImageManagerService::unmapImageDevice(const std::string& name) {
return binder::Status::ok();
}
-binder::Status ImageManagerService::backingImageExists(const std::string& name,
- bool* _aidl_return) {
+binder::Status ImageService::backingImageExists(const std::string& name, bool* _aidl_return) {
if (!CheckUid()) return UidSecurityError();
std::lock_guard<std::mutex> guard(parent_->lock());
@@ -479,8 +476,8 @@ bool ImageManagerService::CheckUid() {
return uid_ == IPCThreadState::self()->getCallingUid();
}
-binder::Status GsiService::openImageManager(const std::string& prefix,
- android::sp<IImageManager>* _aidl_return) {
+binder::Status GsiService::openImageService(const std::string& prefix,
+ android::sp<IImageService>* _aidl_return) {
static constexpr char kImageMetadataPrefix[] = "/metadata/gsi/";
static constexpr char kImageDataPrefix[] = "/data/gsi/";
@@ -511,7 +508,7 @@ binder::Status GsiService::openImageManager(const std::string& prefix,
return BinderError("Unknown error");
}
- *_aidl_return = new ImageManagerService(this, std::move(impl), uid);
+ *_aidl_return = new ImageService(this, std::move(impl), uid);
return binder::Status::ok();
}