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