1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.accounts;
18 
19 import android.accounts.IAccountManagerResponse;
20 import android.accounts.Account;
21 import android.accounts.AuthenticatorDescription;
22 import android.content.IntentSender;
23 import android.os.Bundle;
24 import android.os.RemoteCallback;
25 import android.os.UserHandle;
26 
27 import java.util.Map;
28 
29 /**
30  * Central application service that provides account management.
31  * @hide
32  */
33 interface IAccountManager {
getPassword(in Account account)34     String getPassword(in Account account);
getUserData(in Account account, String key)35     String getUserData(in Account account, String key);
getAuthenticatorTypes(int userId)36     AuthenticatorDescription[] getAuthenticatorTypes(int userId);
getAccounts(String accountType, String opPackageName)37     Account[] getAccounts(String accountType, String opPackageName);
getAccountsForPackage(String packageName, int uid, String opPackageName)38     Account[] getAccountsForPackage(String packageName, int uid, String opPackageName);
getAccountsByTypeForPackage(String type, String packageName, String opPackageName)39     Account[] getAccountsByTypeForPackage(String type, String packageName, String opPackageName);
getAccountsAsUser(String accountType, int userId, String opPackageName)40     Account[] getAccountsAsUser(String accountType, int userId, String opPackageName);
hasFeatures(in IAccountManagerResponse response, in Account account, in String[] features, String opPackageName)41     void hasFeatures(in IAccountManagerResponse response, in Account account, in String[] features,
42         String opPackageName);
getAccountByTypeAndFeatures(in IAccountManagerResponse response, String accountType, in String[] features, String opPackageName)43     void getAccountByTypeAndFeatures(in IAccountManagerResponse response, String accountType,
44         in String[] features, String opPackageName);
getAccountsByFeatures(in IAccountManagerResponse response, String accountType, in String[] features, String opPackageName)45     void getAccountsByFeatures(in IAccountManagerResponse response, String accountType,
46         in String[] features, String opPackageName);
addAccountExplicitly(in Account account, String password, in Bundle extras)47     boolean addAccountExplicitly(in Account account, String password, in Bundle extras);
removeAccount(in IAccountManagerResponse response, in Account account, boolean expectActivityLaunch)48     void removeAccount(in IAccountManagerResponse response, in Account account,
49         boolean expectActivityLaunch);
removeAccountAsUser(in IAccountManagerResponse response, in Account account, boolean expectActivityLaunch, int userId)50     void removeAccountAsUser(in IAccountManagerResponse response, in Account account,
51         boolean expectActivityLaunch, int userId);
removeAccountExplicitly(in Account account)52     boolean removeAccountExplicitly(in Account account);
copyAccountToUser(in IAccountManagerResponse response, in Account account, int userFrom, int userTo)53     void copyAccountToUser(in IAccountManagerResponse response, in Account account,
54         int userFrom, int userTo);
invalidateAuthToken(String accountType, String authToken)55     void invalidateAuthToken(String accountType, String authToken);
peekAuthToken(in Account account, String authTokenType)56     String peekAuthToken(in Account account, String authTokenType);
setAuthToken(in Account account, String authTokenType, String authToken)57     void setAuthToken(in Account account, String authTokenType, String authToken);
setPassword(in Account account, String password)58     void setPassword(in Account account, String password);
clearPassword(in Account account)59     void clearPassword(in Account account);
setUserData(in Account account, String key, String value)60     void setUserData(in Account account, String key, String value);
updateAppPermission(in Account account, String authTokenType, int uid, boolean value)61     void updateAppPermission(in Account account, String authTokenType, int uid, boolean value);
62 
getAuthToken(in IAccountManagerResponse response, in Account account, String authTokenType, boolean notifyOnAuthFailure, boolean expectActivityLaunch, in Bundle options)63     void getAuthToken(in IAccountManagerResponse response, in Account account,
64         String authTokenType, boolean notifyOnAuthFailure, boolean expectActivityLaunch,
65         in Bundle options);
addAccount(in IAccountManagerResponse response, String accountType, String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch, in Bundle options)66     void addAccount(in IAccountManagerResponse response, String accountType,
67         String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
68         in Bundle options);
addAccountAsUser(in IAccountManagerResponse response, String accountType, String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch, in Bundle options, int userId)69     void addAccountAsUser(in IAccountManagerResponse response, String accountType,
70         String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
71         in Bundle options, int userId);
updateCredentials(in IAccountManagerResponse response, in Account account, String authTokenType, boolean expectActivityLaunch, in Bundle options)72     void updateCredentials(in IAccountManagerResponse response, in Account account,
73         String authTokenType, boolean expectActivityLaunch, in Bundle options);
editProperties(in IAccountManagerResponse response, String accountType, boolean expectActivityLaunch)74     void editProperties(in IAccountManagerResponse response, String accountType,
75         boolean expectActivityLaunch);
confirmCredentialsAsUser(in IAccountManagerResponse response, in Account account, in Bundle options, boolean expectActivityLaunch, int userId)76     void confirmCredentialsAsUser(in IAccountManagerResponse response, in Account account,
77         in Bundle options, boolean expectActivityLaunch, int userId);
accountAuthenticated(in Account account)78     boolean accountAuthenticated(in Account account);
getAuthTokenLabel(in IAccountManagerResponse response, String accountType, String authTokenType)79     void getAuthTokenLabel(in IAccountManagerResponse response, String accountType,
80         String authTokenType);
81 
82     /* Shared accounts */
addSharedAccountsFromParentUser(int parentUserId, int userId, String opPackageName)83     void addSharedAccountsFromParentUser(int parentUserId, int userId, String opPackageName);
84 
85     /* Account renaming. */
renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName)86     void renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName);
getPreviousName(in Account account)87     String getPreviousName(in Account account);
88 
89     /* Add account in two steps. */
startAddAccountSession(in IAccountManagerResponse response, String accountType, String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch, in Bundle options)90     void startAddAccountSession(in IAccountManagerResponse response, String accountType,
91         String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
92         in Bundle options);
93 
94     /* Update credentials in two steps. */
startUpdateCredentialsSession(in IAccountManagerResponse response, in Account account, String authTokenType, boolean expectActivityLaunch, in Bundle options)95     void startUpdateCredentialsSession(in IAccountManagerResponse response, in Account account,
96         String authTokenType, boolean expectActivityLaunch, in Bundle options);
97 
98     /* Finish session started by startAddAccountSession(...) or startUpdateCredentialsSession(...)
99     for user */
finishSessionAsUser(in IAccountManagerResponse response, in Bundle sessionBundle, boolean expectActivityLaunch, in Bundle appInfo, int userId)100     void finishSessionAsUser(in IAccountManagerResponse response, in Bundle sessionBundle,
101         boolean expectActivityLaunch, in Bundle appInfo, int userId);
102 
103     /* Check if an account exists on any user on the device. */
someUserHasAccount(in Account account)104     boolean someUserHasAccount(in Account account);
105 
106     /* Check if credentials update is suggested */
isCredentialsUpdateSuggested(in IAccountManagerResponse response, in Account account, String statusToken)107     void isCredentialsUpdateSuggested(in IAccountManagerResponse response, in Account account,
108         String statusToken);
109 
110     /* Returns Map<String, Integer> from package name to visibility with all values stored for given account */
getPackagesAndVisibilityForAccount(in Account account)111     Map getPackagesAndVisibilityForAccount(in Account account);
addAccountExplicitlyWithVisibility(in Account account, String password, in Bundle extras, in Map visibility)112     boolean addAccountExplicitlyWithVisibility(in Account account, String password, in Bundle extras,
113             in Map visibility);
setAccountVisibility(in Account a, in String packageName, int newVisibility)114     boolean setAccountVisibility(in Account a, in String packageName, int newVisibility);
getAccountVisibility(in Account a, in String packageName)115     int getAccountVisibility(in Account a, in String packageName);
116     /* Type may be null returns Map <Account, Integer>*/
getAccountsAndVisibilityForPackage(in String packageName, in String accountType)117     Map getAccountsAndVisibilityForPackage(in String packageName, in String accountType);
118 
registerAccountListener(in String[] accountTypes, String opPackageName)119     void registerAccountListener(in String[] accountTypes, String opPackageName);
unregisterAccountListener(in String[] accountTypes, String opPackageName)120     void unregisterAccountListener(in String[] accountTypes, String opPackageName);
121 
122     /* Check if the package in a user can access an account */
hasAccountAccess(in Account account, String packageName, in UserHandle userHandle)123     boolean hasAccountAccess(in Account account, String packageName, in UserHandle userHandle);
124     /* Crate an intent to request account access for package and a given user id */
createRequestAccountAccessIntentSenderAsUser(in Account account, String packageName, in UserHandle userHandle)125     IntentSender createRequestAccountAccessIntentSenderAsUser(in Account account,
126         String packageName, in UserHandle userHandle);
127 
onAccountAccessed(String token)128     void onAccountAccessed(String token);
129 }
130