1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_ABILITY_RUNTIME_QUERY_ERMS_MANAGER_H 17 #define OHOS_ABILITY_RUNTIME_QUERY_ERMS_MANAGER_H 18 19 #include <future> 20 #include "cpp/mutex.h" 21 22 #include <iremote_object.h> 23 #include <iremote_stub.h> 24 #include <memory> 25 26 #include "query_erms_observer_manager.h" 27 #include "singleton.h" 28 29 namespace OHOS { 30 namespace AAFwk { 31 class AbilityManagerService; 32 33 /** 34 * @class QueryERMSManager 35 * QueryERMSManager. 36 */ 37 class QueryERMSManager { 38 public: 39 static QueryERMSManager &GetInstance(); 40 41 /** 42 * OnQueryFinished, StartQueryERMS is complete. 43 * 44 * @param appId, appId. 45 * @param startTime, startTime. 46 * @param rule, atomic service startup rule. 47 * @param resultCode, ERR_OK on success, others on failure. 48 */ 49 void OnQueryFinished(int32_t recordId, const std::string &appId, const std::string &startTime, 50 const AtomicServiceStartupRule &rule, int32_t resultCode); 51 52 /** 53 * Add an observer from application into queryERMSObserverManager. 54 * @param observer, the observer of the ability to free install. 55 * @return Returns ERR_OK on success, others on failure. 56 */ 57 int AddQueryERMSObserver(sptr<IRemoteObject> callerToken, sptr<AbilityRuntime::IQueryERMSObserver> observer); 58 59 private: 60 QueryERMSManager(); 61 ~QueryERMSManager(); 62 63 void HandleQueryERMSResult(int32_t recordId, const std::string &appId, const std::string &startTime, 64 const AtomicServiceStartupRule &rule, int32_t resultCode); 65 void HandleOnQueryERMSSuccess(int32_t recordId, const std::string &appId, const std::string &startTime, 66 const AtomicServiceStartupRule &rule); 67 void HandleOnQueryERMSFail(int32_t recordId, const std::string &appId, const std::string &startTime, 68 const AtomicServiceStartupRule &rule, int resultCode); 69 70 DISALLOW_COPY_AND_MOVE(QueryERMSManager); 71 }; 72 } // namespace AAFwk 73 } // namespace OHOS 74 #endif // OHOS_ABILITY_RUNTIME_QUERY_ERMS_MANAGER_H 75