diff options
author | Yo Chiang <yochiang@google.com> | 2020-09-02 04:02:43 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-09-02 04:02:43 +0000 |
commit | 1ba307abdac01f484e33a2bd15d6dba4b2423f3a (patch) | |
tree | 84af24723cde0f2b4b0f7e210c884afb39a18eba | |
parent | 69a1bb0d8dddbab961f124d64472a3e687d0c5d0 (diff) | |
parent | 36fdbc6daf44c85c5d811e08c35a792b867d0aae (diff) | |
download | gsid-1ba307abdac01f484e33a2bd15d6dba4b2423f3a.tar.gz |
Merge "Add closePartition() method to gsid"
-rw-r--r-- | aidl/android/gsi/IGsiService.aidl | 13 | ||||
-rw-r--r-- | gsi_service.cpp | 15 | ||||
-rw-r--r-- | gsi_service.h | 1 |
3 files changed, 28 insertions, 1 deletions
diff --git a/aidl/android/gsi/IGsiService.aidl b/aidl/android/gsi/IGsiService.aidl index 5503493..8b38504 100644 --- a/aidl/android/gsi/IGsiService.aidl +++ b/aidl/android/gsi/IGsiService.aidl @@ -179,6 +179,16 @@ interface IGsiService { int createPartition(in @utf8InCpp String name, long size, boolean readOnly); /** + * Complete the current partition installation. A partition installation is + * complete after all pending bytes are written successfully. + * Returns an error if current installation still have pending bytes. + * Returns an error if there is any internal filesystem error. + * + * @return 0 on success, an error code on failure. + */ + int closePartition(); + + /** * Wipe a partition. This will not work if the GSI is currently running. * The partition will not be removed, but the first block will be zeroed. * @@ -212,7 +222,8 @@ interface IGsiService { * 2. Open a new partition installer. * 3. Create and map the new partition. * - * In other words, getAvbPublicKey() works between two createPartition() calls. + * In other words, getAvbPublicKey() should be called after + * createPartition() is called and before closePartition() is called. * * @param dst Output the AVB public key. * @return 0 on success, an error code on failure. diff --git a/gsi_service.cpp b/gsi_service.cpp index 490655c..3c875f8 100644 --- a/gsi_service.cpp +++ b/gsi_service.cpp @@ -182,6 +182,21 @@ binder::Status GsiService::createPartition(const ::std::string& name, int64_t si return binder::Status::ok(); } +binder::Status GsiService::closePartition(int32_t* _aidl_return) { + ENFORCE_SYSTEM; + std::lock_guard<std::mutex> guard(lock_); + + if (installer_ == nullptr) { + LOG(ERROR) << "createPartition() has to be called before closePartition()"; + *_aidl_return = IGsiService::INSTALL_ERROR_GENERIC; + return binder::Status::ok(); + } + // It is important to not reset |installer_| here because other methods such + // as enableGsi() relies on the state of |installer_|. + *_aidl_return = installer_->FinishInstall(); + return binder::Status::ok(); +} + binder::Status GsiService::commitGsiChunkFromStream(const android::os::ParcelFileDescriptor& stream, int64_t bytes, bool* _aidl_return) { ENFORCE_SYSTEM; diff --git a/gsi_service.h b/gsi_service.h index 229db36..3f81786 100644 --- a/gsi_service.h +++ b/gsi_service.h @@ -42,6 +42,7 @@ class GsiService : public BinderService<GsiService>, public BnGsiService { binder::Status closeInstall(int32_t* _aidl_return) override; binder::Status createPartition(const ::std::string& name, int64_t size, bool readOnly, int32_t* _aidl_return) override; + binder::Status closePartition(int32_t* _aidl_return) override; binder::Status commitGsiChunkFromStream(const ::android::os::ParcelFileDescriptor& stream, int64_t bytes, bool* _aidl_return) override; binder::Status getInstallProgress(::android::gsi::GsiProgress* _aidl_return) override; |