diff --git a/frameworks/ets/ani/BUILD.gn b/frameworks/ets/ani/BUILD.gn index f487ec8a1225f3956c9d5fa7ec48d2bfa9ee867f..ea1f0d27eaad77b56db42bc466d496a3f904022d 100644 --- a/frameworks/ets/ani/BUILD.gn +++ b/frameworks/ets/ani/BUILD.gn @@ -23,7 +23,6 @@ group("ani_packages") { "${ability_runtime_path}/frameworks/ets/ani/app_manager:ability_app_manager_ani_kit", "${ability_runtime_path}/frameworks/ets/ani/form_extension_ability:form_extension_ability_etc", "${ability_runtime_path}/frameworks/ets/ani/insight_intent/insight_intent_driver:insight_intent_driver_ani_kit", - "${ability_runtime_path}/frameworks/ets/ani/native_constructor:context_ani", "${ability_runtime_path}/frameworks/ets/ani/uri_permission_manager:uri_permission_manager_abc_etc", "${ability_runtime_path}/frameworks/ets/ani/uri_permission_manager:uri_permission_manager_ani_kit", "${ability_runtime_path}/frameworks/ets/ani/wantagent:aniwantagent", diff --git a/frameworks/ets/ani/native_constructor/BUILD.gn b/frameworks/ets/ani/native_constructor/BUILD.gn deleted file mode 100644 index 3637f8a2acd409fa39b8bda960235366e6c93312..0000000000000000000000000000000000000000 --- a/frameworks/ets/ani/native_constructor/BUILD.gn +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -ohos_shared_library("context_ani") { - branch_protector_ret = "pac_ret" - sanitize = { - cfi = true - cfi_cross_dso = true - cfi_vcall_icall_only = true - debug = false - } - - sources = [ - "context_native_constructor.cpp", - ] - - include_dirs = [ - "${ability_runtime_services_path}/common/include", - ] - - external_deps = [ - "hilog:libhilog", - "runtime_core:ani", - ] - subsystem_name = "ability" - part_name = "ability_runtime" - output_extension = "so" -} diff --git a/frameworks/ets/ani/native_constructor/context_native_constructor.cpp b/frameworks/ets/ani/native_constructor/context_native_constructor.cpp deleted file mode 100644 index b402dad70d58335e188783889c763d4955ab3219..0000000000000000000000000000000000000000 --- a/frameworks/ets/ani/native_constructor/context_native_constructor.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AbilityRuntime { -void ContextConstructor() -{ -} - -void AbilityStageContextConstructor() -{ -} - -void ExtensionContextConstructor() -{ -} - -void UIAbilityContextConstructor() -{ -} - -extern "C" { -ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) -{ - ani_env *env; - if (vm == nullptr || result == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Illegal VM or result"); - return ANI_ERROR; - } - if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Unsupported ANI_VERSION_1"); - return ANI_ERROR; - } - // class Context - ani_class contextClass; - static const char *contextClassName = "Lapplication/Context/Context;"; - if (ANI_OK != env->FindClass(contextClassName, &contextClass)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Not found class %{public}s.", contextClassName); - return ANI_NOT_FOUND; - } - std::array classMethods_context = { - ani_native_function {"", ":V", reinterpret_cast(ContextConstructor)}, - }; - if (ANI_OK != env->Class_BindNativeMethods(contextClass, classMethods_context.data(), - classMethods_context.size())) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Cannot bind native ctor to class %{public}s.", contextClassName); - return ANI_ERROR; - }; - // class ExtensionContext - ani_class extensionContextClass; - static const char *extensionContextClassName = "Lapplication/ExtensionContext/ExtensionContext;"; - if (ANI_OK != env->FindClass(extensionContextClassName, &extensionContextClass)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Not found class %{public}s.", extensionContextClassName); - return ANI_NOT_FOUND; - } - std::array classMethods_extensionContext = { - ani_native_function {"", ":V", reinterpret_cast(ExtensionContextConstructor)}, - }; - if (ANI_OK != env->Class_BindNativeMethods(extensionContextClass, classMethods_extensionContext.data(), - classMethods_extensionContext.size())) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Cannot bind native ctor to class %{public}s.", extensionContextClassName); - return ANI_ERROR; - }; - // class UIAbilityContext - ani_class uiAbilityClass; - static const char *uiAbilityClassName = "Lapplication/UIAbilityContext/UIAbilityContext;"; - if (ANI_OK != env->FindClass(uiAbilityClassName, &uiAbilityClass)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Not found class %{public}s.", uiAbilityClassName); - return ANI_NOT_FOUND; - } - std::array classMethods_uiAbility = { - ani_native_function {"", ":V", reinterpret_cast(UIAbilityContextConstructor)}, - }; - if (ANI_OK != env->Class_BindNativeMethods(uiAbilityClass, classMethods_uiAbility.data(), - classMethods_uiAbility.size())) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Cannot bind native ctor to class %{public}s.", uiAbilityClassName); - return ANI_ERROR; - }; - // class AbilityStageContext - ani_class abilityStageContextClass; - static const char *abilityStageContextClassName = "Lapplication/AbilityStageContext/AbilityStageContext;"; - if (ANI_OK != env->FindClass(abilityStageContextClassName, &abilityStageContextClass)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Not found class %{public}s.", abilityStageContextClassName); - return ANI_NOT_FOUND; - } - std::array classMethods_abilityStage = { - ani_native_function {"", ":V", reinterpret_cast(AbilityStageContextConstructor)}, - }; - if (ANI_OK != env->Class_BindNativeMethods(abilityStageContextClass, classMethods_abilityStage.data(), - classMethods_abilityStage.size())) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Cannot bind native ctor to class %{public}s.", abilityStageContextClassName); - return ANI_ERROR; - }; - - *result = ANI_VERSION_1; - return ANI_OK; -} -} -} // namespace AbilityRuntime -} // namespace OHOS \ No newline at end of file diff --git a/frameworks/ets/ets/application/AbilityStageContext.ets b/frameworks/ets/ets/application/AbilityStageContext.ets index 5fe7eafea1e7c169c8fdd9d15155885e73ddaf7b..a1ac3ade04407fc945161b490eedc0c8b2c27050 100644 --- a/frameworks/ets/ets/application/AbilityStageContext.ets +++ b/frameworks/ets/ets/application/AbilityStageContext.ets @@ -18,14 +18,6 @@ import { Configuration } from '@ohos.app.ability.Configuration' import { HapModuleInfo } from 'bundleManager.HapModuleInfo'; export default class AbilityStageContext extends Context { - static { - loadLibrary("context_ani"); - } config?: Configuration; - currentHapModuleInfo: HapModuleInfo; - native constructor(); - constructor(currentHapModuleInfo: HapModuleInfo) { - super(); - this.currentHapModuleInfo = currentHapModuleInfo; - } + currentHapModuleInfo!: HapModuleInfo; } \ No newline at end of file diff --git a/frameworks/ets/ets/application/BaseContext.ets b/frameworks/ets/ets/application/BaseContext.ets index 2e9e42158db0f925bef44484f492b1f900b47652..9c11325513c31c23e34d615ae8f77a255caf930b 100644 --- a/frameworks/ets/ets/application/BaseContext.ets +++ b/frameworks/ets/ets/application/BaseContext.ets @@ -14,6 +14,6 @@ */ export default class BaseContext { - public nativeContext : long = 0; - public stageMode: boolean; + public nativeContext: long = 0; + public stageMode: boolean = true; } \ No newline at end of file diff --git a/frameworks/ets/ets/application/Context.ets b/frameworks/ets/ets/application/Context.ets index 29dd7bdd7a5dd0484b81a85790126541d5518a09..0a441fb4944058c0d013e23d5136e4988c999dbc 100644 --- a/frameworks/ets/ets/application/Context.ets +++ b/frameworks/ets/ets/application/Context.ets @@ -24,25 +24,16 @@ import { BusinessError } from '@ohos.base'; import AsyncCallbackWrapper from '../utils/AbilityUtils'; export class Context extends BaseContext { - static { - loadLibrary("context_ani"); - } area: contextConstant.AreaMode = contextConstant.AreaMode.EL1; filesDir: string = ""; tempDir: string = ""; preferencesDir: string = ""; databaseDir: string = ""; cacheDir: string = ""; - applicationInfo: ApplicationInfo; + applicationInfo!: ApplicationInfo; eventHub: EventHub = new EventHub(); - resourceManager: resmgr.ResourceManager; + resourceManager!: resmgr.ResourceManager; processName: string = ""; - native constructor(); - constructor(applicationInfo: ApplicationInfo, resourceManager: resmgr.ResourceManager) { - super(); - this.applicationInfo = applicationInfo; - this.resourceManager = resourceManager; - } public native getApplicationContextSync(): ApplicationContext; public native createModuleResourceManagerSync(bundleName: string, moduleName: string): resmgr.ResourceManager; diff --git a/frameworks/ets/ets/application/ExtensionContext.ets b/frameworks/ets/ets/application/ExtensionContext.ets index 593e35756276d2fac2ac013172a1a91fe6d4fc9c..fa9e0f5c446276ddbd395e3a5dd474b8bea4e2c7 100644 --- a/frameworks/ets/ets/application/ExtensionContext.ets +++ b/frameworks/ets/ets/application/ExtensionContext.ets @@ -19,17 +19,7 @@ import { Configuration } from '@ohos.app.ability.Configuration'; import { HapModuleInfo } from 'bundleManager.HapModuleInfo'; export default class ExtensionContext extends Context { - static { - loadLibrary("context_ani"); - } - extensionAbilityInfo: ExtensionAbilityInfo; - config: Configuration; - currentHapModuleInfo: HapModuleInfo; - native constructor(); - constructor(config: Configuration, extensionAbilityInfo: ExtensionAbilityInfo, currentHapModuleInfo: HapModuleInfo) { - super(); - this.config = config; - this.extensionAbilityInfo = extensionAbilityInfo; - this.currentHapModuleInfo = currentHapModuleInfo; - } + extensionAbilityInfo!: ExtensionAbilityInfo; + config!: Configuration; + currentHapModuleInfo!: HapModuleInfo; } \ No newline at end of file diff --git a/frameworks/ets/ets/application/UIAbilityContext.ets b/frameworks/ets/ets/application/UIAbilityContext.ets index 6cd38d8892bff0933ad662fda2737a4c404fac74..52818f2ce396a73affee5c4e8085b1403dbfd7a0 100644 --- a/frameworks/ets/ets/application/UIAbilityContext.ets +++ b/frameworks/ets/ets/application/UIAbilityContext.ets @@ -32,23 +32,10 @@ import { LocalStorage } from '@ohos.arkui.stateManagement'; type Any = Object | null | undefined export default class UIAbilityContext extends Context { - static { - loadLibrary("context_ani"); - } - - config: Configuration; - abilityInfo: AbilityInfo; - windowStage: window.WindowStage; - currentHapModuleInfo: HapModuleInfo; - - native constructor(); - constructor(config: Configuration, abilityInfo: AbilityInfo, windowStage: window.WindowStage, currentHapModuleInfo: HapModuleInfo) { - super(); - this.config = config; - this.abilityInfo = abilityInfo; - this.windowStage = windowStage; - this.currentHapModuleInfo = currentHapModuleInfo; - } + config!: Configuration; + abilityInfo!: AbilityInfo; + windowStage!: window.WindowStage; + currentHapModuleInfo!: HapModuleInfo; private static native nativeTransferStatic(input: ESValue): Object; private static native nativeTransferDynamic(input: Object): ESValue;