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
17package android.accounts;
18
19import android.accounts.IAccountManagerResponse;
20import android.accounts.Account;
21import android.accounts.AuthenticatorDescription;
22import android.content.IntentSender;
23import android.os.Bundle;
24import android.os.RemoteCallback;
25import android.os.UserHandle;
26
27import java.util.Map;
28
29/**
30 * Central application service that provides account management.
31 * @hide
32 */
33interface IAccountManager {
34    String getPassword(in Account account);
35    String getUserData(in Account account, String key);
36    AuthenticatorDescription[] getAuthenticatorTypes(int userId);
37    Account[] getAccounts(String accountType, String opPackageName);
38    Account[] getAccountsForPackage(String packageName, int uid, String opPackageName);
39    Account[] getAccountsByTypeForPackage(String type, String packageName, String opPackageName);
40    Account[] getAccountsAsUser(String accountType, int userId, String opPackageName);
41    void hasFeatures(in IAccountManagerResponse response, in Account account, in String[] features,
42        String opPackageName);
43    void getAccountByTypeAndFeatures(in IAccountManagerResponse response, String accountType,
44        in String[] features, String opPackageName);
45    void getAccountsByFeatures(in IAccountManagerResponse response, String accountType,
46        in String[] features, String opPackageName);
47    boolean addAccountExplicitly(in Account account, String password, in Bundle extras);
48    void removeAccount(in IAccountManagerResponse response, in Account account,
49        boolean expectActivityLaunch);
50    void removeAccountAsUser(in IAccountManagerResponse response, in Account account,
51        boolean expectActivityLaunch, int userId);
52    boolean removeAccountExplicitly(in Account account);
53    void copyAccountToUser(in IAccountManagerResponse response, in Account account,
54        int userFrom, int userTo);
55    void invalidateAuthToken(String accountType, String authToken);
56    String peekAuthToken(in Account account, String authTokenType);
57    void setAuthToken(in Account account, String authTokenType, String authToken);
58    void setPassword(in Account account, String password);
59    void clearPassword(in Account account);
60    void setUserData(in Account account, String key, String value);
61    void updateAppPermission(in Account account, String authTokenType, int uid, boolean value);
62
63    void getAuthToken(in IAccountManagerResponse response, in Account account,
64        String authTokenType, boolean notifyOnAuthFailure, boolean expectActivityLaunch,
65        in Bundle options);
66    void addAccount(in IAccountManagerResponse response, String accountType,
67        String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
68        in Bundle options);
69    void addAccountAsUser(in IAccountManagerResponse response, String accountType,
70        String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
71        in Bundle options, int userId);
72    void updateCredentials(in IAccountManagerResponse response, in Account account,
73        String authTokenType, boolean expectActivityLaunch, in Bundle options);
74    void editProperties(in IAccountManagerResponse response, String accountType,
75        boolean expectActivityLaunch);
76    void confirmCredentialsAsUser(in IAccountManagerResponse response, in Account account,
77        in Bundle options, boolean expectActivityLaunch, int userId);
78    boolean accountAuthenticated(in Account account);
79    void getAuthTokenLabel(in IAccountManagerResponse response, String accountType,
80        String authTokenType);
81
82    /* Shared accounts */
83    Account[] getSharedAccountsAsUser(int userId);
84    boolean removeSharedAccountAsUser(in Account account, int userId);
85    void addSharedAccountsFromParentUser(int parentUserId, int userId, String opPackageName);
86
87    /* Account renaming. */
88    void renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName);
89    String getPreviousName(in Account account);
90    boolean renameSharedAccountAsUser(in Account accountToRename, String newName, int userId);
91
92    /* Add account in two steps. */
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. */
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 */
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. */
107    boolean someUserHasAccount(in Account account);
108
109    /* Check if credentials update is suggested */
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 */
114    Map getPackagesAndVisibilityForAccount(in Account account);
115    boolean addAccountExplicitlyWithVisibility(in Account account, String password, in Bundle extras,
116            in Map visibility);
117    boolean setAccountVisibility(in Account a, in String packageName, int newVisibility);
118    int getAccountVisibility(in Account a, in String packageName);
119    /* Type may be null returns Map <Account, Integer>*/
120    Map getAccountsAndVisibilityForPackage(in String packageName, in String accountType);
121
122    void registerAccountListener(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 */
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 */
128    IntentSender createRequestAccountAccessIntentSenderAsUser(in Account account,
129        String packageName, in UserHandle userHandle);
130
131    void onAccountAccessed(String token);
132}
133