1/*
2 * Copyright (C) 2010 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.content.pm.RegisteredServicesCache;
20import android.content.pm.RegisteredServicesCacheListener;
21import android.os.Handler;
22
23import java.io.FileDescriptor;
24import java.io.PrintWriter;
25import java.util.Collection;
26
27/**
28 * An interface to the Authenticator specialization of RegisteredServicesCache. The use of
29 * this interface by the AccountManagerService makes it easier to unit test it.
30 * @hide
31 */
32public interface IAccountAuthenticatorCache {
33    /**
34     * Accessor for the {@link android.content.pm.RegisteredServicesCache.ServiceInfo} that
35     * matched the specified {@link android.accounts.AuthenticatorDescription} or null
36     * if none match.
37     * @param type the authenticator type to return
38     * @return the {@link android.content.pm.RegisteredServicesCache.ServiceInfo} that
39     * matches the account type or null if none is present
40     */
41    RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> getServiceInfo(
42            AuthenticatorDescription type, int userId);
43
44    /**
45     * @return A copy of a Collection of all the current Authenticators.
46     */
47    Collection<RegisteredServicesCache.ServiceInfo<AuthenticatorDescription>> getAllServices(
48            int userId);
49
50    /**
51     * Dumps the state of the cache. See
52     * {@link android.os.Binder#dump(java.io.FileDescriptor, java.io.PrintWriter, String[])}
53     */
54    void dump(FileDescriptor fd, PrintWriter fout, String[] args, int userId);
55
56    /**
57     * Sets a listener that will be notified whenever the authenticator set changes
58     * @param listener the listener to notify, or null
59     * @param handler the {@link Handler} on which the notification will be posted. If null
60     * the notification will be posted on the main thread.
61     */
62    void setListener(RegisteredServicesCacheListener<AuthenticatorDescription> listener,
63            Handler handler);
64
65    void invalidateCache(int userId);
66}
67