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 */
getSharedAccountsAsUser(int userId)83     Account[] getSharedAccountsAsUser(int userId);
removeSharedAccountAsUser(in Account account, int userId)84     boolean removeSharedAccountAsUser(in Account account, int userId);
addSharedAccountsFromParentUser(int parentUserId, int userId, String opPackageName)85     void addSharedAccountsFromParentUser(int parentUserId, int userId, String opPackageName);
86 
87     /* Account renaming. */
renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName)88     void renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName);
getPreviousName(in Account account)89     String getPreviousName(in Account account);
renameSharedAccountAsUser(in Account accountToRename, String newName, int userId)90     boolean renameSharedAccountAsUser(in Account accountToRename, String newName, int userId);
91 
92     /* Add account in two steps. */
startAddAccountSession(in IAccountManagerResponse response, String accountType, String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch, in Bundle options)93     void startAddAccountSession(in IAccountManagerResponse response, String accountType,
94         String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
95         in Bundle options);
96 
97     /* Update credentials in two steps. */
startUpdateCredentialsSession(in IAccountManagerResponse response, in Account account, String authTokenType, boolean expectActivityLaunch, in Bundle options)98     void startUpdateCredentialsSession(in IAccountManagerResponse response, in Account account,
99         String authTokenType, boolean expectActivityLaunch, in Bundle options);
100 
101     /* Finish session started by startAddAccountSession(...) or startUpdateCredentialsSession(...)
102     for user */
finishSessionAsUser(in IAccountManagerResponse response, in Bundle sessionBundle, boolean expectActivityLaunch, in Bundle appInfo, int userId)103     void finishSessionAsUser(in IAccountManagerResponse response, in Bundle sessionBundle,
104         boolean expectActivityLaunch, in Bundle appInfo, int userId);
105 
106     /* Check if an account exists on any user on the device. */
someUserHasAccount(in Account account)107     boolean someUserHasAccount(in Account account);
108 
109     /* Check if credentials update is suggested */
isCredentialsUpdateSuggested(in IAccountManagerResponse response, in Account account, String statusToken)110     void isCredentialsUpdateSuggested(in IAccountManagerResponse response, in Account account,
111         String statusToken);
112 
113     /* Returns Map<String, Integer> from package name to visibility with all values stored for given account */
getPackagesAndVisibilityForAccount(in Account account)114     Map getPackagesAndVisibilityForAccount(in Account account);
addAccountExplicitlyWithVisibility(in Account account, String password, in Bundle extras, in Map visibility)115     boolean addAccountExplicitlyWithVisibility(in Account account, String password, in Bundle extras,
116             in Map visibility);
setAccountVisibility(in Account a, in String packageName, int newVisibility)117     boolean setAccountVisibility(in Account a, in String packageName, int newVisibility);
getAccountVisibility(in Account a, in String packageName)118     int getAccountVisibility(in Account a, in String packageName);
119     /* Type may be null returns Map <Account, Integer>*/
getAccountsAndVisibilityForPackage(in String packageName, in String accountType)120     Map getAccountsAndVisibilityForPackage(in String packageName, in String accountType);
121 
registerAccountListener(in String[] accountTypes, String opPackageName)122     void registerAccountListener(in String[] accountTypes, String opPackageName);
unregisterAccountListener(in String[] accountTypes, String opPackageName)123     void unregisterAccountListener(in String[] accountTypes, String opPackageName);
124 
125     /* Check if the package in a user can access an account */
hasAccountAccess(in Account account, String packageName, in UserHandle userHandle)126     boolean hasAccountAccess(in Account account, String packageName, in UserHandle userHandle);
127     /* Crate an intent to request account access for package and a given user id */
createRequestAccountAccessIntentSenderAsUser(in Account account, String packageName, in UserHandle userHandle)128     IntentSender createRequestAccountAccessIntentSenderAsUser(in Account account,
129         String packageName, in UserHandle userHandle);
130 
onAccountAccessed(String token)131     void onAccountAccessed(String token);
132 }
133