diff options
author | 2020-04-17 10:01:47 -0700 | |
---|---|---|
committer | 2020-04-17 11:02:16 -0700 | |
commit | ab65cb1824d27f1c864b3cccc5075b5e1b96667c (patch) | |
tree | 6af4f3c75703b8579e1e3d6b09599b6c6ff7724a /services/incremental/IncrementalService.h | |
parent | 74548402d1a07d1812f9dbd9f200f02058c69ac9 (diff) |
Switching to FSM-based DL lifecycle.
This is a pure refactoring.
Bug: b/153874006
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest
Change-Id: Ieda2be08d7359fa69b2d328c85b3606de6d02b3d
Diffstat (limited to 'services/incremental/IncrementalService.h')
-rw-r--r-- | services/incremental/IncrementalService.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/services/incremental/IncrementalService.h b/services/incremental/IncrementalService.h index 8c79d7725dcf..8b28bac26f9a 100644 --- a/services/incremental/IncrementalService.h +++ b/services/incremental/IncrementalService.h @@ -171,29 +171,31 @@ private: public: DataLoaderStub(IncrementalService& service, MountId id, DataLoaderParamsParcel&& params, FileSystemControlParcel&& control, - const DataLoaderStatusListener* externalListener) - : mService(service), - mId(id), - mParams(std::move(params)), - mControl(std::move(control)), - mListener(externalListener ? *externalListener : DataLoaderStatusListener()) {} + const DataLoaderStatusListener* externalListener); ~DataLoaderStub(); - bool create(); + bool requestCreate(); bool requestStart(); - void destroy(); + bool requestDestroy(); + + bool waitForDestroy(Clock::duration duration = std::chrono::seconds(60)); + + void onDump(int fd); - // accessors MountId id() const { return mId; } const DataLoaderParamsParcel& params() const { return mParams; } - int status() const { return mStatus; } - bool startRequested() const { return mStartRequested; } private: binder::Status onStatusChanged(MountId mount, int newStatus) final; + bool create(); bool start(); - bool waitForDestroy(); + bool destroy(); + + bool setTargetStatus(int status); + bool waitForStatus(int status, Clock::duration duration); + + bool fsmStep(); IncrementalService& mService; MountId const mId; @@ -203,9 +205,9 @@ private: std::mutex mStatusMutex; std::condition_variable mStatusCondition; - int mStatus = IDataLoaderStatusListener::DATA_LOADER_DESTROYED; - bool mStartRequested = false; - bool mDestroyRequested = true; + int mCurrentStatus = IDataLoaderStatusListener::DATA_LOADER_DESTROYED; + int mTargetStatus = IDataLoaderStatusListener::DATA_LOADER_DESTROYED; + TimePoint mTargetStatusTs = {}; }; using DataLoaderStubPtr = sp<DataLoaderStub>; |