1*33f37583SAndroid Build Coastguard Worker /* 2*33f37583SAndroid Build Coastguard Worker * Copyright (C) 2020 The Android Open Source Project 3*33f37583SAndroid Build Coastguard Worker * 4*33f37583SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*33f37583SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*33f37583SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*33f37583SAndroid Build Coastguard Worker * 8*33f37583SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*33f37583SAndroid Build Coastguard Worker * 10*33f37583SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*33f37583SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*33f37583SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*33f37583SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*33f37583SAndroid Build Coastguard Worker * limitations under the License. 15*33f37583SAndroid Build Coastguard Worker */ 16*33f37583SAndroid Build Coastguard Worker 17*33f37583SAndroid Build Coastguard Worker #ifndef ANDROID_APEXD_APEXD_LIFECYCLE_H_ 18*33f37583SAndroid Build Coastguard Worker #define ANDROID_APEXD_APEXD_LIFECYCLE_H_ 19*33f37583SAndroid Build Coastguard Worker 20*33f37583SAndroid Build Coastguard Worker #include <android-base/result.h> 21*33f37583SAndroid Build Coastguard Worker 22*33f37583SAndroid Build Coastguard Worker namespace android { 23*33f37583SAndroid Build Coastguard Worker namespace apex { 24*33f37583SAndroid Build Coastguard Worker 25*33f37583SAndroid Build Coastguard Worker class ApexdLifecycle { 26*33f37583SAndroid Build Coastguard Worker private: ApexdLifecycle()27*33f37583SAndroid Build Coastguard Worker ApexdLifecycle(){}; 28*33f37583SAndroid Build Coastguard Worker std::atomic<bool> boot_completed_; 29*33f37583SAndroid Build Coastguard Worker 30*33f37583SAndroid Build Coastguard Worker // Non-copyable && non-moveable. 31*33f37583SAndroid Build Coastguard Worker ApexdLifecycle(const ApexdLifecycle&) = delete; 32*33f37583SAndroid Build Coastguard Worker ApexdLifecycle& operator=(const ApexdLifecycle&) = delete; 33*33f37583SAndroid Build Coastguard Worker ApexdLifecycle& operator=(ApexdLifecycle&&) = delete; 34*33f37583SAndroid Build Coastguard Worker 35*33f37583SAndroid Build Coastguard Worker void RevertActiveSessions(const std::string& process, 36*33f37583SAndroid Build Coastguard Worker const std::string& error); 37*33f37583SAndroid Build Coastguard Worker public: GetInstance()38*33f37583SAndroid Build Coastguard Worker static ApexdLifecycle& GetInstance() { 39*33f37583SAndroid Build Coastguard Worker static ApexdLifecycle instance; 40*33f37583SAndroid Build Coastguard Worker return instance; 41*33f37583SAndroid Build Coastguard Worker } 42*33f37583SAndroid Build Coastguard Worker bool IsBooting(); 43*33f37583SAndroid Build Coastguard Worker void MarkBootCompleted(); 44*33f37583SAndroid Build Coastguard Worker void WaitForBootStatus(const bool has_active_session); 45*33f37583SAndroid Build Coastguard Worker }; 46*33f37583SAndroid Build Coastguard Worker } // namespace apex 47*33f37583SAndroid Build Coastguard Worker } // namespace android 48*33f37583SAndroid Build Coastguard Worker 49*33f37583SAndroid Build Coastguard Worker #endif // ANDROID_APEXD_APEXD_LIFECYCLE_H 50