1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_IAPP_ACCOUNT_H 17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_IAPP_ACCOUNT_H 18 19 #include "app_account_common.h" 20 #include "app_account_info.h" 21 #include "app_account_subscribe_info.h" 22 #include "iremote_broker.h" 23 #include "iremote_object.h" 24 #include "want.h" 25 26 namespace OHOS { 27 namespace AccountSA { 28 class IAppAccount : public IRemoteBroker { 29 public: 30 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accountfwk.IAppAccount"); 31 32 virtual ErrCode AddAccount(const std::string &name, const std::string &extraInfo) = 0; 33 virtual ErrCode AddAccountImplicitly(const std::string &owner, const std::string &authType, 34 const AAFwk::Want &options, const sptr<IRemoteObject> &callback) = 0; 35 virtual ErrCode DeleteAccount(const std::string &name) = 0; 36 37 virtual ErrCode GetAccountExtraInfo(const std::string &name, std::string &extraInfo) = 0; 38 virtual ErrCode SetAccountExtraInfo(const std::string &name, const std::string &extraInfo) = 0; 39 40 virtual ErrCode EnableAppAccess(const std::string &name, const std::string &authorizedApp) = 0; 41 virtual ErrCode DisableAppAccess(const std::string &name, const std::string &authorizedApp) = 0; 42 43 virtual ErrCode CheckAppAccountSyncEnable(const std::string &name, bool &syncEnable) = 0; 44 virtual ErrCode SetAppAccountSyncEnable(const std::string &name, const bool &syncEnable) = 0; 45 46 virtual ErrCode GetAssociatedData(const std::string &name, const std::string &key, std::string &value) = 0; 47 virtual ErrCode SetAssociatedData(const std::string &name, const std::string &key, const std::string &value) = 0; 48 49 virtual ErrCode GetAccountCredential( 50 const std::string &name, const std::string &credentialType, std::string &credential) = 0; 51 virtual ErrCode SetAccountCredential( 52 const std::string &name, const std::string &credentialType, const std::string &credential) = 0; 53 54 virtual ErrCode Authenticate(const std::string &name, const std::string &owner, const std::string &authType, 55 const AAFwk::Want &options, const sptr<IRemoteObject> &callback) = 0; 56 virtual ErrCode GetOAuthToken( 57 const std::string &name, const std::string &owner, const std::string &authType, std::string &token) = 0; 58 virtual ErrCode SetOAuthToken( 59 const std::string &name, const std::string &authType, const std::string &token) = 0; 60 virtual ErrCode DeleteOAuthToken( 61 const std::string &name, const std::string &owner, const std::string &authType, const std::string &token) = 0; 62 virtual ErrCode SetOAuthTokenVisibility(const std::string &name, const std::string &authType, 63 const std::string &bundleName, bool isVisible) = 0; 64 virtual ErrCode CheckOAuthTokenVisibility(const std::string &name, const std::string &authType, 65 const std::string &bundleName, bool &isVisible) = 0; 66 virtual ErrCode GetAuthenticatorInfo(const std::string &owner, AuthenticatorInfo &info) = 0; 67 virtual ErrCode GetAllOAuthTokens(const std::string &name, const std::string &owner, 68 std::vector<OAuthTokenInfo> &tokenInfos) = 0; 69 virtual ErrCode GetOAuthList(const std::string &name, const std::string &authType, 70 std::set<std::string> &oauthList) = 0; 71 virtual ErrCode GetAuthenticatorCallback(const std::string &sessionId, sptr<IRemoteObject> &callback) = 0; 72 73 virtual ErrCode GetAllAccounts(const std::string &owner, std::vector<AppAccountInfo> &appAccounts) = 0; 74 virtual ErrCode GetAllAccessibleAccounts(std::vector<AppAccountInfo> &appAccounts) = 0; 75 76 virtual ErrCode SubscribeAppAccount( 77 const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) = 0; 78 virtual ErrCode UnsubscribeAppAccount(const sptr<IRemoteObject> &eventListener) = 0; 79 80 enum class Message { 81 ADD_ACCOUNT = 0, 82 ADD_ACCOUNT_IMPLICITLY, 83 DELETE_ACCOUNT, 84 GET_ACCOUNT_EXTRA_INFO, 85 SET_ACCOUNT_EXTRA_INFO, 86 ENABLE_APP_ACCESS, 87 DISABLE_APP_ACCESS, 88 CHECK_APP_ACCOUNT_SYNC_ENABLE, 89 SET_APP_ACCOUNT_SYNC_ENABLE, 90 GET_ASSOCIATED_DATA, 91 SET_ASSOCIATED_DATA, 92 GET_ACCOUNT_CREDENTIAL, 93 SET_ACCOUNT_CREDENTIAL, 94 AUTHENTICATE, 95 GET_OAUTH_TOKEN, 96 SET_OAUTH_TOKEN, 97 DELETE_OAUTH_TOKEN, 98 SET_OAUTH_TOKEN_VISIBILITY, 99 CHECK_OAUTH_TOKEN_VISIBILITY, 100 GET_AUTHENTICATOR_INFO, 101 GET_ALL_OAUTH_TOKENS, 102 GET_OAUTH_LIST, 103 GET_AUTHENTICATOR_CALLBACK, 104 CLEAR_OAUTH_TOKEN, 105 GET_ALL_ACCOUNTS, 106 GET_ALL_ACCESSIBLE_ACCOUNTS, 107 SUBSCRIBE_ACCOUNT, 108 UNSUBSCRIBE_ACCOUNT, 109 }; 110 }; 111 } // namespace AccountSA 112 } // namespace OHOS 113 114 #endif // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_APPACCOUNT_IAPP_ACCOUNT_H 115