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
27/**
28 * Central application service that provides account management.
29 * @hide
30 */
31interface IAccountManager {
32    String getPassword(in Account account);
33    String getUserData(in Account account, String key);
34    AuthenticatorDescription[] getAuthenticatorTypes(int userId);
35    Account[] getAccounts(String accountType, String opPackageName);
36    Account[] getAccountsForPackage(String packageName, int uid, String opPackageName);
37    Account[] getAccountsByTypeForPackage(String type, String packageName, String opPackageName);
38    Account[] getAccountsAsUser(String accountType, int userId, String opPackageName);
39    void hasFeatures(in IAccountManagerResponse response, in Account account, in String[] features,
40        String opPackageName);
41    void getAccountsByFeatures(in IAccountManagerResponse response, String accountType,
42        in String[] features, String opPackageName);
43    boolean addAccountExplicitly(in Account account, String password, in Bundle extras);
44    void removeAccount(in IAccountManagerResponse response, in Account account,
45        boolean expectActivityLaunch);
46    void removeAccountAsUser(in IAccountManagerResponse response, in Account account,
47        boolean expectActivityLaunch, int userId);
48    boolean removeAccountExplicitly(in Account account);
49    void copyAccountToUser(in IAccountManagerResponse response, in Account account,
50        int userFrom, int userTo);
51    void invalidateAuthToken(String accountType, String authToken);
52    String peekAuthToken(in Account account, String authTokenType);
53    void setAuthToken(in Account account, String authTokenType, String authToken);
54    void setPassword(in Account account, String password);
55    void clearPassword(in Account account);
56    void setUserData(in Account account, String key, String value);
57    void updateAppPermission(in Account account, String authTokenType, int uid, boolean value);
58
59    void getAuthToken(in IAccountManagerResponse response, in Account account,
60        String authTokenType, boolean notifyOnAuthFailure, boolean expectActivityLaunch,
61        in Bundle options);
62    void addAccount(in IAccountManagerResponse response, String accountType,
63        String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
64        in Bundle options);
65    void addAccountAsUser(in IAccountManagerResponse response, String accountType,
66        String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
67        in Bundle options, int userId);
68    void updateCredentials(in IAccountManagerResponse response, in Account account,
69        String authTokenType, boolean expectActivityLaunch, in Bundle options);
70    void editProperties(in IAccountManagerResponse response, String accountType,
71        boolean expectActivityLaunch);
72    void confirmCredentialsAsUser(in IAccountManagerResponse response, in Account account,
73        in Bundle options, boolean expectActivityLaunch, int userId);
74    boolean accountAuthenticated(in Account account);
75    void getAuthTokenLabel(in IAccountManagerResponse response, String accountType,
76        String authTokenType);
77
78    /* Shared accounts */
79    Account[] getSharedAccountsAsUser(int userId);
80    boolean removeSharedAccountAsUser(in Account account, int userId);
81    void addSharedAccountsFromParentUser(int parentUserId, int userId);
82
83    /* Account renaming. */
84    void renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName);
85    String getPreviousName(in Account account);
86    boolean renameSharedAccountAsUser(in Account accountToRename, String newName, int userId);
87
88    /* Add account in two steps. */
89    void startAddAccountSession(in IAccountManagerResponse response, String accountType,
90        String authTokenType, in String[] requiredFeatures, boolean expectActivityLaunch,
91        in Bundle options);
92
93    /* Update credentials in two steps. */
94    void startUpdateCredentialsSession(in IAccountManagerResponse response, in Account account,
95        String authTokenType, boolean expectActivityLaunch, in Bundle options);
96
97    /* Finish session started by startAddAccountSession(...) or startUpdateCredentialsSession(...) for user */
98    void finishSessionAsUser(in IAccountManagerResponse response, in Bundle sessionBundle,
99        boolean expectActivityLaunch, in Bundle appInfo, int userId);
100
101    /* Check if an account exists on any user on the device. */
102    boolean someUserHasAccount(in Account account);
103
104    /* Check if credentials update is suggested */
105    void isCredentialsUpdateSuggested(in IAccountManagerResponse response, in Account account,
106        String statusToken);
107
108    /* Check if the package in a user can access an account */
109    boolean hasAccountAccess(in Account account, String packageName, in UserHandle userHandle);
110    /* Crate an intent to request account access for package and a given user id */
111    IntentSender createRequestAccountAccessIntentSenderAsUser(in Account account,
112        String packageName, in UserHandle userHandle);
113
114    void onAccountAccessed(String token);
115}
116