!9574 add switch event on/off

Merge pull request !9574 from jidong/getLocalId022801
This commit is contained in:
openharmony_ci 2024-03-18 08:00:59 +00:00 committed by Gitee
commit 881829ab28
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1705,6 +1705,74 @@ declare namespace osAccount {
*/
off(type: 'activate' | 'activating', name: string, callback?: Callback<number>): void;
/**
* Subscribes to the OS account switching event.
*
* @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
* @param { 'switching' } type - Indicates the event type.
* @param { Callback<OsAccountSwitchEventData> } callback - Indicates the callback for getting the event data.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Not system application.
* @throws { BusinessError } 401 - The parameter check failed.
* @throws { BusinessError } 12300001 - System service exception.
* @throws { BusinessError } 12300002 - Invalid type.
* @syscap SystemCapability.Account.OsAccount
* @systemapi Hide this for inner system use.
* @since 12
*/
on(type: 'switching', callback: Callback<OsAccountSwitchEventData>): void;
/**
* Unsubscribes from the OS account switching event.
*
* @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
* @param { 'switching' } type - Indicates the event type.
* @param { Callback<OsAccountSwitchEventData> } [callback] - Indicates the callback for getting the event data.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Not system application.
* @throws { BusinessError } 401 - The parameter check failed.
* @throws { BusinessError } 12300001 - System service exception.
* @throws { BusinessError } 12300002 - Invalid type.
* @syscap SystemCapability.Account.OsAccount
* @systemapi Hide this for inner system use.
* @since 12
*/
off(type: 'switching', callback?: Callback<OsAccountSwitchEventData>): void;
/**
* Subscribes to the OS account switched event.
*
* @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
* @param { 'switched' } type - Indicates the event type.
* @param { Callback<OsAccountSwitchEventData> } callback - Indicates the callback for getting the event data.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Not system application.
* @throws { BusinessError } 401 - The parameter check failed.
* @throws { BusinessError } 12300001 - System service exception.
* @throws { BusinessError } 12300002 - Invalid type.
* @syscap SystemCapability.Account.OsAccount
* @systemapi Hide this for inner system use.
* @since 12
*/
on(type: 'switched', callback: Callback<OsAccountSwitchEventData>): void;
/**
* Unsubscribes from the OS account switched event.
*
* @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS
* @param { 'switched' } type - Indicates the event type.
* @param { Callback<OsAccountSwitchEventData> } [callback] - Indicates the callback for getting the event data.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Not system application.
* @throws { BusinessError } 401 - The parameter check failed.
* @throws { BusinessError } 12300001 - System service exception.
* @throws { BusinessError } 12300002 - Invalid type.
* @syscap SystemCapability.Account.OsAccount
* @systemapi Hide this for inner system use.
* @since 12
*/
off(type: 'switched', callback?: Callback<OsAccountSwitchEventData>): void;
/**
* Gets the bundle ID associated with the specified UID.
*
@ -1983,6 +2051,36 @@ declare namespace osAccount {
domainInfo: DomainAccountInfo;
}
/**
* Defines the switching/switched event data structure for the OS account.
*
* @typedef OsAccountSwitchEventData
* @syscap SystemCapability.Account.OsAccount
* @systemapi Hide this for inner system use.
* @since 12
*/
interface OsAccountSwitchEventData {
/**
* Indicates which OS account to switch from.
*
* @type { number }
* @syscap SystemCapability.Account.OsAccount
* @systemapi Hide this for inner system use.
* @since 12
*/
fromAccountId: number;
/**
* Indicates which OS account to switch to.
*
* @type { number }
* @syscap SystemCapability.Account.OsAccount
* @systemapi Hide this for inner system use.
* @since 12
*/
toAccountId: number;
}
/**
* Options for creating an OS account.
*