156285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana/* 256285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * Copyright (C) 2010 The Android Open Source Project 356285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * 456285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * Licensed under the Apache License, Version 2.0 (the "License"); 556285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * you may not use this file except in compliance with the License. 656285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * You may obtain a copy of the License at 756285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * 856285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * http://www.apache.org/licenses/LICENSE-2.0 956285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * 1056285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * Unless required by applicable law or agreed to in writing, software 1156285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * distributed under the License is distributed on an "AS IS" BASIS, 1256285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1356285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * See the License for the specific language governing permissions and 1456285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * limitations under the License. 1556285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana */ 1656285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana 1756285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintanapackage android.accounts; 1856285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana 1956285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintanaimport android.content.pm.RegisteredServicesCache; 2056285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintanaimport android.content.pm.RegisteredServicesCacheListener; 2156285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintanaimport android.os.Handler; 2256285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana 2356285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintanaimport java.io.FileDescriptor; 2456285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintanaimport java.io.PrintWriter; 2556285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintanaimport java.util.Collection; 2656285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana 2756285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana/** 2856285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * An interface to the Authenticator specialization of RegisteredServicesCache. The use of 2956285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * this interface by the AccountManagerService makes it easier to unit test it. 3056285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * @hide 3156285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana */ 3256285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintanapublic interface IAccountAuthenticatorCache { 3356285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana /** 3456285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * Accessor for the {@link android.content.pm.RegisteredServicesCache.ServiceInfo} that 3556285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * matched the specified {@link android.accounts.AuthenticatorDescription} or null 3656285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * if none match. 3756285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * @param type the authenticator type to return 3856285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * @return the {@link android.content.pm.RegisteredServicesCache.ServiceInfo} that 3956285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * matches the account type or null if none is present 4056285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana */ 4156285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> getServiceInfo( 426ab72d74b86e5f4ec3c3909366fd46c225a66bd7Jeff Sharkey AuthenticatorDescription type, int userId); 4356285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana 4456285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana /** 4556285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * @return A copy of a Collection of all the current Authenticators. 4656285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana */ 476ab72d74b86e5f4ec3c3909366fd46c225a66bd7Jeff Sharkey Collection<RegisteredServicesCache.ServiceInfo<AuthenticatorDescription>> getAllServices( 486ab72d74b86e5f4ec3c3909366fd46c225a66bd7Jeff Sharkey int userId); 4956285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana 5056285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana /** 5156285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * Dumps the state of the cache. See 5256285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * {@link android.os.Binder#dump(java.io.FileDescriptor, java.io.PrintWriter, String[])} 5356285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana */ 546ab72d74b86e5f4ec3c3909366fd46c225a66bd7Jeff Sharkey void dump(FileDescriptor fd, PrintWriter fout, String[] args, int userId); 5556285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana 5656285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana /** 5756285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * Sets a listener that will be notified whenever the authenticator set changes 5856285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * @param listener the listener to notify, or null 5956285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * @param handler the {@link Handler} on which the notification will be posted. If null 6056285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana * the notification will be posted on the main thread. 6156285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana */ 6256285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana void setListener(RegisteredServicesCacheListener<AuthenticatorDescription> listener, 6356285a60e83138bb4b4f2d3bdec91b2f3ca11aa2Fred Quintana Handler handler); 6426ff6626fc4ee0ae46f01ad309b366921da589feKenny Root 656ab72d74b86e5f4ec3c3909366fd46c225a66bd7Jeff Sharkey void invalidateCache(int userId); 666ab72d74b86e5f4ec3c3909366fd46c225a66bd7Jeff Sharkey} 67