From 13eeba5249b97fdf6efaffc7c2792b8dc9a53278 Mon Sep 17 00:00:00 2001 From: liminjie10 Date: Fri, 9 Dec 2022 11:18:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0settingsdata=E7=9A=84.d.t?= =?UTF-8?q?s=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liminjie10 --- api/@ohos.settings.d.ts | 142 ++++++++++++++++++++++++++++------------ 1 file changed, 101 insertions(+), 41 deletions(-) diff --git a/api/@ohos.settings.d.ts b/api/@ohos.settings.d.ts index 34beb2931d..17f8783dbe 100644 --- a/api/@ohos.settings.d.ts +++ b/api/@ohos.settings.d.ts @@ -769,19 +769,97 @@ declare namespace settings { */ const WIFI_WATCHDOG_STATUS: string } + + /** + * Enables or disables airplane mode. + * + * @param enable Specifies whether to enable airplane mode. The value {@code true} means to enable airplane + * mode, and {@code false} means to disable airplane mode. + * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @since 7 + */ + function enableAirplaneMode(enable: boolean, callback: AsyncCallback): void; + function enableAirplaneMode(enable: boolean): Promise; + + /** + * Checks whether a specified application can show as float window. + * + * @param context Indicates the application context. + * @return Returns {@code true} if the application can draw over other applications; returns {@code false} + * otherwise. + * @since 7 + */ + function canShowFloating(callback: AsyncCallback): void; + function canShowFloating(): Promise; /** * Constructs a URI for a specific name-value pair for monitoring data of the ability that uses the Data * template. - * * @param name Indicates the name of the setting to set. * @returns Returns the corresponding URI; returns {@code null} if the URI does not exist. * @since 7 */ - function getURI(name: string, callback: AsyncCallback): void; - function getURI(name: string): Promise; + function getURI(name: string, callback: AsyncCallback): void; + function getURI(name: string): Promise; /** + * get settingsdata uri(synchronization method) + * @since 8 + * @param name Indicates the name of the setting to set. + * @return Return settingsdata uri. + */ + function getUriSync(name: string): string; + + /** + * get value from settingsdata + * @since 9 + * @param context Indicates the Context or dataAbilityHelper used to access + * the database. + * @param name Indicates the name of the character string. + * @return Returns the value of the character string in the table if any is found; returns {@code null} + * otherwise. + * @StageModelOnly + */ + function getValue(context: Context, name: string, callback: AsyncCallback): void; + function getValue(context: Context, name: string): Promise; + + /** + * get value from settingsdata(synchronization method) + * @since 9 + * @param context Indicates Context or dataAbilityHelper instance + * @param name Indicates the name of the character string. + * @param defValue Indicates the default value of the character string. + * @return settingsdata value + * @StageModelOnly + */ + function getValueSync(context: Context, name: string, defValue: string): string; + + /** + * set settingsdata value. + * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * @since 9 + * @param context Indicates Context or dataAbilityHelper instance + * @param name Indicates the name of the character string. + * @param value Indicates the value of the character string. + * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @StageModelOnly + */ + function setValue(context: Context, name: string, value: string, callback: AsyncCallback): void; + function setValue(context: Context, name: string, value: string): Promise; + + /** + * set settingsdata value(synchronization method) + * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * @since 9 + * @param context Indicates Context or dataAbilityHelper instance + * @param name Indicates the name of the character string. + * @param value Indicates the value of the character string. + * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @StageModelOnly + */ + function setValueSync(context: Context, name: string, value: string): boolean; + + /** * Obtains the value of a specified character string in the database. * * @param dataAbilityHelper Indicates the {@link ohos.aafwk.ability.DataAbilityHelper} used to access @@ -790,13 +868,15 @@ declare namespace settings { * @returns Returns the value of the character string in the table if any is found; returns {@code null} * otherwise. * @since 7 + * @deprecated since 9 + * @useinstead getValue(context: context...) + * @FAModelOnly */ - function getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback): void; - function getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise; + function getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback): void; + function getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise; /** * Saves a character string name and its value to the database. - * * @param dataAbilityHelper Indicates the {@link ohos.aafwk.ability.DataAbilityHelper} used to access * the database. * @param name Indicates the name of the character string. @@ -804,39 +884,12 @@ declare namespace settings { * @returns Returns {@code true} if the operation is successful; returns {@code false} otherwise. * @since 7 * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead setValue(context: context...) + * @FAModelOnly */ - function setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, callback: AsyncCallback): void; - function setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Promise; - - /** - * Enables or disables airplane mode. - * - * @param enable Specifies whether to enable airplane mode. The value {@code true} means to enable airplane - * mode, and {@code false} means to disable airplane mode. - * @returns Returns {@code true} if the operation is successful; returns {@code false} otherwise. - * @since 7 - */ - function enableAirplaneMode(enable: boolean, callback: AsyncCallback): void; - function enableAirplaneMode(enable: boolean): Promise; - - /** - * Checks whether a specified application can show as float window. - * - * @param context Indicates the application context. - * @returns Returns {@code true} if the application can draw over other applications; returns {@code false} - * otherwise. - * @since 7 - */ - function canShowFloating(callback: AsyncCallback): void; - function canShowFloating(): Promise; - - /** - * get settingsdata uri(synchronization method) - * @since 8 - * @param name Indicates the name of the setting to set. - * @returns Return settingsdata uri. - */ - function getUriSync(name: string): string; + function setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: string, callback: AsyncCallback): void; + function setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: string): Promise; /** * get value from settingsdata(synchronization method) @@ -844,20 +897,27 @@ declare namespace settings { * @param dataAbilityHelper Indicates dataAbilityHelper instance * @param name Indicates the name of the character string. * @param defValue Indicates the default value of the character string. - * @returns settingsdata value + * @return settingsdata value + * @deprecated since 9 + * @useinstead getValueSync(context: context...) + * @FAModelOnly */ function getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string; /** * set settingsdata value(synchronization method) - * @need permission ohos.permission.WRITE_SYSTEM_SETTING + * @permission ohos.permission.MANAGE_SECURE_SETTINGS * @since 8 * @param dataAbilityHelper Indicates dataAbilityHelper instance * @param name Indicates the name of the character string. * @param value Indicates the value of the character string. - * @returns Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @deprecated since 9 + * @useinstead setValueSync(context: context...) + * @FAModelOnly */ function setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean; + } export default settings; \ No newline at end of file -- Gitee From f05e1f39b97f6928001c7f335d295a934b013056 Mon Sep 17 00:00:00 2001 From: liminjie10 Date: Fri, 9 Dec 2022 07:03:53 +0000 Subject: [PATCH 2/2] update api/@ohos.settings.d.ts. Signed-off-by: liminjie10 --- api/@ohos.settings.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api/@ohos.settings.d.ts b/api/@ohos.settings.d.ts index 17f8783dbe..a6b89532df 100644 --- a/api/@ohos.settings.d.ts +++ b/api/@ohos.settings.d.ts @@ -775,7 +775,7 @@ declare namespace settings { * * @param enable Specifies whether to enable airplane mode. The value {@code true} means to enable airplane * mode, and {@code false} means to disable airplane mode. - * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @returns Returns {@code true} if the operation is successful; returns {@code false} otherwise. * @since 7 */ function enableAirplaneMode(enable: boolean, callback: AsyncCallback): void; @@ -785,7 +785,7 @@ declare namespace settings { * Checks whether a specified application can show as float window. * * @param context Indicates the application context. - * @return Returns {@code true} if the application can draw over other applications; returns {@code false} + * @returns Returns {@code true} if the application can draw over other applications; returns {@code false} * otherwise. * @since 7 */ @@ -806,7 +806,7 @@ declare namespace settings { * get settingsdata uri(synchronization method) * @since 8 * @param name Indicates the name of the setting to set. - * @return Return settingsdata uri. + * @returns Returns settingsdata uri. */ function getUriSync(name: string): string; @@ -816,7 +816,7 @@ declare namespace settings { * @param context Indicates the Context or dataAbilityHelper used to access * the database. * @param name Indicates the name of the character string. - * @return Returns the value of the character string in the table if any is found; returns {@code null} + * @returns Returns the value of the character string in the table if any is found; returns {@code null} * otherwise. * @StageModelOnly */ @@ -829,7 +829,7 @@ declare namespace settings { * @param context Indicates Context or dataAbilityHelper instance * @param name Indicates the name of the character string. * @param defValue Indicates the default value of the character string. - * @return settingsdata value + * @returns settingsdata value * @StageModelOnly */ function getValueSync(context: Context, name: string, defValue: string): string; @@ -841,7 +841,7 @@ declare namespace settings { * @param context Indicates Context or dataAbilityHelper instance * @param name Indicates the name of the character string. * @param value Indicates the value of the character string. - * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @returns Returns {@code true} if the operation is successful; returns {@code false} otherwise. * @StageModelOnly */ function setValue(context: Context, name: string, value: string, callback: AsyncCallback): void; @@ -854,7 +854,7 @@ declare namespace settings { * @param context Indicates Context or dataAbilityHelper instance * @param name Indicates the name of the character string. * @param value Indicates the value of the character string. - * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @returns Returns {@code true} if the operation is successful; returns {@code false} otherwise. * @StageModelOnly */ function setValueSync(context: Context, name: string, value: string): boolean; @@ -897,7 +897,7 @@ declare namespace settings { * @param dataAbilityHelper Indicates dataAbilityHelper instance * @param name Indicates the name of the character string. * @param defValue Indicates the default value of the character string. - * @return settingsdata value + * @returns settingsdata value * @deprecated since 9 * @useinstead getValueSync(context: context...) * @FAModelOnly @@ -911,7 +911,7 @@ declare namespace settings { * @param dataAbilityHelper Indicates dataAbilityHelper instance * @param name Indicates the name of the character string. * @param value Indicates the value of the character string. - * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. + * @returns Returns {@code true} if the operation is successful; returns {@code false} otherwise. * @deprecated since 9 * @useinstead setValueSync(context: context...) * @FAModelOnly -- Gitee