blob: 68c17c32fdc3e9c9e9db64976236218d17a35a79 [file] [log] [blame]
Svetoslav Ganov5cb29732016-07-11 19:32:30 -07001/*
2 * Copyright (C) 2016 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.annotation.IntRange;
20import android.annotation.NonNull;
21import android.os.RemoteCallback;
22
23/**
24 * Account manager local system service interface.
25 *
26 * @hide Only for use within the system server.
27 */
28public abstract class AccountManagerInternal {
29
30 /**
Svet Ganovf6d424f12016-09-20 20:18:53 -070031 * Listener for explicit UID account access grant changes.
32 */
33 public interface OnAppPermissionChangeListener {
34
35 /**
36 * Called when the explicit grant state for a given UID to
37 * access an account changes.
38 *
39 * @param account The account
40 * @param uid The UID for which the grant changed
41 */
42 public void onAppPermissionChanged(Account account, int uid);
43 }
44
45 /**
Svetoslav Ganov5cb29732016-07-11 19:32:30 -070046 * Requests that a given package is given access to an account.
47 * The provided callback will be invoked with a {@link android.os.Bundle}
48 * containing the result which will be a boolean value mapped to the
49 * {@link AccountManager#KEY_BOOLEAN_RESULT} key.
50 *
51 * @param account The account for which to request.
52 * @param packageName The package name for which to request.
53 * @param userId Concrete user id for which to request.
54 * @param callback A callback for receiving the result.
55 */
Svet Ganovf6d424f12016-09-20 20:18:53 -070056 public abstract void requestAccountAccess(@NonNull Account account,
Svetoslav Ganov5cb29732016-07-11 19:32:30 -070057 @NonNull String packageName, @IntRange(from = 0) int userId,
58 @NonNull RemoteCallback callback);
Svet Ganovf6d424f12016-09-20 20:18:53 -070059
60 /**
61 * Check whether the given UID has access to the account.
62 *
63 * @param account The account
64 * @param uid The UID
65 * @return Whether the UID can access the account
66 */
67 public abstract boolean hasAccountAccess(@NonNull Account account, @IntRange(from = 0) int uid);
68
69 /**
70 * Adds a listener for explicit UID account access grant changes.
71 *
72 * @param listener The listener
73 */
74 public abstract void addOnAppPermissionChangeListener(
75 @NonNull OnAppPermissionChangeListener listener);
Svet Ganov5d09c992016-09-07 09:57:41 -070076
77 /**
78 * Backups the account access permissions.
79 * @param userId The user for which to backup.
80 * @return The backup data.
81 */
82 public abstract byte[] backupAccountAccessPermissions(int userId);
83
84 /**
85 * Restores the account access permissions.
86 * @param data The restore data.
87 * @param userId The user for which to restore.
88 */
89 public abstract void restoreAccountAccessPermissions(byte[] data, int userId);
Svetoslav Ganov5cb29732016-07-11 19:32:30 -070090}