summaryrefslogtreecommitdiff
path: root/gsi_service.cpp
diff options
context:
space:
mode:
authorHoward Chen <howardsoc@google.com>2019-08-05 16:21:00 +0800
committerHoward Chen <howardsoc@google.com>2019-09-18 15:52:15 +0800
commit5676d96164a2c33c512fc09c55b5492351c4a7a4 (patch)
treea8864e5c75dbb42e9dd3c6a75cbb137efecb8397 /gsi_service.cpp
parent25b18cc44a5fbe7e1578dc96ac200849ffa70183 (diff)
downloadgsid-5676d96164a2c33c512fc09c55b5492351c4a7a4.tar.gz
Use Ashmem to reduce buffer copies.
Replace boolean commitGsiChunkFromMemory(in byte[] bytes); with boolean setAshmem(in ParcelFileDescriptor stream, long size); boolean commitGsiChunkFromAshmem(long bytes); to reduce copies between binder buffer and process memory. Bug: 138976291 Test: adb shell am start-activity \ -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \ -a android.os.image.action.START_INSTALL \ -d file:///storage/emulated/0/Download/system.raw.gz \ --el KEY_SYSTEM_SIZE $(du -b system.raw|cut -f1) \ --el KEY_USERDATA_SIZE 8589934592 Change-Id: Ic9b14a3f531f61aa6544f9158b199f05cdec04ec Merged-In: Ic9b14a3f531f61aa6544f9158b199f05cdec04ec
Diffstat (limited to 'gsi_service.cpp')
-rw-r--r--gsi_service.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/gsi_service.cpp b/gsi_service.cpp
index f9805c4..dcf2d83 100644
--- a/gsi_service.cpp
+++ b/gsi_service.cpp
@@ -169,8 +169,7 @@ binder::Status GsiService::getInstallProgress(::android::gsi::GsiProgress* _aidl
return binder::Status::ok();
}
-binder::Status GsiService::commitGsiChunkFromMemory(const std::vector<uint8_t>& bytes,
- bool* _aidl_return) {
+binder::Status GsiService::commitGsiChunkFromAshmem(int64_t bytes, bool* _aidl_return) {
ENFORCE_SYSTEM;
std::lock_guard<std::mutex> guard(parent_->lock());
@@ -178,8 +177,17 @@ binder::Status GsiService::commitGsiChunkFromMemory(const std::vector<uint8_t>&
*_aidl_return = false;
return binder::Status::ok();
}
+ *_aidl_return = installer_->CommitGsiChunk(bytes);
+ return binder::Status::ok();
+}
- *_aidl_return = installer_->CommitGsiChunk(bytes.data(), bytes.size());
+binder::Status GsiService::setGsiAshmem(const ::android::os::ParcelFileDescriptor& ashmem,
+ int64_t size, bool* _aidl_return) {
+ if (!installer_) {
+ *_aidl_return = false;
+ return binder::Status::ok();
+ }
+ *_aidl_return = installer_->MapAshmem(ashmem.get(), size);
return binder::Status::ok();
}