From 6903e7b86fb473d4820c372448d7716aa446b625 Mon Sep 17 00:00:00 2001 From: yeyuning Date: Tue, 11 Mar 2025 17:18:22 +0800 Subject: [PATCH] features Signed-off-by: yeyuning Change-Id: Iad1bdc8d955a8d4784f5b51d22c93932a6c7bf1a --- api/@ohos.account.osAccount.d.ts | 183 ++++++++++++++++++++++++++++++- 1 file changed, 179 insertions(+), 4 deletions(-) diff --git a/api/@ohos.account.osAccount.d.ts b/api/@ohos.account.osAccount.d.ts index 0b9cbc7769..4ac87d3700 100644 --- a/api/@ohos.account.osAccount.d.ts +++ b/api/@ohos.account.osAccount.d.ts @@ -146,6 +146,36 @@ declare namespace osAccount { */ activateOsAccount(localId: number): Promise; + /** + * Activates a specified OS account on the target display. + *

+ * If multiple OS accounts are available, you can call this method to enable a specific OS account to run in the foreground. + * Cross-display activation refers to switching a foreground OS account from one display to another. + * In standard non-cross-display activation, the OS account previously running in the foreground will be switched to the background. + * However, is not supported in cross-display activation. + *

+ * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + * @param { number } localId - Indicates the local ID of the OS account. + * @param { number } displayId - Indicates the display ID of the OS account. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid localId. + * @throws { BusinessError } 12300003 - Account not found. + * @throws { BusinessError } 12300008 - Restricted Account. + * @throws { BusinessError } 12300016 - The number of logged in accounts reaches the upper limit. + * @throws { BusinessError } 12300018 - The display not found. + * @throws { BusinessError } 12300019 - Cross-display activation is not supported. + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + activateOsAccount(localId: number, displayId: number): Promise; + /** * Deactivates a specified OS account. * @@ -1168,6 +1198,40 @@ declare namespace osAccount { */ getForegroundOsAccountLocalId(): Promise; + /** + * Gets the local ID of the foreground OS account by displayId. + * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @returns { Promise } Returns local ID of the target foreground OS account. + * @param { number } displayId - Indicates the display ID of the target foreground OS account. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300017 - The foreground os account not found. + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + getForegroundOsAccountLocalId(displayId: number): Promise; + + /** + * Gets the disyplay ID of the foreground OS account by localId. + * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @returns { Promise } Returns disyplay ID of the target foreground OS account. + * @param { number } localId - Indicates the local ID of the target foreground OS account. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300017 - The foreground os account not found. + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + getForegroundOsAccountDisplayId(localId: number): Promise; + /** * Creates an OS account using the local name and account type. * @@ -1878,7 +1942,7 @@ declare namespace osAccount { /** * Subscribes to the OS account switching event. * - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { 'switching' } type - Indicates the event type. * @param { Callback } callback - Indicates the callback for getting the event data. * @throws { BusinessError } 201 - Permission denied. @@ -1896,7 +1960,7 @@ declare namespace osAccount { /** * Unsubscribes from the OS account switching event. * - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { 'switching' } type - Indicates the event type. * @param { Callback } [callback] - Indicates the callback for getting the event data. * @throws { BusinessError } 201 - Permission denied. @@ -1914,7 +1978,7 @@ declare namespace osAccount { /** * Subscribes to the OS account switched event. * - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { 'switched' } type - Indicates the event type. * @param { Callback } callback - Indicates the callback for getting the event data. * @throws { BusinessError } 201 - Permission denied. @@ -1932,7 +1996,7 @@ declare namespace osAccount { /** * Unsubscribes from the OS account switched event. * - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { 'switched' } type - Indicates the event type. * @param { Callback } [callback] - Indicates the callback for getting the event data. * @throws { BusinessError } 201 - Permission denied. @@ -1947,6 +2011,78 @@ declare namespace osAccount { */ off(type: 'switched', callback?: Callback): void; + /** + * Subscribes to the OS account created event. + * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { 'created' } type - Indicates the event type. + * @param { Callback } callback - Indicates the callback for getting the event data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid type. + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + on(type: 'created', callback: Callback): void; + + /** + * Unsubscribes from the OS account created event. + * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { 'created' } type - Indicates the event type. + * @param { Callback } [callback] - Indicates the callback for getting the event data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid type. + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + off(type: 'created', callback?: Callback): void; + + /** + * Subscribes to the OS account removed event. + * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { 'removed' } type - Indicates the event type. + * @param { Callback } callback - Indicates the callback for getting the event data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid type. + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + on(type: 'removed', callback: Callback): void; + + /** + * Unsubscribes from the OS account removed event. + * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { 'removed' } type - Indicates the event type. + * @param { Callback } [callback] - Indicates the callback for getting the event data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + *
2. Incorrect parameter types. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid type. + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + off(type: 'removed', callback?: Callback): void; + /** * Gets the bundle ID associated with the specified UID. * @@ -2240,6 +2376,35 @@ declare namespace osAccount { domainInfo: DomainAccountInfo; } + /** + * Defines the event data structure for the OS account. + * + * @typedef OsAccountEventData + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + interface OsAccountEventData { + /** + * Indicates the account ID of the OS account. + * + * @type { number } + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + accountId: number; + /** + * Indicates the event type. + * + * @type { string } + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + event: string; + } + /** * Defines the switching/switched event data structure for the OS account. * @@ -2268,6 +2433,16 @@ declare namespace osAccount { * @since 12 */ toAccountId: number; + + /** + * Indicates the target display ID for account switching. + * + * @type { number } + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + displayId?: number; } /** -- Gitee