diff --git a/api/@ohos.settings.d.ts b/api/@ohos.settings.d.ts index 34beb2931d53a5362a0ec4cbe81291ccdf229897..a6b89532df1cacddea4a72938a1e94b005fa2627 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. + * @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; /** * 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. + * @returns Returns 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. + * @returns 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. + * @returns 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. + * @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; + 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. + * @returns 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) @@ -845,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. * @returns 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. + * @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