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.IAccountAuthenticatorResponse;
20 import android.accounts.Account;
21 import android.os.Bundle;
22 
23 /**
24  * Service that allows the interaction with an authentication server.
25  * @hide
26  */
27 oneway interface IAccountAuthenticator {
28     /**
29      * prompts the user for account information and adds the result to the IAccountManager
30      */
31     @EnforcePermission("ACCOUNT_MANAGER")
32     @UnsupportedAppUsage
addAccount(in IAccountAuthenticatorResponse response, String accountType, String authTokenType, in String[] requiredFeatures, in Bundle options)33     void addAccount(in IAccountAuthenticatorResponse response, String accountType,
34         String authTokenType, in String[] requiredFeatures, in Bundle options);
35 
36     /**
37      * prompts the user for the credentials of the account
38      */
39     @EnforcePermission("ACCOUNT_MANAGER")
40     @UnsupportedAppUsage
confirmCredentials(in IAccountAuthenticatorResponse response, in Account account, in Bundle options)41     void confirmCredentials(in IAccountAuthenticatorResponse response, in Account account,
42         in Bundle options);
43 
44     /**
45      * gets the password by either prompting the user or querying the IAccountManager
46      */
47     @EnforcePermission("ACCOUNT_MANAGER")
48     @UnsupportedAppUsage
getAuthToken(in IAccountAuthenticatorResponse response, in Account account, String authTokenType, in Bundle options)49     void getAuthToken(in IAccountAuthenticatorResponse response, in Account account,
50         String authTokenType, in Bundle options);
51 
52     /**
53      * Gets the user-visible label of the given authtoken type.
54      */
55     @EnforcePermission("ACCOUNT_MANAGER")
56     @UnsupportedAppUsage
getAuthTokenLabel(in IAccountAuthenticatorResponse response, String authTokenType)57     void getAuthTokenLabel(in IAccountAuthenticatorResponse response, String authTokenType);
58 
59     /**
60      * prompts the user for a new password and writes it to the IAccountManager
61      */
62     @EnforcePermission("ACCOUNT_MANAGER")
63     @UnsupportedAppUsage
updateCredentials(in IAccountAuthenticatorResponse response, in Account account, String authTokenType, in Bundle options)64     void updateCredentials(in IAccountAuthenticatorResponse response, in Account account,
65         String authTokenType, in Bundle options);
66 
67     /**
68      * launches an activity that lets the user edit and set the properties for an authenticator
69      */
70     @EnforcePermission("ACCOUNT_MANAGER")
71     @UnsupportedAppUsage
editProperties(in IAccountAuthenticatorResponse response, String accountType)72     void editProperties(in IAccountAuthenticatorResponse response, String accountType);
73 
74     /**
75      * returns a Bundle where the boolean value BOOLEAN_RESULT_KEY is set if the account has the
76      * specified features
77      */
78     @EnforcePermission("ACCOUNT_MANAGER")
79     @UnsupportedAppUsage
hasFeatures(in IAccountAuthenticatorResponse response, in Account account, in String[] features)80     void hasFeatures(in IAccountAuthenticatorResponse response, in Account account,
81         in String[] features);
82 
83     /**
84      * Gets whether or not the account is allowed to be removed.
85      */
86     @EnforcePermission("ACCOUNT_MANAGER")
87     @UnsupportedAppUsage
getAccountRemovalAllowed(in IAccountAuthenticatorResponse response, in Account account)88     void getAccountRemovalAllowed(in IAccountAuthenticatorResponse response, in Account account);
89 
90     /**
91      * Returns a Bundle containing the required credentials to copy the account across users.
92      */
93     @EnforcePermission("ACCOUNT_MANAGER")
getAccountCredentialsForCloning(in IAccountAuthenticatorResponse response, in Account account)94     void getAccountCredentialsForCloning(in IAccountAuthenticatorResponse response,
95             in Account account);
96 
97     /**
98      * Uses the Bundle containing credentials from another instance of the authenticator to create
99      * a copy of the account on this user.
100      */
101     @EnforcePermission("ACCOUNT_MANAGER")
addAccountFromCredentials(in IAccountAuthenticatorResponse response, in Account account, in Bundle accountCredentials)102     void addAccountFromCredentials(in IAccountAuthenticatorResponse response, in Account account,
103             in Bundle accountCredentials);
104 
105     /**
106      * Starts the add account session by prompting the user for account information
107      * and return a Bundle containing data to finish the session later.
108      */
109     @EnforcePermission("ACCOUNT_MANAGER")
startAddAccountSession(in IAccountAuthenticatorResponse response, String accountType, String authTokenType, in String[] requiredFeatures, in Bundle options)110     void startAddAccountSession(in IAccountAuthenticatorResponse response, String accountType,
111         String authTokenType, in String[] requiredFeatures, in Bundle options);
112 
113     /**
114      * Prompts the user for a new password but does not write it to the IAccountManager.
115      */
116     @EnforcePermission("ACCOUNT_MANAGER")
startUpdateCredentialsSession(in IAccountAuthenticatorResponse response, in Account account, String authTokenType, in Bundle options)117     void startUpdateCredentialsSession(in IAccountAuthenticatorResponse response, in Account account,
118         String authTokenType, in Bundle options);
119 
120     /**
121      * Finishes the session started by startAddAccountSession(...) or
122      * startUpdateCredentialsSession(...) by adding account to or updating local credentials
123      * in the IAccountManager.
124      */
125     @EnforcePermission("ACCOUNT_MANAGER")
finishSession(in IAccountAuthenticatorResponse response, String accountType, in Bundle sessionBundle)126     void finishSession(in IAccountAuthenticatorResponse response, String accountType,
127         in Bundle sessionBundle);
128 
129     /**
130      * Checks if the credentials of the provided account should be updated.
131      */
132     @EnforcePermission("ACCOUNT_MANAGER")
isCredentialsUpdateSuggested(in IAccountAuthenticatorResponse response, in Account account, String statusToken)133     void isCredentialsUpdateSuggested(in IAccountAuthenticatorResponse response, in Account account,
134         String statusToken);
135 }
136