From cc72bf2f6fea84717ae56d652aeca92f34751d69 Mon Sep 17 00:00:00 2001 From: huangjie Date: Fri, 16 Sep 2022 10:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=AE=A1=E7=90=86API=20?= =?UTF-8?q?=E5=8F=AF=E6=8D=95=E8=8E=B7=E9=94=99=E8=AF=AF=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjie --- api/@ohos.resourceManager.d.ts | 291 +++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) diff --git a/api/@ohos.resourceManager.d.ts b/api/@ohos.resourceManager.d.ts index 9dfa61e1cf..4765844c93 100644 --- a/api/@ohos.resourceManager.d.ts +++ b/api/@ohos.resourceManager.d.ts @@ -192,6 +192,62 @@ export interface AsyncCallback { (err: Error, data: T): void; } +/** + * Bussiness error code + * + * @since 9 + */ + export enum ResMgrErrorCode { + /** + * Invalid input parameter + * + * @since 9 + */ + INVALID_INPUT_PARAMETER = 401, + + /** + * Resource id invalid + * + * @since 9 + */ + RES_ID_NOT_FOUND = 9001001, + + /** + * Resource not found by id + * + * @since 9 + */ + RES_NOT_FOUND_BY_ID = 9001002, + + /** + * Resource name invalid + * + * @since 9 + */ + RES_NAME_NOT_FOUND = 9001003, + + /** + * Resource not found by name + * + * @since 9 + */ + RES_NOT_FOUND_BY_NAME = 9001004, + + /** + * Rawfile path is invalid + * + * @since 9 + */ + RES_PATH_INVALID = 9001005, + + /** + * Resource re-ref too much + * + * @since 9 + */ + RES_REF_TO_MUCH = 9001006, +} + /** * Obtains the ResourceManager object of the current application. * @@ -242,6 +298,8 @@ export interface ResourceManager { * @param resId Indicates the resource ID. * @param callback Indicates the asynchronous callback used to return the obtained character string. * @since 6 + * @deprecated since 9 + * @useinstead getStringValue */ getString(resId: number, callback: AsyncCallback): void; @@ -251,6 +309,8 @@ export interface ResourceManager { * @param resId Indicates the resource ID. * @return Returns the character string corresponding to the resource ID. * @since 6 + * @deprecated since 9 + * @useinstead getStringValue */ getString(resId: number): Promise; @@ -259,6 +319,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @param callback Indicates the asynchronous callback used to return the obtained character string. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getString(resource: Resource, callback: AsyncCallback): void; @@ -268,6 +329,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @return Returns the character string corresponding to the resource object. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getString(resource: Resource): Promise; @@ -278,6 +340,8 @@ export interface ResourceManager { * @param resId Indicates the resource ID. * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. * @since 6 + * @deprecated since 9 + * @useinstead getStringArrayValue */ getStringArray(resId: number, callback: AsyncCallback>): void; @@ -287,6 +351,8 @@ export interface ResourceManager { * @param resId Indicates the resource ID. * @return Returns the array of character strings corresponding to the specified resource ID. * @since 6 + * @deprecated since 9 + * @useinstead getStringArrayValue */ getStringArray(resId: number): Promise>; @@ -295,6 +361,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getStringArray(resource: Resource, callback: AsyncCallback>): void; @@ -304,6 +371,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @return Returns the array of character strings corresponding to the specified resource object. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getStringArray(resource: Resource): Promise>; @@ -314,6 +382,8 @@ export interface ResourceManager { * @param resId Indicates the resource ID. * @param callback Indicates the asynchronous callback used to return the obtained media file content. * @since 6 + * @deprecated since 9 + * @useinstead getMediaContent */ getMedia(resId: number, callback: AsyncCallback): void; @@ -323,6 +393,8 @@ export interface ResourceManager { * @param resId Indicates the resource ID. * @return Returns the content of the media file corresponding to the specified resource ID. * @since 6 + * @deprecated since 9 + * @useinstead getMediaContent */ getMedia(resId: number): Promise; @@ -331,6 +403,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @param callback Indicates the asynchronous callback used to return the obtained media file content. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getMedia(resource: Resource, callback: AsyncCallback): void; @@ -340,6 +413,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @return Returns the content of the media file corresponding to the specified resource object. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getMedia(resource: Resource): Promise; @@ -351,6 +425,8 @@ export interface ResourceManager { * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image * resource. * @since 6 + * @deprecated since 9 + * @useinstead getMediaContentBase64 */ getMediaBase64(resId: number, callback: AsyncCallback): void; @@ -360,6 +436,8 @@ export interface ResourceManager { * @param resId Indicates the resource ID. * @return Returns the Base64 code of the image resource corresponding to the specified resource ID. * @since 6 + * @deprecated since 9 + * @useinstead getMediaContentBase64 */ getMediaBase64(resId: number): Promise; @@ -369,6 +447,7 @@ export interface ResourceManager { * @param resource Indicates the resource object. * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image * resource. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getMediaBase64(resource: Resource, callback: AsyncCallback): void; @@ -378,6 +457,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @return Returns the Base64 code of the image resource corresponding to the specified resource object. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getMediaBase64(resource: Resource): Promise; @@ -387,6 +467,8 @@ export interface ResourceManager { * * @param callback Indicates the asynchronous callback used to return the obtained device capability. * @since 6 + * @deprecated since 9 + * @useinstead getDevCapability */ getDeviceCapability(callback: AsyncCallback): void; @@ -395,6 +477,8 @@ export interface ResourceManager { * * @return Returns the device capability. * @since 6 + * @deprecated since 9 + * @useinstead getDevCapability */ getDeviceCapability(): Promise; @@ -404,6 +488,8 @@ export interface ResourceManager { * @param callback Indicates the asynchronous callback used to return the obtained device * configuration. * @since 6 + * @deprecated since 9 + * @useinstead getConfig */ getConfiguration(callback: AsyncCallback): void; @@ -412,6 +498,8 @@ export interface ResourceManager { * * @return Returns the device configuration. * @since 6 + * @deprecated since 9 + * @useinstead getConfig */ getConfiguration(): Promise; @@ -424,6 +512,8 @@ export interface ResourceManager { * @param callback Indicates the asynchronous callback used to return the singular-plural character * string represented by the ID string corresponding to the specified number. * @since 6 + * @deprecated since 9 + * @useinstead getPluralStringValue */ getPluralString(resId: number, num: number, callback: AsyncCallback): void; @@ -436,6 +526,8 @@ export interface ResourceManager { * @return Returns the singular-plural character string represented by the ID string * corresponding to the specified number. * @since 6 + * @deprecated since 9 + * @useinstead getPluralStringValue */ getPluralString(resId: number, num: number): Promise; @@ -447,6 +539,7 @@ export interface ResourceManager { * @param num Indicates the number. * @param callback Indicates the asynchronous callback used to return the singular-plural character * string represented by the resource object string corresponding to the specified number. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getPluralString(resource: Resource, num: number, callback: AsyncCallback): void; @@ -459,6 +552,7 @@ export interface ResourceManager { * @param num Indicates the number. * @return Returns the singular-plural character string represented by the resource object string * corresponding to the specified number. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getPluralString(resource: Resource, num: number): Promise; @@ -469,6 +563,8 @@ export interface ResourceManager { * @param path Indicates the resource relative path. * @param callback Indicates the asynchronous callback used to return the raw file resource. * @since 8 + * @deprecated since 9 + * @useinstead getRawFileContent */ getRawFile(path: string, callback: AsyncCallback): void; @@ -478,6 +574,8 @@ export interface ResourceManager { * @param path Indicates the resource relative path. * @return Returns the raw file resource corresponding to the specified resource path. * @since 8 + * @deprecated since 9 + * @useinstead getRawFileContent */ getRawFile(path: string): Promise; @@ -487,6 +585,8 @@ export interface ResourceManager { * @param path Indicates the resource relative path. * @param callback Indicates the asynchronous callback used to return the raw file resource descriptor. * @since 8 + * @deprecated since 9 + * @useinstead getRawFd */ getRawFileDescriptor(path: string, callback: AsyncCallback): void; @@ -496,6 +596,8 @@ export interface ResourceManager { * @param path Indicates the resource relative path. * @return Returns the raw file resource descriptor corresponding to the specified resource path. * @since 8 + * @deprecated since 9 + * @useinstead getRawFd */ getRawFileDescriptor(path: string): Promise; @@ -505,6 +607,8 @@ export interface ResourceManager { * @param path Indicates the resource relative path. * @param callback Indicates the asynchronous callback used to return result close raw file resource descriptor. * @since 8 + * @deprecated since 9 + * @useinstead closeRawFd */ closeRawFileDescriptor(path: string, callback: AsyncCallback): void; @@ -514,6 +618,8 @@ export interface ResourceManager { * @param path Indicates the resource relative path. * @return Returns result close raw file resource descriptor corresponding to the specified resource path. * @since 8 + * @deprecated since 9 + * @useinstead closeRawFd */ closeRawFileDescriptor(path: string): Promise; @@ -522,6 +628,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @param callback Indicates the asynchronous callback used to return the obtained character string. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getStringByName(resName: string, callback: AsyncCallback): void; @@ -531,6 +638,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @return Returns the character string corresponding to the resource name. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getStringByName(resName: string): Promise; @@ -540,6 +648,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getStringArrayByName(resName: string, callback: AsyncCallback>): void; @@ -549,6 +658,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @return Returns the array of character strings corresponding to the specified resource name. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getStringArrayByName(resName: string): Promise>; @@ -558,6 +668,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @param callback Indicates the asynchronous callback used to return the obtained media file content. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getMediaByName(resName: string, callback: AsyncCallback): void; @@ -567,6 +678,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @return Returns the content of the media file corresponding to the specified resource name. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getMediaByName(resName: string): Promise; @@ -577,6 +689,7 @@ export interface ResourceManager { * @param resName Indicates the resource name. * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image * resource. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getMediaBase64ByName(resName: string, callback: AsyncCallback): void; @@ -586,6 +699,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @return Returns the Base64 code of the image resource corresponding to the specified resource name. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getMediaBase64ByName(resName: string): Promise; @@ -598,6 +712,7 @@ export interface ResourceManager { * @param num Indicates the number. * @param callback Indicates the asynchronous callback used to return the singular-plural character * string represented by the name string corresponding to the specified number. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getPluralStringByName(resName: string, num: number, callback: AsyncCallback): void; @@ -610,6 +725,7 @@ export interface ResourceManager { * @param num Indicates the number. * @return Returns the singular-plural character string represented by the name string * corresponding to the specified number. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getPluralStringByName(resName: string, num: number): Promise; @@ -619,6 +735,7 @@ export interface ResourceManager { * * @param resId Indicates the resource ID. * @return Returns the character string corresponding to the resource ID. + * @throws { BusinessError } If the resource not found by resId. * @since 9 */ getStringSync(resId: number): string; @@ -628,6 +745,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @return Returns the character string corresponding to the resource object. + * @throws { BusinessError } If the resource not found by resId. * @since 9 */ getStringSync(resource: Resource): string; @@ -637,6 +755,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @return Returns the character string corresponding to the resource name. + * @throws { BusinessError } If the resource not found by resId. * @since 9 */ getStringByNameSync(resName: string): string; @@ -646,6 +765,7 @@ export interface ResourceManager { * * @param resId Indicates the resource ID. * @return Returns the boolean resource corresponding to the resource ID. + * @throws { BusinessError } If the resource not found by resId. * @since 9 */ getBoolean(resId: number): boolean; @@ -655,6 +775,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @return Returns the boolean resource corresponding to the resource object. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getBoolean(resource: Resource): boolean; @@ -664,6 +785,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @return Returns the boolean resource corresponding to the resource name. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getBooleanByName(resName: string): boolean; @@ -673,6 +795,7 @@ export interface ResourceManager { * * @param resId Indicates the resource ID. * @return Returns the number resource corresponding to the resource ID. + * @throws { BusinessError } If the resource not found by resId. * @since 9 */ getNumber(resId: number): number; @@ -682,6 +805,7 @@ export interface ResourceManager { * * @param resource Indicates the resource object. * @return Returns the number resource corresponding to the resource object. + * @throws { BusinessError } If the resource not found by module resId. * @since 9 */ getNumber(resource: Resource): number; @@ -691,6 +815,7 @@ export interface ResourceManager { * * @param resName Indicates the resource name. * @return Returns the number resource corresponding to the resource name. + * @throws { BusinessError } If the resource not found by resName. * @since 9 */ getNumberByName(resName: string): number; @@ -701,6 +826,172 @@ export interface ResourceManager { * @since 7 */ release(); + + /** + * Obtains the character string corresponding to a specified resource ID in callback mode. + * + * @param resId Indicates the resource ID. + * @param callback Indicates the asynchronous callback used to return the obtained character string. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getStringValue(resId: number, callback: AsyncCallback): void; + + /** + * Obtains string resources associated with a specified resource ID in Promise mode. + * + * @param resId Indicates the resource ID. + * @return Returns the character string corresponding to the resource ID. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getStringValue(resId: number): Promise; + + /** + * Obtains the array of character strings corresponding to a specified resource ID in callback mode. + * + * @param resId Indicates the resource ID. + * @param callback Indicates the asynchronous callback used to return the obtained array of character strings. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getStringArrayValue(resId: number, callback: AsyncCallback>): void; + + /** + * Obtains the array of character strings corresponding to a specified resource ID in Promise mode. + * + * @param resId Indicates the resource ID. + * @return Returns the array of character strings corresponding to the specified resource ID. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getStringArrayValue(resId: number): Promise>; + + /** + * Obtains the singular-plural character string represented by the ID string corresponding to the + * specified number in callback mode. + * + * @param resId Indicates the resource ID. + * @param num Indicates the number. + * @param callback Indicates the asynchronous callback used to return the singular-plural character + * string represented by the ID string corresponding to the specified number. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getPluralStringValue(resId: number, num: number, callback: AsyncCallback): void; + + /** + * Obtains the singular-plural character string represented by the ID string corresponding to + * the specified number in Promise mode. + * + * @param resId Indicates the resource ID. + * @param num Indicates the number. + * @return Returns the singular-plural character string represented by the ID string + * corresponding to the specified number. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getPluralStringValue(resId: number, num: number): Promise; + + /** + * Obtains the content of the media file corresponding to a specified resource ID in callback mode. + * + * @param resId Indicates the resource ID. + * @param callback Indicates the asynchronous callback used to return the obtained media file content. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getMediaContent(resId: number, callback: AsyncCallback): void; + + /** + * Obtains the content of the media file corresponding to a specified resource ID in Promise mode. + * + * @param resId Indicates the resource ID. + * @return Returns the content of the media file corresponding to the specified resource ID. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getMediaContent(resId: number): Promise; + + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource ID in callback mode. + * + * @param resId Indicates the resource ID. + * @param callback Indicates the asynchronous callback used to return the obtained Base64 code of the image + * resource. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getMediaContentBase64(resId: number, callback: AsyncCallback): void; + + /** + * Obtains the Base64 code of the image resource corresponding to the specified resource ID in Promise mode. + * + * @param resId Indicates the resource ID. + * @return Returns the Base64 code of the image resource corresponding to the specified resource ID. + * @throws { BusinessError } If the resource not found by resId. + * @since 9 + */ + getMediaContentBase64(resId: number): Promise; + + /** + * Obtains the raw file resource corresponding to the specified resource path in callback mode. + * + * @param path Indicates the resource relative path. + * @param callback Indicates the asynchronous callback used to return the raw file resource. + * @throws { BusinessError } If the resource not found by rawFile path. + * @since 9 + */ + getRawFileContent(path: string, callback: AsyncCallback): void; + + /** + * Obtains the raw file resource corresponding to the specified resource path in Promise mode. + * + * @param path Indicates the resource relative path. + * @return Returns the raw file resource corresponding to the specified resource path. + * @throws { BusinessError } If the resource not found by rawFile path. + * @since 9 + */ + getRawFileContent(path: string): Promise; + + /** + * Obtains the raw file resource descriptor corresponding to the specified resource path in callback mode. + * + * @param path Indicates the resource relative path. + * @param callback Indicates the asynchronous callback used to return the raw file resource descriptor. + * @throws { BusinessError } If the resource not found by rawFile path. + * @since 9 + */ + getRawFd(path: string, callback: AsyncCallback): void; + + /** + * Obtains the raw file resource descriptor corresponding to the specified resource path in Promise mode. + * + * @param path Indicates the resource relative path. + * @return Returns the raw file resource descriptor corresponding to the specified resource path. + * @throws { BusinessError } If the resource not found by rawFile path. + * @since 9 + */ + getRawFd(path: string): Promise; + + /** + * Obtains close raw file resource descriptor corresponding to the specified resource path in callback mode. + * + * @param path Indicates the resource relative path. + * @param callback Indicates the asynchronous callback used to return result close raw file resource descriptor. + * @throws { BusinessError } If the closed resource by rawFile path. + * @since 9 + */ + closeRawFd(path: string, callback: AsyncCallback): void; + + /** + * Obtains close raw file resource descriptor corresponding to the specified resource path in Promise mode. + * + * @param path Indicates the resource relative path. + * @throws { BusinessError } If the closed resource by rawFile path. + * @since 9 + */ + closeRawFd(path: string): Promise; } /** -- Gitee