diff --git a/api/@ohos.account.osAccount.d.ts b/api/@ohos.account.osAccount.d.ts index 1ee596bb3491cc4a72f25b7f0edc0514bf02aeda..bb771d61f819605a4653ab17ceada807545e5133 100644 --- a/api/@ohos.account.osAccount.d.ts +++ b/api/@ohos.account.osAccount.d.ts @@ -97,6 +97,35 @@ declare namespace osAccount { */ activateOsAccount(localId: number, callback: AsyncCallback): void; + /** + * Activates a specified OS account on the target display. + *

+ * If multiple OS accounts and displays are available, you can call this method to enable a + * specific OS account to run in the foreground on a target display. + * Currently, cross-display activation is not supported, which means that a foreground OS account + * cannot be activated from its original display to another display. + *

+ * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + * @param { number } localId - Indicates the local ID of the OS account. + * @param { number } displayId - Indicates the ID of the target display. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300003 - Account not found. + * @throws { BusinessError } 12300008 - Restricted Account. + * @throws { BusinessError } 12300010 - Service busy. Possible causes: The target account is being operated. + * @throws { BusinessError } 12300016 - The number of logged in accounts reaches the upper limit. + * @throws { BusinessError } 12300018 - Display not found. + * @throws { BusinessError } 12300019 - Cross-display activation not supported. + * @syscap SystemCapability.Account.OsAccount + * @systemapi + * @since 20 + */ + activateOsAccount(localId: number, displayId: number): Promise; + /** * Activates a specified OS account. *

@@ -1171,6 +1200,38 @@ declare namespace osAccount { */ getForegroundOsAccountLocalId(): Promise; + /** + * Gets the local ID of the foreground OS account by displayId. + * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { number } displayId - Indicates the display ID of the target foreground OS account. + * @returns { Promise } Returns local ID of the target foreground OS account. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300017 - The foreground OS account is not found. + * @syscap SystemCapability.Account.OsAccount + * @systemapi + * @since 20 + */ + getForegroundOsAccountLocalId(displayId: number): Promise; + + /** + * Gets the disyplay ID of the foreground OS account by localId. + * + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { number } localId - Indicates the local ID of the target foreground OS account. + * @returns { Promise } Returns display ID of the target foreground OS account. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300017 - The foreground OS account is not found. + * @syscap SystemCapability.Account.OsAccount + * @systemapi + * @since 20 + */ + getForegroundOsAccountDisplayId(localId: number): Promise; + /** * Creates an OS account using the local name and account type. * @@ -1894,6 +1955,20 @@ declare namespace osAccount { * @systemapi Hide this for inner system use. * @since 12 */ + /** + * Subscribes to the OS account switching event. + * + * @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. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid type. + * @syscap SystemCapability.Account.OsAccount + * @systemapi + * @since 20 + */ on(type: 'switching', callback: Callback): void; /** @@ -1912,6 +1987,20 @@ declare namespace osAccount { * @systemapi Hide this for inner system use. * @since 12 */ + /** + * Unsubscribes from the OS account switching event. + * + * @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. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid type. + * @syscap SystemCapability.Account.OsAccount + * @systemapi + * @since 20 + */ off(type: 'switching', callback?: Callback): void; /** @@ -1930,6 +2019,20 @@ declare namespace osAccount { * @systemapi Hide this for inner system use. * @since 12 */ + /** + * Subscribes to the OS account switched event. + * + * @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. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid type. + * @syscap SystemCapability.Account.OsAccount + * @systemapi + * @since 20 + */ on(type: 'switched', callback: Callback): void; /** @@ -1948,6 +2051,20 @@ declare namespace osAccount { * @systemapi Hide this for inner system use. * @since 12 */ + /** + * Unsubscribes from the OS account switched event. + * + * @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. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 12300001 - The system service works abnormally. + * @throws { BusinessError } 12300002 - Invalid type. + * @syscap SystemCapability.Account.OsAccount + * @systemapi + * @since 20 + */ off(type: 'switched', callback?: Callback): void; /** @@ -2271,6 +2388,16 @@ declare namespace osAccount { * @since 12 */ toAccountId: number; + + /** + * Indicates which display the switch event occurred on. + * + * @type { ?number } + * @syscap SystemCapability.Account.OsAccount + * @systemapi Hide this for inner system use. + * @since 20 + */ + displayId?: number; } /**