From d961b976e931afe5a9d6f0d6e37caee0a585b21f Mon Sep 17 00:00:00 2001 From: liminjie10 Date: Fri, 9 Dec 2022 11:22:24 +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 | 141 ++++++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 41 deletions(-) diff --git a/api/@ohos.settings.d.ts b/api/@ohos.settings.d.ts index 6732211ade..17f8783dbe 100644 --- a/api/@ohos.settings.d.ts +++ b/api/@ohos.settings.d.ts @@ -20,7 +20,6 @@ import { DataAbilityHelper } from './ability/dataAbilityHelper'; * * @since 7 * @syscap SystemCapability.Applications.settings.Core - * @import import settings from '@ohos.settings' * @permission N/A */ declare namespace settings { @@ -770,45 +769,7 @@ declare namespace settings { */ const WIFI_WATCHDOG_STATUS: string } - - /** - * 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. - * @return 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; - - /** - * Obtains the value of a specified character string in 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. - * @return Returns the value of the character string in the table if any is found; returns {@code null} - * otherwise. - * @since 7 - */ - 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. - * @param value Indicates the value of the character string. - * @return Returns {@code true} if the operation is successful; returns {@code false} otherwise. - * @since 7 - * @systemapi Hide this for inner system use. - */ - 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. * @@ -831,6 +792,16 @@ declare namespace settings { 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; + /** * get settingsdata uri(synchronization method) * @since 8 @@ -839,6 +810,87 @@ declare namespace settings { */ 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 + * the database. + * @param name Indicates the name of the character string. + * @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; + + /** + * 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. + * @param value Indicates the value of the character string. + * @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: string, callback: AsyncCallback): void; + function setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: string): Promise; + /** * get value from settingsdata(synchronization method) * @since 8 @@ -846,19 +898,26 @@ declare namespace settings { * @param name Indicates the name of the character string. * @param defValue Indicates the default value of the character string. * @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. * @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 daed704984c3007629c0574b70103d7a6985efb6 Mon Sep 17 00:00:00 2001 From: liminjie10 Date: Fri, 9 Dec 2022 07:01:15 +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