From 978d7e1492649831c7db74f577ddf580ac577f7b Mon Sep 17 00:00:00 2001 From: some-one-mmx Date: Wed, 11 Jun 2025 21:32:51 +0800 Subject: [PATCH] add blankless ndk api Signed-off-by: some-one-mmx --- .../interfaces/native/arkweb_error_code.h | 58 ++++++++++++++++++ .../interfaces/native/libohweb.ndk.json | 16 +++++ .../native/native_interface_arkweb.h | 60 +++++++++++++++++++ 3 files changed, 134 insertions(+) diff --git a/web/webview/interfaces/native/arkweb_error_code.h b/web/webview/interfaces/native/arkweb_error_code.h index 4caab8f5d..6865c29be 100644 --- a/web/webview/interfaces/native/arkweb_error_code.h +++ b/web/webview/interfaces/native/arkweb_error_code.h @@ -71,5 +71,63 @@ ARKWEB_LIBRARY_OPEN_FAILURE = 17100105, ARKWEB_LIBRARY_SYMBOL_NOT_FOUND = 17100106, } ArkWeb_ErrorCode; +typedef enum ArkWeb_BlanklessErrorCode { +/* + * @brief Success. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +ARKWEB_BLANKLESS_SUCCESS = 0, + +/* + * @brief Unknown error. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +ARKWEB_BLANKLESS_ERR_UNKNOWN = -1, + +/* + * @brief Invalid args. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +ARKWEB_BLANKLESS_ERR_INVALID_ARGS = -2, + +/* + * @brief Init error. The web controller is not binded with the component. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +ARKWEB_BLANKLESS_ERR_CONTROLLER_NOT_INITED = -3, + +/* + * @brief The key of blankless was not matched. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +ARKWEB_BLANKLESS_KEY_NOT_MATCH = -4, + +/* + * @brief There are significant changes for the loading page. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +ARKWEB_BLANKLESS_SIGNIFICANT_CHANGE = -5, + +/* + * @brief Device not support. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +ARKWEB_BLANKLESS_ERR_DEVICE_NOT_SUPPORT = 801, +} ArkWeb_BlanklessErrorCode; + #endif // ARKWEB_ERROR_CODE_H /** @} */ diff --git a/web/webview/interfaces/native/libohweb.ndk.json b/web/webview/interfaces/native/libohweb.ndk.json index aa5489f4a..5438e63f5 100644 --- a/web/webview/interfaces/native/libohweb.ndk.json +++ b/web/webview/interfaces/native/libohweb.ndk.json @@ -326,5 +326,21 @@ { "first_introduced": "20", "name": "OH_NativeArkWeb_RegisterAsyncThreadJavaScriptProxy" + }, + { + "first_introduced": "20", + "name": "OH_NativeArkWeb_GetBlanklessInfoWithKey" + }, + { + "first_introduced": "20", + "name": "OH_NativeArkWeb_SetBlanklessLoadingWithKey" + }, + { + "first_introduced": "20", + "name": "OH_NativeArkWeb_ClearBlanklessLoadingCache" + }, + { + "first_introduced": "20", + "name": "OH_NativeArkWeb_SetBlanklessLoadingCacheCapacity" } ] diff --git a/web/webview/interfaces/native/native_interface_arkweb.h b/web/webview/interfaces/native/native_interface_arkweb.h index 9df320d8c..a6e67a8f8 100644 --- a/web/webview/interfaces/native/native_interface_arkweb.h +++ b/web/webview/interfaces/native/native_interface_arkweb.h @@ -70,6 +70,20 @@ typedef void (*NativeArkWeb_OnValidCallback)(const char*); */ typedef void (*NativeArkWeb_OnDestroyCallback)(const char*); +/** + * @brief Defines the blankless info. + * + * @since 20 + */ +typedef struct { + /** The errCode of the blankless. */ + ArkWeb_BlanklessErrorCode errCode; + /** The estimated similarity of the history snapshots. */ + double similarity; + /** The loadingTime of the history loading. */ + int32_t loadingTime; +} ArkWeb_BlanklessInfo; + /** * @brief Loads a piece of code and execute JS code in the context of the currently displayed page. * @@ -203,6 +217,52 @@ ArkWeb_ErrorCode OH_NativeArkWeb_LoadData(const char* webTag, void OH_NativeArkWeb_RegisterAsyncThreadJavaScriptProxy(const char* webTag, const ArkWeb_ProxyObjectWithResult* proxyObject, const char* permission); +/** + * @brief get the white screen optimization info when the current page is loaded. + * + * @param webTag The name of the web component. + * @param key A key string of the loading page, should not be NULL. + * @return Blankless info. + * + * @since 20 + */ +ArkWeb_BlanklessInfo OH_NativeArkWeb_GetBlanklessInfoWithKey(const char* webTag, const char* key); + +/** + * @brief set the white screen optimization solution when the current page is loaded. + * + * @param webTag The name of the web component. + * @param key A key string of the loading page, should not be NULL. + * @param isStarted If enabled blankless. + * @return Blankless result code. + * + * @since 20 + */ +ArkWeb_BlanklessErrorCode OH_NativeArkWeb_SetBlanklessLoadingWithKey(const char* webTag, + const char* key, + bool isStarted); + +/** + * @brief The apps can use this interface to clear the page cache. The "Clear Page" + * here is within the page range set in the API getBlanklessInfoWithKey. + * + * @param key A array of key string. + * @param size The number of elements in the key array. + * + * @since 20 + */ +void OH_NativeArkWeb_ClearBlanklessLoadingCache(const char* key[], uint32_t size); + +/** + * @brief Set the capacity of the blankless cache. + * + * @param capacity The blankless capacity the apps want to set. + * @return The real blankless capacity, 0-100. + * + * @since 20 + */ +uint32_t OH_NativeArkWeb_SetBlanklessLoadingCacheCapacity(uint32_t capacity); + #ifdef __cplusplus }; #endif -- Gitee