diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/generated/arkts/ArkUIGeneratedNativeModule.ets b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/generated/arkts/ArkUIGeneratedNativeModule.ets index 7c0f29f8416ebc4790e777c6f7d9d2a225307ee8..794fa18727a577ac455b43e9aefa13159de1fa12 100644 --- a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/generated/arkts/ArkUIGeneratedNativeModule.ets +++ b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/generated/arkts/ArkUIGeneratedNativeModule.ets @@ -4421,6 +4421,18 @@ export class ArkUIGeneratedNativeModule { @ani.unsafe.Direct native static _EllipseShape_size(ptr: KPointer, thisArray: KSerializerBuffer, thisLength: int32): KPointer @ani.unsafe.Direct + native static _EnvironmentBackend_isAccessibilityEnabled(): boolean + @ani.unsafe.Direct + native static _EnvironmentBackend_getColorMode(): int32 + @ani.unsafe.Direct + native static _EnvironmentBackend_getFontScale(): float + @ani.unsafe.Direct + native static _EnvironmentBackend_getFontWeightScale(): float + @ani.unsafe.Quick + native static _EnvironmentBackend_getLayoutDirection(): string + @ani.unsafe.Quick + native static _EnvironmentBackend_getLanguageCode(): string + @ani.unsafe.Direct native static _EventEmulator_emitClickEvent(node: KPointer, event: KPointer): void @ani.unsafe.Quick native static _EventEmulator_emitTextInputEvent(node: KPointer, text: KStringPtr): void @@ -5549,6 +5561,16 @@ export class ArkUIGeneratedNativeModule { native static _PermissionRequest_getAccessibleResource(ptr: KPointer): KInteropReturnBuffer @ani.unsafe.Direct native static _PermissionRequest_grant(ptr: KPointer, thisArray: KSerializerBuffer, thisLength: int32): void + @ani.unsafe.Quick + native static _PersistentStorageBackend_get(key: KStringPtr): KInteropReturnBuffer + @ani.unsafe.Quick + native static _PersistentStorageBackend_has(key: KStringPtr): boolean + @ani.unsafe.Quick + native static _PersistentStorageBackend_remove(key: KStringPtr): void + @ani.unsafe.Quick + native static _PersistentStorageBackend_set(key: KStringPtr, value: KStringPtr): void + @ani.unsafe.Direct + native static _PersistentStorageBackend_clear(): void @ani.unsafe.Direct native static _PinchGestureEvent_construct(): KPointer @ani.unsafe.Direct diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/generated/stateManagement.ets b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/generated/stateManagement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4de87500ba4f37e85e4a5a4a42e4083dafb22714 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/generated/stateManagement.ets @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2024-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. + */ + + +// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! + +import { TypeChecker, ArkUIGeneratedNativeModule } from "#components" +import { Finalizable, runtimeType, RuntimeType, SerializerBase, registerCallback, wrapCallback, toPeerPtr, KPointer, MaterializedBase, NativeBuffer } from "@koalaui/interop" +import { unsafeCast, int32, int64, float32 } from "@koalaui/common" +import { CallbackKind } from "./peers/CallbackKind" +import { CallbackTransformer } from "./../CallbackTransformer" +export class EnvironmentBackend { + private static isAccessibilityEnabled_serialize(): boolean { + const retval = ArkUIGeneratedNativeModule._EnvironmentBackend_isAccessibilityEnabled() + return retval + } + private static getColorMode_serialize(): int32 { + const retval = ArkUIGeneratedNativeModule._EnvironmentBackend_getColorMode() + return retval + } + private static getFontScale_serialize(): float { + const retval = ArkUIGeneratedNativeModule._EnvironmentBackend_getFontScale() + return retval + } + private static getFontWeightScale_serialize(): float { + const retval = ArkUIGeneratedNativeModule._EnvironmentBackend_getFontWeightScale() + return retval + } + private static getLayoutDirection_serialize(): string { + const retval = ArkUIGeneratedNativeModule._EnvironmentBackend_getLayoutDirection() + return retval + } + private static getLanguageCode_serialize(): string { + const retval = ArkUIGeneratedNativeModule._EnvironmentBackend_getLanguageCode() + return retval + } + public static isAccessibilityEnabled(): boolean { + return EnvironmentBackend.isAccessibilityEnabled_serialize() + } + public static getColorMode(): int32 { + return EnvironmentBackend.getColorMode_serialize() + } + public static getFontScale(): float { + return EnvironmentBackend.getFontScale_serialize() + } + public static getFontWeightScale(): float { + return EnvironmentBackend.getFontWeightScale_serialize() + } + public static getLayoutDirection(): string { + return EnvironmentBackend.getLayoutDirection_serialize() + } + public static getLanguageCode(): string { + return EnvironmentBackend.getLanguageCode_serialize() + } +} +export class PersistentStorageBackend { + private static get_serialize(key: string): string | undefined { + const retval = ArkUIGeneratedNativeModule._PersistentStorageBackend_get(key) + let retvalDeserializer : DeserializerBase = new DeserializerBase(retval, retval.length) + const buffer_runtimeType = retvalDeserializer.readInt8().toInt() + let buffer : string | undefined + if ((buffer_runtimeType) != (RuntimeType.UNDEFINED)) + { + buffer = (retvalDeserializer.readString() as string) + } + const returnResult : string | undefined = buffer + return returnResult + } + private static has_serialize(key: string): boolean { + const retval = ArkUIGeneratedNativeModule._PersistentStorageBackend_has(key) + return retval + } + private static remove_serialize(key: string): void { + ArkUIGeneratedNativeModule._PersistentStorageBackend_remove(key) + } + private static set_serialize(key: string, value: string): void { + ArkUIGeneratedNativeModule._PersistentStorageBackend_set(key, value) + } + private static clear_serialize(): void { + ArkUIGeneratedNativeModule._PersistentStorageBackend_clear() + } + public static get(key: string): string | undefined { + const key_casted = key as (string) + return PersistentStorageBackend.get_serialize(key_casted) + } + public static has(key: string): boolean { + const key_casted = key as (string) + return PersistentStorageBackend.has_serialize(key_casted) + } + public static remove(key: string): void { + const key_casted = key as (string) + PersistentStorageBackend.remove_serialize(key_casted) + return + } + public static set(key: string, value: string): void { + const key_casted = key as (string) + const value_casted = value as (string) + PersistentStorageBackend.set_serialize(key_casted, value_casted) + return + } + public static clear(): void { + PersistentStorageBackend.clear_serialize() + return + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/arkoala_api_generated.h b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/arkoala_api_generated.h index 15b6145eff8a64dc500a155a5c5185d6bee50cfd..b60f31f51e729ed84077a896a8a9608d9d1d4b55 100644 --- a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/arkoala_api_generated.h +++ b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/arkoala_api_generated.h @@ -25217,6 +25217,15 @@ typedef struct GENERATED_ArkUIEllipseShapeAccessor { const Ark_SizeOptions* size); } GENERATED_ArkUIEllipseShapeAccessor; +typedef struct GENERATED_ArkUIEnvironmentBackendAccessor { + Ark_Boolean (*isAccessibilityEnabled)(); + Ark_Int32 (*getColorMode)(); + Ark_Float32 (*getFontScale)(); + Ark_Float32 (*getFontWeightScale)(); + Ark_String (*getLayoutDirection)(); + Ark_String (*getLanguageCode)(); +} GENERATED_ArkUIEnvironmentBackendAccessor; + typedef struct GENERATED_ArkUIEventEmulatorAccessor { void (*emitClickEvent)(Ark_NativePointer node, Ark_ClickEvent event); @@ -26396,6 +26405,15 @@ typedef struct GENERATED_ArkUIPermissionRequestAccessor { const Array_String* resources); } GENERATED_ArkUIPermissionRequestAccessor; +typedef struct GENERATED_ArkUIPersistentStorageBackendAccessor { + Opt_String (*get)(const Ark_String* key); + Ark_Boolean (*has)(const Ark_String* key); + void (*remove)(const Ark_String* key); + void (*set)(const Ark_String* key, + const Ark_String* value); + void (*clear)(); +} GENERATED_ArkUIPersistentStorageBackendAccessor; + typedef struct GENERATED_ArkUIPinchGestureEventAccessor { void (*destroyPeer)(Ark_PinchGestureEvent peer); Ark_PinchGestureEvent (*construct)(); @@ -28147,6 +28165,7 @@ typedef struct GENERATED_ArkUIAccessors { const GENERATED_ArkUIDrawingRenderingContextAccessor* (*getDrawingRenderingContextAccessor)(); const GENERATED_ArkUIDrawModifierAccessor* (*getDrawModifierAccessor)(); const GENERATED_ArkUIEllipseShapeAccessor* (*getEllipseShapeAccessor)(); + const GENERATED_ArkUIEnvironmentBackendAccessor* (*getEnvironmentBackendAccessor)(); const GENERATED_ArkUIEventEmulatorAccessor* (*getEventEmulatorAccessor)(); const GENERATED_ArkUIEventResultAccessor* (*getEventResultAccessor)(); const GENERATED_ArkUIEventTargetInfoAccessor* (*getEventTargetInfoAccessor)(); @@ -28221,6 +28240,7 @@ typedef struct GENERATED_ArkUIAccessors { const GENERATED_ArkUIPathShapeAccessor* (*getPathShapeAccessor)(); const GENERATED_ArkUIPatternLockControllerAccessor* (*getPatternLockControllerAccessor)(); const GENERATED_ArkUIPermissionRequestAccessor* (*getPermissionRequestAccessor)(); + const GENERATED_ArkUIPersistentStorageBackendAccessor* (*getPersistentStorageBackendAccessor)(); const GENERATED_ArkUIPinchGestureEventAccessor* (*getPinchGestureEventAccessor)(); const GENERATED_ArkUIPinchGestureInterfaceAccessor* (*getPinchGestureInterfaceAccessor)(); const GENERATED_ArkUIPinchRecognizerAccessor* (*getPinchRecognizerAccessor)(); diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/bridge_generated.cc b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/bridge_generated.cc index 1bd22eba45c646ade7a93b8558ade13ca36e608d..a6dd581dbbd22ec0535e0b2ee9b9c8fad6d53133 100644 --- a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/bridge_generated.cc +++ b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/bridge_generated.cc @@ -32081,6 +32081,30 @@ Ark_NativePointer impl_EllipseShape_size(Ark_NativePointer thisPtr, KSerializerB return GetAccessors()->getEllipseShapeAccessor()->size(self, static_cast(&size_value)); } KOALA_INTEROP_DIRECT_3(EllipseShape_size, Ark_NativePointer, Ark_NativePointer, KSerializerBuffer, int32_t) +Ark_Boolean impl_EnvironmentBackend_isAccessibilityEnabled() { + return GetAccessors()->getEnvironmentBackendAccessor()->isAccessibilityEnabled(); +} +KOALA_INTEROP_DIRECT_0(EnvironmentBackend_isAccessibilityEnabled, Ark_Boolean) +Ark_Int32 impl_EnvironmentBackend_getColorMode() { + return GetAccessors()->getEnvironmentBackendAccessor()->getColorMode(); +} +KOALA_INTEROP_DIRECT_0(EnvironmentBackend_getColorMode, Ark_Int32) +Ark_Int32 impl_EnvironmentBackend_getFontScale() { + return GetAccessors()->getEnvironmentBackendAccessor()->getFontScale(); +} +KOALA_INTEROP_DIRECT_0(EnvironmentBackend_getFontScale, Ark_Int32) +Ark_Int32 impl_EnvironmentBackend_getFontWeightScale() { + return GetAccessors()->getEnvironmentBackendAccessor()->getFontWeightScale(); +} +KOALA_INTEROP_DIRECT_0(EnvironmentBackend_getFontWeightScale, Ark_Int32) +Ark_String impl_EnvironmentBackend_getLayoutDirection() { + return GetAccessors()->getEnvironmentBackendAccessor()->getLayoutDirection(); +} +KOALA_INTEROP_0(EnvironmentBackend_getLayoutDirection, KStringPtr) +Ark_String impl_EnvironmentBackend_getLanguageCode() { + return GetAccessors()->getEnvironmentBackendAccessor()->getLanguageCode(); +} +KOALA_INTEROP_0(EnvironmentBackend_getLanguageCode, KStringPtr) void impl_EventEmulator_emitClickEvent(Ark_NativePointer node, Ark_NativePointer event) { GetAccessors()->getEventEmulatorAccessor()->emitClickEvent(node, static_cast(event)); } @@ -36451,6 +36475,35 @@ void impl_PermissionRequest_grant(Ark_NativePointer thisPtr, KSerializerBuffer t GetAccessors()->getPermissionRequestAccessor()->grant(self, static_cast(&resources_value)); } KOALA_INTEROP_DIRECT_V3(PermissionRequest_grant, Ark_NativePointer, KSerializerBuffer, int32_t) +KInteropReturnBuffer impl_PersistentStorageBackend_get(const KStringPtr& key) { + const auto &retValue = GetAccessors()->getPersistentStorageBackendAccessor()->get((const Ark_String*) (&key)); + SerializerBase _retSerializer {}; + Ark_Int32 retValue_type = INTEROP_RUNTIME_UNDEFINED; + retValue_type = runtimeType(retValue); + _retSerializer.writeInt8(retValue_type); + if ((retValue_type) != (INTEROP_RUNTIME_UNDEFINED)) { + const auto retValue_value = retValue.value; + _retSerializer.writeString(retValue_value); + } + return _retSerializer.toReturnBuffer(); +} +KOALA_INTEROP_1(PersistentStorageBackend_get, KInteropReturnBuffer, KStringPtr) +Ark_Boolean impl_PersistentStorageBackend_has(const KStringPtr& key) { + return GetAccessors()->getPersistentStorageBackendAccessor()->has((const Ark_String*) (&key)); +} +KOALA_INTEROP_1(PersistentStorageBackend_has, Ark_Boolean, KStringPtr) +void impl_PersistentStorageBackend_remove(const KStringPtr& key) { + GetAccessors()->getPersistentStorageBackendAccessor()->remove((const Ark_String*) (&key)); +} +KOALA_INTEROP_V1(PersistentStorageBackend_remove, KStringPtr) +void impl_PersistentStorageBackend_set(const KStringPtr& key, const KStringPtr& value) { + GetAccessors()->getPersistentStorageBackendAccessor()->set((const Ark_String*) (&key), (const Ark_String*) (&value)); +} +KOALA_INTEROP_V2(PersistentStorageBackend_set, KStringPtr, KStringPtr) +void impl_PersistentStorageBackend_clear() { + GetAccessors()->getPersistentStorageBackendAccessor()->clear(); +} +KOALA_INTEROP_DIRECT_V0(PersistentStorageBackend_clear) Ark_NativePointer impl_PinchGestureEvent_construct() { return GetAccessors()->getPinchGestureEventAccessor()->construct(); } diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/dummy_impl.cc b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/dummy_impl.cc index 0fcaf05c17e56b01f2e88f4f6ba62477aea046f8..65e75fd299e5c7647c2e79df7d02a612efb05312 100644 --- a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/dummy_impl.cc +++ b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/dummy_impl.cc @@ -889,6 +889,69 @@ namespace OHOS::Ace::NG::GeneratedModifier { } } // CommonMethodModifier + namespace EnvironmentBackendAccessor { + Ark_Boolean IsAccessibilityEnabledImpl() + { + if (needGroupedLog(1)) + { + string out("isAccessibilityEnabled() \n"); + out.append("[return false] \n"); + appendGroupedLog(1, out); + } + return false; + } + Ark_Int32 GetColorModeImpl() + { + if (needGroupedLog(1)) + { + string out("getColorMode() \n"); + out.append("[return 1] \n"); + appendGroupedLog(1, out); + } + return 1; + } + Ark_Float32 GetFontScaleImpl() + { + if (needGroupedLog(1)) + { + string out("getFontScale() \n"); + out.append("[return 1.0] \n"); + appendGroupedLog(1, out); + } + return 1.0; + } + Ark_Float32 GetFontWeightScaleImpl() + { + if (needGroupedLog(1)) + { + string out("getFontWeightScale() \n"); + out.append("[return 1.0] \n"); + appendGroupedLog(1, out); + } + return 1.0; + } + Ark_String GetLayoutDirectionImpl() + { + if (needGroupedLog(1)) + { + string out("getLayoutDirection() \n"); + out.append("[return \"LTR\"] \n"); + appendGroupedLog(1, out); + } + return { "LTR", 3 }; + } + Ark_String GetLanguageCodeImpl() + { + if (needGroupedLog(1)) + { + string out("getLanguageCode() \n"); + out.append("[return \"en\"] \n"); + appendGroupedLog(1, out); + } + return { "en", 2 }; + } + } // EnvironmentBackendAccessor + namespace EventEmulatorAccessor { void EmitClickEventImpl(Ark_NativePointer node, Ark_ClickEvent event) @@ -32972,6 +33035,80 @@ namespace OHOS::Ace::NG::GeneratedModifier { return reinterpret_cast(300); } } // EllipseShapeAccessor + namespace EnvironmentBackendAccessor { + Ark_Boolean IsAccessibilityEnabledImpl() + { + if (!needGroupedLog(1)) + { + return 0; + } + string out("isAccessibilityEnabled("); + out.append(") \n"); + out.append("[return 0] \n"); + appendGroupedLog(1, out); + return 0; + } + Ark_Int32 GetColorModeImpl() + { + if (!needGroupedLog(1)) + { + return 0; + } + string out("getColorMode("); + out.append(") \n"); + out.append("[return 0] \n"); + appendGroupedLog(1, out); + return 0; + } + Ark_Float32 GetFontScaleImpl() + { + if (!needGroupedLog(1)) + { + return 0; + } + string out("getFontScale("); + out.append(") \n"); + out.append("[return 0] \n"); + appendGroupedLog(1, out); + return 0; + } + Ark_Float32 GetFontWeightScaleImpl() + { + if (!needGroupedLog(1)) + { + return 0; + } + string out("getFontWeightScale("); + out.append(") \n"); + out.append("[return 0] \n"); + appendGroupedLog(1, out); + return 0; + } + Ark_String GetLayoutDirectionImpl() + { + if (!needGroupedLog(1)) + { + return {}; + } + string out("getLayoutDirection("); + out.append(") \n"); + out.append("[return {}] \n"); + appendGroupedLog(1, out); + return {}; + } + Ark_String GetLanguageCodeImpl() + { + if (!needGroupedLog(1)) + { + return {}; + } + string out("getLanguageCode("); + out.append(") \n"); + out.append("[return {}] \n"); + appendGroupedLog(1, out); + return {}; + } + } // EnvironmentBackendAccessor namespace EventEmulatorAccessor { void EmitTextInputEventImpl(Ark_NativePointer node, const Ark_String* text) @@ -40992,6 +41129,69 @@ namespace OHOS::Ace::NG::GeneratedModifier { appendGroupedLog(1, out); } } // PermissionRequestAccessor + namespace PersistentStorageBackendAccessor { + Opt_String GetImpl(const Ark_String* key) + { + if (!needGroupedLog(1)) + { + return {}; + } + string out("get("); + WriteToString(&out, key); + out.append(") \n"); + out.append("[return {}] \n"); + appendGroupedLog(1, out); + return {}; + } + Ark_Boolean HasImpl(const Ark_String* key) + { + if (!needGroupedLog(1)) + { + return 0; + } + string out("has("); + WriteToString(&out, key); + out.append(") \n"); + out.append("[return 0] \n"); + appendGroupedLog(1, out); + return 0; + } + void RemoveImpl(const Ark_String* key) + { + if (!needGroupedLog(1)) + { + return; + } + string out("remove("); + WriteToString(&out, key); + out.append(") \n"); + appendGroupedLog(1, out); + } + void SetImpl(const Ark_String* key, + const Ark_String* value) + { + if (!needGroupedLog(1)) + { + return; + } + string out("set("); + WriteToString(&out, key); + out.append(", "); + WriteToString(&out, value); + out.append(") \n"); + appendGroupedLog(1, out); + } + void ClearImpl() + { + if (!needGroupedLog(1)) + { + return; + } + string out("clear("); + out.append(") \n"); + appendGroupedLog(1, out); + } + } // PersistentStorageBackendAccessor namespace PinchGestureEventAccessor { void DestroyPeerImpl(Ark_PinchGestureEvent peer) { @@ -52917,6 +53117,19 @@ namespace OHOS::Ace::NG::GeneratedModifier { struct EllipseShapePeer { virtual ~EllipseShapePeer() = default; }; + const GENERATED_ArkUIEnvironmentBackendAccessor* GetEnvironmentBackendAccessor() + { + static const GENERATED_ArkUIEnvironmentBackendAccessor EnvironmentBackendAccessorImpl { + EnvironmentBackendAccessor::IsAccessibilityEnabledImpl, + EnvironmentBackendAccessor::GetColorModeImpl, + EnvironmentBackendAccessor::GetFontScaleImpl, + EnvironmentBackendAccessor::GetFontWeightScaleImpl, + EnvironmentBackendAccessor::GetLayoutDirectionImpl, + EnvironmentBackendAccessor::GetLanguageCodeImpl, + }; + return &EnvironmentBackendAccessorImpl; + } + const GENERATED_ArkUIEventEmulatorAccessor* GetEventEmulatorAccessor() { static const GENERATED_ArkUIEventEmulatorAccessor EventEmulatorAccessorImpl { @@ -54262,6 +54475,18 @@ namespace OHOS::Ace::NG::GeneratedModifier { struct PermissionRequestPeer { virtual ~PermissionRequestPeer() = default; }; + const GENERATED_ArkUIPersistentStorageBackendAccessor* GetPersistentStorageBackendAccessor() + { + static const GENERATED_ArkUIPersistentStorageBackendAccessor PersistentStorageBackendAccessorImpl { + PersistentStorageBackendAccessor::GetImpl, + PersistentStorageBackendAccessor::HasImpl, + PersistentStorageBackendAccessor::RemoveImpl, + PersistentStorageBackendAccessor::SetImpl, + PersistentStorageBackendAccessor::ClearImpl, + }; + return &PersistentStorageBackendAccessorImpl; + } + const GENERATED_ArkUIPinchGestureEventAccessor* GetPinchGestureEventAccessor() { static const GENERATED_ArkUIPinchGestureEventAccessor PinchGestureEventAccessorImpl { @@ -56071,6 +56296,7 @@ namespace OHOS::Ace::NG::GeneratedModifier { GetDrawingRenderingContextAccessor, GetDrawModifierAccessor, GetEllipseShapeAccessor, + GetEnvironmentBackendAccessor, GetEventEmulatorAccessor, GetEventResultAccessor, GetEventTargetInfoAccessor, @@ -56145,6 +56371,7 @@ namespace OHOS::Ace::NG::GeneratedModifier { GetPathShapeAccessor, GetPatternLockControllerAccessor, GetPermissionRequestAccessor, + GetPersistentStorageBackendAccessor, GetPinchGestureEventAccessor, GetPinchGestureInterfaceAccessor, GetPinchRecognizerAccessor, diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/real_impl.cc b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/real_impl.cc index df27d2e3f00c3e930d3ca3b06b6304d092a237a1..609c6f069b48418bc6ecba1ef224368873c9eb21 100644 --- a/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/real_impl.cc +++ b/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/framework/native/src/generated/real_impl.cc @@ -889,6 +889,69 @@ namespace OHOS::Ace::NG::GeneratedModifier { } } // CommonMethodModifier + namespace EnvironmentBackendAccessor { + Ark_Boolean IsAccessibilityEnabledImpl() + { + if (needGroupedLog(1)) + { + string out("isAccessibilityEnabled() \n"); + out.append("[return false] \n"); + appendGroupedLog(1, out); + } + return false; + } + Ark_Int32 GetColorModeImpl() + { + if (needGroupedLog(1)) + { + string out("getColorMode() \n"); + out.append("[return 1] \n"); + appendGroupedLog(1, out); + } + return 1; + } + Ark_Float32 GetFontScaleImpl() + { + if (needGroupedLog(1)) + { + string out("getFontScale() \n"); + out.append("[return 1.0] \n"); + appendGroupedLog(1, out); + } + return 1.0; + } + Ark_Float32 GetFontWeightScaleImpl() + { + if (needGroupedLog(1)) + { + string out("getFontWeightScale() \n"); + out.append("[return 1.0] \n"); + appendGroupedLog(1, out); + } + return 1.0; + } + Ark_String GetLayoutDirectionImpl() + { + if (needGroupedLog(1)) + { + string out("getLayoutDirection() \n"); + out.append("[return \"LTR\"] \n"); + appendGroupedLog(1, out); + } + return { "LTR", 3 }; + } + Ark_String GetLanguageCodeImpl() + { + if (needGroupedLog(1)) + { + string out("getLanguageCode() \n"); + out.append("[return \"en\"] \n"); + appendGroupedLog(1, out); + } + return { "en", 2 }; + } + } // EnvironmentBackendAccessor + namespace EventEmulatorAccessor { void EmitClickEventImpl(Ark_NativePointer node, Ark_ClickEvent event) @@ -13915,6 +13978,32 @@ namespace OHOS::Ace::NG::GeneratedModifier { return {}; } } // EllipseShapeAccessor + namespace EnvironmentBackendAccessor { + Ark_Boolean IsAccessibilityEnabledImpl() + { + return {}; + } + Ark_Int32 GetColorModeImpl() + { + return {}; + } + Ark_Float32 GetFontScaleImpl() + { + return {}; + } + Ark_Float32 GetFontWeightScaleImpl() + { + return {}; + } + Ark_String GetLayoutDirectionImpl() + { + return {}; + } + Ark_String GetLanguageCodeImpl() + { + return {}; + } + } // EnvironmentBackendAccessor namespace EventEmulatorAccessor { void EmitClickEventImpl(Ark_NativePointer node, Ark_ClickEvent event) @@ -16924,6 +17013,26 @@ namespace OHOS::Ace::NG::GeneratedModifier { { } } // PermissionRequestAccessor + namespace PersistentStorageBackendAccessor { + Opt_String GetImpl(const Ark_String* key) + { + return {}; + } + Ark_Boolean HasImpl(const Ark_String* key) + { + return {}; + } + void RemoveImpl(const Ark_String* key) + { + } + void SetImpl(const Ark_String* key, + const Ark_String* value) + { + } + void ClearImpl() + { + } + } // PersistentStorageBackendAccessor namespace PinchGestureEventAccessor { void DestroyPeerImpl(Ark_PinchGestureEvent peer) { @@ -22308,6 +22417,19 @@ namespace OHOS::Ace::NG::GeneratedModifier { struct EllipseShapePeer { virtual ~EllipseShapePeer() = default; }; + const GENERATED_ArkUIEnvironmentBackendAccessor* GetEnvironmentBackendAccessor() + { + static const GENERATED_ArkUIEnvironmentBackendAccessor EnvironmentBackendAccessorImpl { + EnvironmentBackendAccessor::IsAccessibilityEnabledImpl, + EnvironmentBackendAccessor::GetColorModeImpl, + EnvironmentBackendAccessor::GetFontScaleImpl, + EnvironmentBackendAccessor::GetFontWeightScaleImpl, + EnvironmentBackendAccessor::GetLayoutDirectionImpl, + EnvironmentBackendAccessor::GetLanguageCodeImpl, + }; + return &EnvironmentBackendAccessorImpl; + } + const GENERATED_ArkUIEventEmulatorAccessor* GetEventEmulatorAccessor() { static const GENERATED_ArkUIEventEmulatorAccessor EventEmulatorAccessorImpl { @@ -23653,6 +23775,18 @@ namespace OHOS::Ace::NG::GeneratedModifier { struct PermissionRequestPeer { virtual ~PermissionRequestPeer() = default; }; + const GENERATED_ArkUIPersistentStorageBackendAccessor* GetPersistentStorageBackendAccessor() + { + static const GENERATED_ArkUIPersistentStorageBackendAccessor PersistentStorageBackendAccessorImpl { + PersistentStorageBackendAccessor::GetImpl, + PersistentStorageBackendAccessor::HasImpl, + PersistentStorageBackendAccessor::RemoveImpl, + PersistentStorageBackendAccessor::SetImpl, + PersistentStorageBackendAccessor::ClearImpl, + }; + return &PersistentStorageBackendAccessorImpl; + } + const GENERATED_ArkUIPinchGestureEventAccessor* GetPinchGestureEventAccessor() { static const GENERATED_ArkUIPinchGestureEventAccessor PinchGestureEventAccessorImpl { @@ -25462,6 +25596,7 @@ namespace OHOS::Ace::NG::GeneratedModifier { GetDrawingRenderingContextAccessor, GetDrawModifierAccessor, GetEllipseShapeAccessor, + GetEnvironmentBackendAccessor, GetEventEmulatorAccessor, GetEventResultAccessor, GetEventTargetInfoAccessor, @@ -25536,6 +25671,7 @@ namespace OHOS::Ace::NG::GeneratedModifier { GetPathShapeAccessor, GetPatternLockControllerAccessor, GetPermissionRequestAccessor, + GetPersistentStorageBackendAccessor, GetPinchGestureEventAccessor, GetPinchGestureInterfaceAccessor, GetPinchRecognizerAccessor, diff --git a/frameworks/core/interfaces/native/generated/interface/arkoala_api_generated.h b/frameworks/core/interfaces/native/generated/interface/arkoala_api_generated.h index f4161f75ff42503e95ff4b724db5446a4f79913b..b71345548bea77a2c633bfb3beaaf611d4b6b978 100644 --- a/frameworks/core/interfaces/native/generated/interface/arkoala_api_generated.h +++ b/frameworks/core/interfaces/native/generated/interface/arkoala_api_generated.h @@ -25958,6 +25958,15 @@ typedef struct GENERATED_ArkUIDragEventAccessor { Ark_Boolean useCustomDropAnimation); } GENERATED_ArkUIDragEventAccessor; +typedef struct GENERATED_ArkUIEnvironmentBackendAccessor { + Ark_Boolean (*isAccessibilityEnabled)(); + Ark_Int32 (*getColorMode)(); + Ark_Float32 (*getFontScale)(); + Ark_Float32 (*getFontWeightScale)(); + Ark_String (*getLayoutDirection)(); + Ark_String (*getLanguageCode)(); +} GENERATED_ArkUIEnvironmentBackendAccessor; + typedef struct GENERATED_ArkUIKeyEventAccessor { void (*destroyPeer)(Ark_KeyEvent peer); Ark_KeyEvent (*ctor)(); @@ -26894,6 +26903,15 @@ typedef struct GENERATED_ArkUISwipeGestureInterfaceAccessor { const Callback_GestureEvent_Void* event); } GENERATED_ArkUISwipeGestureInterfaceAccessor; +typedef struct GENERATED_ArkUIPersistentStorageBackendAccessor { + Opt_String (*get)(const Ark_String* key); + Ark_Boolean (*has)(const Ark_String* key); + void (*remove)(const Ark_String* key); + void (*set)(const Ark_String* key, + const Ark_String* value); + void (*clear)(); +} GENERATED_ArkUIPersistentStorageBackendAccessor; + typedef struct GENERATED_ArkUIPinchGestureInterfaceAccessor { void (*destroyPeer)(Ark_PinchGestureInterface peer); Ark_PinchGestureInterface (*ctor)(const Opt_Literal_Number_distance_fingers* value); @@ -28407,6 +28425,7 @@ typedef struct GENERATED_ArkUIAccessors { const GENERATED_ArkUILazyForEachOpsAccessor* (*getLazyForEachOpsAccessor)(); const GENERATED_ArkUISystemOpsAccessor* (*getSystemOpsAccessor)(); const GENERATED_ArkUIGestureOpsAccessor* (*getGestureOpsAccessor)(); + const GENERATED_ArkUIEnvironmentBackendAccessor* (*getEnvironmentBackendAccessor)(); const GENERATED_ArkUIFocusControllerAccessor* (*getFocusControllerAccessor)(); const GENERATED_ArkUIComponentContentAccessor* (*getComponentContentAccessor)(); const GENERATED_ArkUISceneAccessor* (*getSceneAccessor)(); @@ -28515,6 +28534,7 @@ typedef struct GENERATED_ArkUIAccessors { const GENERATED_ArkUICanvasPatternAccessor* (*getCanvasPatternAccessor)(); const GENERATED_ArkUIImageBitmapAccessor* (*getImageBitmapAccessor)(); const GENERATED_ArkUIImageDataAccessor* (*getImageDataAccessor)(); + const GENERATED_ArkUIPersistentStorageBackendAccessor* (*getPersistentStorageBackendAccessor)(); const GENERATED_ArkUIRenderingContextSettingsAccessor* (*getRenderingContextSettingsAccessor)(); const GENERATED_ArkUICanvasRendererAccessor* (*getCanvasRendererAccessor)(); const GENERATED_ArkUICanvasRenderingContext2DAccessor* (*getCanvasRenderingContext2DAccessor)(); diff --git a/frameworks/core/interfaces/native/generated/interface/node_interface.gni b/frameworks/core/interfaces/native/generated/interface/node_interface.gni index f262bd0bedad35eea48693628dc0460e11f067ee..1d5a96231e77ea4ddcac8ba2d0d889fd1d1463d6 100644 --- a/frameworks/core/interfaces/native/generated/interface/node_interface.gni +++ b/frameworks/core/interfaces/native/generated/interface/node_interface.gni @@ -105,6 +105,7 @@ generated_sources = [ "implementation/embedded_component_modifier.cpp", "implementation/side_bar_container_ops_accessor.cpp", "implementation/stepper_ops_accessor.cpp", + "implementation/environment_backend_accessor.cpp", "implementation/event_emulator_accessor.cpp", "implementation/text_field_ops_accessor.cpp", "implementation/event_result_accessor.cpp", @@ -224,6 +225,7 @@ generated_sources = [ "implementation/pattern_lock_controller_accessor.cpp", "implementation/pattern_lock_modifier.cpp", "implementation/permission_request_accessor.cpp", + "implementation/persistent_storage_backend_accessor.cpp", "implementation/pinch_gesture_event_accessor.cpp", "implementation/pinch_gesture_interface_accessor.cpp", "implementation/pinch_recognizer_accessor.cpp", diff --git a/frameworks/core/interfaces/native/implementation/all_modifiers.cpp b/frameworks/core/interfaces/native/implementation/all_modifiers.cpp index 0c3820f78596cc39be8d2faca1364b736c75002d..dd4ad4a646524694c7989330a7df657a678e6ce9 100644 --- a/frameworks/core/interfaces/native/implementation/all_modifiers.cpp +++ b/frameworks/core/interfaces/native/implementation/all_modifiers.cpp @@ -216,6 +216,7 @@ const GENERATED_ArkUIUnifiedDataAccessor* GetUnifiedDataAccessor(); const GENERATED_ArkUILazyForEachOpsAccessor* GetLazyForEachOpsAccessor(); const GENERATED_ArkUISystemOpsAccessor* GetSystemOpsAccessor(); const GENERATED_ArkUIGestureOpsAccessor* GetGestureOpsAccessor(); +const GENERATED_ArkUIEnvironmentBackendAccessor* GetEnvironmentBackendAccessor(); const GENERATED_ArkUIFocusControllerAccessor* GetFocusControllerAccessor(); const GENERATED_ArkUIComponentContentAccessor* GetComponentContentAccessor(); const GENERATED_ArkUISceneAccessor* GetSceneAccessor(); @@ -324,6 +325,7 @@ const GENERATED_ArkUIPath2DAccessor* GetPath2DAccessor(); const GENERATED_ArkUICanvasPatternAccessor* GetCanvasPatternAccessor(); const GENERATED_ArkUIImageBitmapAccessor* GetImageBitmapAccessor(); const GENERATED_ArkUIImageDataAccessor* GetImageDataAccessor(); +const GENERATED_ArkUIPersistentStorageBackendAccessor* GetPersistentStorageBackendAccessor(); const GENERATED_ArkUIRenderingContextSettingsAccessor* GetRenderingContextSettingsAccessor(); const GENERATED_ArkUICanvasRendererAccessor* GetCanvasRendererAccessor(); const GENERATED_ArkUICanvasRenderingContext2DAccessor* GetCanvasRenderingContext2DAccessor(); @@ -586,6 +588,7 @@ const GENERATED_ArkUIAccessors* GENERATED_GetArkUIAccessors() GetLazyForEachOpsAccessor, GetSystemOpsAccessor, GetGestureOpsAccessor, + GetEnvironmentBackendAccessor, GetFocusControllerAccessor, GetComponentContentAccessor, GetSceneAccessor, @@ -694,6 +697,7 @@ const GENERATED_ArkUIAccessors* GENERATED_GetArkUIAccessors() GetCanvasPatternAccessor, GetImageBitmapAccessor, GetImageDataAccessor, + GetPersistentStorageBackendAccessor, GetRenderingContextSettingsAccessor, GetCanvasRendererAccessor, GetCanvasRenderingContext2DAccessor, diff --git a/frameworks/core/interfaces/native/implementation/environment_backend_accessor.cpp b/frameworks/core/interfaces/native/implementation/environment_backend_accessor.cpp new file mode 100755 index 0000000000000000000000000000000000000000..119b0e197de8905b1c0a3f560868bd7bcfb8e5c6 --- /dev/null +++ b/frameworks/core/interfaces/native/implementation/environment_backend_accessor.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2024-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 "core/components_ng/base/frame_node.h" +#include "core/interfaces/native/utility/converter.h" +#include "arkoala_api_generated.h" + +#include "base/memory/referenced.h" +#include "base/i18n/localization.h" +#include "core/common/ace_engine.h" +#include "core/common/ace_application_info.h" +#include "core/common/container.h" +#include "core/common/storage/storage_proxy.h" +#include "core/common/environment/environment_proxy.h" +#include "core/interfaces/native/utility/reverse_converter.h" +#include "core/pipeline/pipeline_base.h" + +namespace OHOS::Ace::NG::GeneratedModifier { +namespace EnvironmentBackendAccessor { +Ark_Boolean IsAccessibilityEnabledImpl() +{ + const auto defaultValue = Converter::ArkValue(false); + std::string value; +#if defined(PREVIEW) + value = "false"; +#else + auto container = Container::Current(); + if (!container) { + LOGW("container is null"); + return defaultValue; + } + auto executor = container->GetTaskExecutor(); + value = EnvironmentProxy::GetInstance()->GetEnvironment(executor)->GetAccessibilityEnabled(); +#endif + if (value == "true") { + return Converter::ArkValue(true); + } + return defaultValue; +} +Ark_Int32 GetColorModeImpl() +{ + auto colorMode = Container::CurrentColorMode(); + return Converter::ArkValue(static_cast(colorMode)); +} +Ark_Float32 GetFontScaleImpl() +{ + const auto errValue = Converter::ArkValue(0.0f); + auto container = Container::Current(); + if (!container) { + LOGW("container is null"); + return errValue; + } + auto context = container->GetPipelineContext(); + if (!context) { + LOGW("context is null"); + return errValue; + } + auto returnValue = context->GetFontScale(); + return Converter::ArkValue(returnValue); +} +Ark_Float32 GetFontWeightScaleImpl() +{ + auto weightScale = SystemProperties::GetFontWeightScale(); + return Converter::ArkValue(weightScale);; +} +Ark_String GetLayoutDirectionImpl() +{ + auto isRTL = AceApplicationInfo::GetInstance().IsRightToLeft(); + auto value = isRTL ? 0 : 1; + auto strValue = std::to_string(value); + return Converter::ArkValue(strValue, Converter::FC); +} +Ark_String GetLanguageCodeImpl() +{ + const auto errValue = Converter::ArkValue("", Converter::FC); + auto container = Container::Current(); + if (!container) { + LOGW("Initialize is not complete, cannot get the language"); + return errValue; + } + auto location = Localization::GetInstance(); + CHECK_NULL_RETURN(location, errValue); + return Converter::ArkValue(location->GetLanguage(), Converter::FC); +} +} // EnvironmentBackendAccessor +const GENERATED_ArkUIEnvironmentBackendAccessor* GetEnvironmentBackendAccessor() +{ + static const GENERATED_ArkUIEnvironmentBackendAccessor EnvironmentBackendAccessorImpl { + EnvironmentBackendAccessor::IsAccessibilityEnabledImpl, + EnvironmentBackendAccessor::GetColorModeImpl, + EnvironmentBackendAccessor::GetFontScaleImpl, + EnvironmentBackendAccessor::GetFontWeightScaleImpl, + EnvironmentBackendAccessor::GetLayoutDirectionImpl, + EnvironmentBackendAccessor::GetLanguageCodeImpl, + }; + return &EnvironmentBackendAccessorImpl; +} + +} diff --git a/frameworks/core/interfaces/native/implementation/persistent_storage_backend_accessor.cpp b/frameworks/core/interfaces/native/implementation/persistent_storage_backend_accessor.cpp new file mode 100755 index 0000000000000000000000000000000000000000..9fc14660bdd750651ca5835c161c9d577867eff3 --- /dev/null +++ b/frameworks/core/interfaces/native/implementation/persistent_storage_backend_accessor.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2024-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 "core/components_ng/base/frame_node.h" +#include "core/interfaces/native/utility/converter.h" +#include "arkoala_api_generated.h" + +#include "base/memory/referenced.h" +#include "base/i18n/localization.h" +#include "core/common/ace_engine.h" +#include "core/common/ace_application_info.h" +#include "core/common/container.h" +#include "core/common/storage/storage_proxy.h" +#include "core/common/environment/environment_proxy.h" +#include "core/interfaces/native/utility/reverse_converter.h" +#include "core/pipeline/pipeline_base.h" + +namespace OHOS::Ace::NG::GeneratedModifier { +namespace PersistentStorageBackendAccessor { +Opt_String GetImpl(const Ark_String* key) +{ + const auto errValue = Converter::ArkValue("", Converter::FC); +#if defined(PREVIEW) + LOGW("[Engine Log] Unable to use the PersistentStorage in the Previewer. Perform this operation on the " + "emulator or a real device instead."); + return errValue; +#endif + auto storage = StorageProxy::GetInstance()->GetStorage(); + if (!storage) { + LOGW("no storage available"); + return errValue; + } + CHECK_NULL_RETURN(key, errValue); + auto keyValue = Converter::Convert(*key); + std::string value = storage->GetString(keyValue); + if (value.empty()) { + LOGE("value is empty"); + } + return Converter::ArkValue(value, Converter::FC); +} +Ark_Boolean HasImpl(const Ark_String* key) +{ + auto defaultValue = Converter::ArkValue(false); +#if defined(PREVIEW) + LOGW("[Engine Log] Unable to use the PersistentStorage in the Previewer. Perform this operation on the " + "emulator or a real device instead."); + return defaultValue; +#endif + if (!StorageProxy::GetInstance()->GetStorage()) { + LOGW("no storage available"); + return defaultValue; + } + CHECK_NULL_RETURN(key, defaultValue); + auto keyValue = Converter::Convert(*key); + std::string value = StorageProxy::GetInstance()->GetStorage()->GetString(keyValue); + if (!value.empty()) { + return Converter::ArkValue(true); + } + return defaultValue; +} +void RemoveImpl(const Ark_String* key) +{ +#if defined(PREVIEW) + LOGW("[Engine Log] Unable to use the PersistentStorage in the Previewer. Perform this operation on the " + "emulator or a real device instead."); + return; +#endif + if (!StorageProxy::GetInstance()->GetStorage()) { + LOGW("no storage available"); + return; + } + CHECK_NULL_VOID(key); + auto keyValue = Converter::Convert(*key); + StorageProxy::GetInstance()->GetStorage()->Delete(keyValue); +} +void SetImpl(const Ark_String* key, + const Ark_String* value) +{ +#if defined(PREVIEW) + LOGW("[Engine Log] Unable to use the PersistentStorage in the Previewer. Perform this operation on the " + "emulator or a real device instead."); + return; +#endif + if (!StorageProxy::GetInstance()->GetStorage()) { + LOGW("no storage available"); + return; + } + CHECK_NULL_VOID(key); + auto keyValue = Converter::Convert(*key); + CHECK_NULL_VOID(value); + auto convertedValue = Converter::Convert(*value); + StorageProxy::GetInstance()->GetStorage()->SetString(keyValue, convertedValue); + +} +void ClearImpl() +{ +#if defined(PREVIEW) + LOGW("[Engine Log] Unable to use the PersistentStorage in the Previewer. Perform this operation on the " + "emulator or a real device instead."); + return; +#endif + if (!StorageProxy::GetInstance()->GetStorage()) { + LOGW("no storage available"); + return; + } + StorageProxy::GetInstance()->GetStorage()->Clear(); +} +} // PersistentStorageBackendAccessor +const GENERATED_ArkUIPersistentStorageBackendAccessor* GetPersistentStorageBackendAccessor() +{ + static const GENERATED_ArkUIPersistentStorageBackendAccessor PersistentStorageBackendAccessorImpl { + PersistentStorageBackendAccessor::GetImpl, + PersistentStorageBackendAccessor::HasImpl, + PersistentStorageBackendAccessor::RemoveImpl, + PersistentStorageBackendAccessor::SetImpl, + PersistentStorageBackendAccessor::ClearImpl, + }; + return &PersistentStorageBackendAccessorImpl; +} + +}