1 /* 2 * Copyright (c) 2022 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_CJ_ABILITY_STAGE_H 17 #define OHOS_ABILITY_RUNTIME_CJ_ABILITY_STAGE_H 18 19 #include <utility> 20 21 #include "ability_stage.h" 22 #include "cj_ability_stage_object.h" 23 #include "ffi_remote_data.h" 24 25 #ifdef WINDOWS_PLATFORM 26 #define CJ_EXPORT __declspec(dllexport) 27 #else 28 #define CJ_EXPORT __attribute__((visibility("default"))) 29 #endif 30 31 extern "C" { 32 struct CurrentHapModuleInfo { 33 const char* name; 34 const char* icon; 35 int32_t iconId; 36 const char* label; 37 int32_t labelId; 38 const char* description; 39 int32_t descriptionId; 40 const char* mainElementName; 41 bool installationFree; 42 const char* hashValue; 43 }; 44 45 CJ_EXPORT CurrentHapModuleInfo* FFICJCurrentHapModuleInfo(int64_t id); 46 CJ_EXPORT int64_t FFIAbilityGetAbilityStageContext(AbilityStageHandle abilityStageHandle); 47 } 48 49 50 namespace OHOS { 51 namespace AbilityRuntime { 52 class CJAbilityStage : public AbilityStage { 53 public: 54 static std::shared_ptr<CJAbilityStage> Create( 55 const std::unique_ptr<Runtime>& runtime, const AppExecFwk::HapModuleInfo& hapModuleInfo); CJAbilityStage(std::shared_ptr<CJAbilityStageObject> cjStage)56 explicit CJAbilityStage( 57 std::shared_ptr<CJAbilityStageObject> cjStage) : cjAbilityStageObject_(std::move(cjStage)) {} 58 ~CJAbilityStage() override = default; 59 60 void Init(const std::shared_ptr<Context> &context, 61 const std::weak_ptr<AppExecFwk::OHOSApplication> application) override; 62 void OnCreate(const AAFwk::Want& want) const override; 63 std::string OnAcceptWant(const AAFwk::Want& want) override; 64 void OnConfigurationUpdated(const AppExecFwk::Configuration& configuration) override; 65 void OnMemoryLevel(int level) override; 66 67 private: 68 std::shared_ptr<CJAbilityStageObject> cjAbilityStageObject_; 69 }; 70 } // namespace AbilityRuntime 71 } // namespace OHOS 72 73 #endif // OHOS_ABILITY_RUNTIME_CJ_ABILITY_STAGE_H 74