diff options
author | David Anderson <dvander@google.com> | 2019-07-12 14:18:37 -0700 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2019-07-29 11:35:12 -0700 |
commit | 4c75673a121e055a258e8710de2a4ec9c263c68f (patch) | |
tree | 6d9b43b5fdb846ae335846d4312de302d689524d /gsi_service.h | |
parent | 1fdec26f4fc748768ccba2a67a9adc8147432e51 (diff) | |
download | gsid-4c75673a121e055a258e8710de2a4ec9c263c68f.tar.gz |
Only shut down gsid when it has no more consumers.
Consumers of gsiservice must now use IGsid for its top-level interface.
IGsiService can be acquired through IGsid::getClient. When the last
reference to IGsiService is dropped, gsid will cleanly exit. Callers
should no longer stop gsid through init.
Bug: 133528572
Test: gsid cleanly exits after gsi_tool runs
Change-Id: Ie5cb80fa63e61b143f9f27cca96999a5c71dab2c
Merged-In: Ie5cb80fa63e61b143f9f27cca96999a5c71dab2c
Diffstat (limited to 'gsi_service.h')
-rw-r--r-- | gsi_service.h | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/gsi_service.h b/gsi_service.h index ad582dd..6d72921 100644 --- a/gsi_service.h +++ b/gsi_service.h @@ -24,6 +24,7 @@ #include <android-base/unique_fd.h> #include <android/gsi/BnGsiService.h> +#include <android/gsi/BnGsid.h> #include <binder/BinderService.h> #include <libfiemap/split_fiemap_writer.h> #include <liblp/builder.h> @@ -34,13 +35,28 @@ namespace android { namespace gsi { -class GsiService : public BinderService<GsiService>, public BnGsiService { +class Gsid : public BinderService<Gsid>, public BnGsid { public: static void Register(); + static char const* getServiceName() { return kGsiServiceName; } + + binder::Status getClient(android::sp<IGsiService>* _aidl_return) override; + + private: + friend class GsiService; + friend class ImageManagerService; + + std::mutex& lock() { return lock_; } + + std::mutex lock_; +}; - GsiService(); +class GsiService : public BinderService<GsiService>, public BnGsiService { + public: ~GsiService() override; + static android::sp<IGsiService> Get(Gsid* parent); + binder::Status startGsiInstall(int64_t gsiSize, int64_t userdataSize, bool wipeUserdata, int* _aidl_return) override; binder::Status beginGsiInstall(const GsiInstallParams& params, int* _aidl_return) override; @@ -69,18 +85,16 @@ class GsiService : public BinderService<GsiService>, public BnGsiService { void StartAsyncOperation(const std::string& step, int64_t total_bytes); void UpdateProgress(int status, int64_t bytes_processed); - static char const* getServiceName() { return kGsiServiceName; } - // Helper methods for GsiInstaller. static bool RemoveGsiFiles(const std::string& install_dir, bool wipeUserdata); bool should_abort() const { return should_abort_; } + Gsid* parent() const { return parent_.get(); } static void RunStartupTasks(); static std::string GetInstalledImageDir(); private: - friend class ImageManagerService; - + GsiService(Gsid* parent); int ValidateInstallParams(GsiInstallParams* params); bool DisableGsiInstall(); int ReenableGsi(bool one_shot); @@ -88,9 +102,9 @@ class GsiService : public BinderService<GsiService>, public BnGsiService { enum class AccessLevel { System, SystemOrShell }; binder::Status CheckUid(AccessLevel level = AccessLevel::System); - std::mutex* lock() { return &lock_; } + static android::wp<GsiService> sInstance; - std::mutex lock_; + android::sp<Gsid> parent_; std::unique_ptr<GsiInstaller> installer_; // These are initialized or set in StartInstall(). |