diff --git a/api/@ohos.account.appAccount.d.ts b/api/@ohos.account.appAccount.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6eeda3dcf8905dfa6451250015751b94b4229033 --- /dev/null +++ b/api/@ohos.account.appAccount.d.ts @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {AsyncCallback} from "./basic"; + +declare namespace appAccount { + /** + * Obtains the AppAccountManager instance. + * @since 7 + * @sysCap SystemCapability.Account.AppAccount + * @devices phone, tablet, tv, wearable, car + * @return Returns the instance of the AppAccountManager. + */ + function createAppAccountManager(): AppAccountManager; + + /** + * Provides methods for managing application accounts. + * @name AppAccountManager + * @since 7 + * @sysCap SystemCapability.Account.AppAccount + * @devices phone, tablet, tv, wearable, car + */ + interface AppAccountManager { + /** + * Adds the account name and extra information of this application to the account management service. + *
+ * Only the owner of the application account has the permission to call this method.
+ *
+ * @since 7
+ * @devices phone, tablet, tv, wearable, car
+ * @param name Indicates the name of the application account to add.
+ * @param extraInfo Indicates the extra information of the application account to add.
+ * The extra information cannot be sensitive information of the application account.
+ * @return void.
+ */
+ addAccount(name: string, callback: AsyncCallback
+ * Only the owner of the application account has the permission to call this method.
+ *
+ * @since 7
+ * @devices phone, tablet, tv, wearable, car
+ * @param name Indicates the name of the application account to delete.
+ * @return void.
+ */
+ deleteAccount(name: string, callback: AsyncCallback
+ * If the same OHOS account has logged in to multiple devices, these devices constitute a super device
+ * through the distributed networking. On the networked devices, you can call this method to check
+ * whether application data can be synchronized.
+ *
+ *
+ * @since 7
+ * @devices phone, tablet, tv, wearable, car
+ * @param name Indicates the name of the application account.
+ * @return Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise.
+ * @permission ohos.permission.DISTRIBUTED_DATASYNC.
+ */
+ checkAppAccountSyncEnable(name: string, callback: AsyncCallback
+ * You can call this method when you forget the extra information of your application account or
+ * need to modify the extra information.
+ *
+ * @since 7
+ * @devices phone, tablet, tv, wearable, car
+ * @param name Indicates the name of the application account.
+ * @param extraInfo Indicates the extra information to set.
+ * @return void.
+ */
+ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback
+ * If the same OHOS account has logged in to multiple devices, these devices constitute a super device
+ * through the distributed networking. On the networked devices, you can call this method to set whether to
+ * allow cross-device data synchronization. If synchronization is allowed, application data can be synchronized
+ * among these devices in the event of any changes related to the application account.
+ * If synchronization is not allowed, the application data is stored only on the local device.
+ *
+ * Application account-related changes: adding or deleting an application account, setting extra
+ * information (such as updating a token), and setting data associated with this application account
+ *
+ * Application data that can be synchronized: application account name, token,
+ * and data associated with this application account
+ *
+ *
+ * @since 7
+ * @devices phone, tablet, tv, wearable, car
+ * @param name Indicates the name of the application account.
+ * @param isEnable Specifies whether to allow application data synchronization.
+ * @return void.
+ * @permission ohos.permission.DISTRIBUTED_DATASYNC.
+ */
+ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
+ * This method applies to the following accounts:
+ *
+ * This method applies to the following accounts:
+ *
+ * When the account owner updates the account, the subscriber will receive a notification
+ * about the account change event.
+ *
+ * @since 7
+ * @devices phone, tablet, tv, wearable, car
+ * @param owners Indicates the account owners, which are specified
+ * by {@link AppAccount#AppAccount(String name, String owner)}.
+ * @return void
+ */
+ on(type: 'change', owners: Array
+ *
+ *
+ * @since 7
+ * @devices phone, tablet, tv, wearable, car
+ * @return Returns a list of application accounts.
+ * @permission ohos.permission.GET_ACCOUNTS_PRIVILEGED.
+ */
+ getAllAccessibleAccounts(callback: AsyncCallback
+ *
+ *
+ * @since 7
+ * @devices phone, tablet, tv, wearable, car
+ * @param owner Indicates the account owner of your application or third-party applications.
+ * @return Returns a list of application accounts.
+ * @permission ohos.permission.GET_ACCOUNTS_PRIVILEGED.
+ */
+ getAllAccounts(owner: string, callback: AsyncCallback