1 /* 2 * Copyright (c) 2021 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 FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_ACE_SERVICE_ABILITY_H 17 #define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_ACE_SERVICE_ABILITY_H 18 19 #include <string> 20 #include <vector> 21 22 #include "ability.h" 23 #include "ability_loader.h" 24 #include "iremote_object.h" 25 #include "want.h" 26 27 #include "adapter/ohos/entrance/pa_engine/pa_backend.h" 28 29 namespace OHOS::Ace { 30 31 class AceServiceAbility final : public OHOS::AppExecFwk::Ability { 32 public: AceServiceAbility()33 AceServiceAbility() 34 { 35 abilityId_ = instanceId_; 36 instanceId_++; 37 } 38 virtual ~AceServiceAbility() = default; 39 40 void OnStart(const OHOS::AAFwk::Want& want) override; 41 void OnStop() override; 42 sptr<IRemoteObject> OnConnect(const OHOS::AAFwk::Want &want) override; 43 void OnDisconnect(const OHOS::AAFwk::Want &want) override; 44 void OnCommand(const AAFwk::Want &want, bool restart, int startId) override; 45 46 private: 47 int32_t abilityId_ = 100000; 48 49 static int32_t instanceId_; 50 static const std::string START_PARAMS_KEY; 51 static const std::string URI; 52 }; 53 54 } // namespace OHOS::Ace 55 56 #endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CPP_ACE_SERVICE_ABILITY_H 57