1 /* 2 * Copyright (c) 2023 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 UPDATE_NOTIFY_H 17 #define UPDATE_NOTIFY_H 18 19 #include <string> 20 #include "ability_connect_callback_stub.h" 21 #include "ability_connect_callback_interface.h" 22 #include "ability_manager_interface.h" 23 #include "ability_manager_client.h" 24 #include "if_system_ability_manager.h" 25 #include "system_ability_definition.h" 26 #include "update_no_constructor.h" 27 #include "want.h" 28 29 namespace OHOS { 30 namespace UpdateEngine { 31 class UpdateNotify : public NoConstructor { 32 public: 33 static bool NotifyToAppService(const std::string &eventInfo, const std::string &subscribeInfo); 34 35 private: 36 static ErrCode ConnectAbility(const AAFwk::Want &want, const sptr<AAFwk::IAbilityConnection> &connect, 37 const sptr<IRemoteObject> &callerToken); 38 static ErrCode DisconnectAbility(const sptr<AAFwk::IAbilityConnection> &connect); 39 static ErrCode StopServiceAbility(const AAFwk::Want &want); 40 static ErrCode StartAbility(const AAFwk::Want &want); 41 static AAFwk::Want MakeWant(const std::string &deviceId, const std::string &abilityName, 42 const std::string &bundleName, const std::string &subscribeInfo, const std::string ¶ms = {}); 43 }; 44 45 class NotifyConnection : public AAFwk::AbilityConnectionStub { 46 public: 47 explicit NotifyConnection() = default; 48 ~NotifyConnection() = default; 49 50 void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, 51 int32_t resultCode) override; 52 void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; 53 }; 54 } // namespace UpdateEngine 55 } // namespace OHOS 56 #endif // UPDATE_NOTIFY_H