AccountManagerFuture.java revision 4a51c20ce607c74914f90fd897f04080121ac13b
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 */ 16package android.accounts; 17 18import java.util.concurrent.Future; 19import java.util.concurrent.TimeUnit; 20import java.util.concurrent.ExecutionException; 21import java.util.concurrent.TimeoutException; 22import java.io.IOException; 23 24/** 25 * An extension of {@link java.util.concurrent.Future} that provides wrappers for {@link #get()} 26 * that handle the various 27 * exceptions that {@link #get()} may return and rethrows them as exceptions specific to 28 * {@link android.accounts.AccountManager}. 29 */ 30public interface AccountManagerFuture<V> extends Future<V> { 31 /** 32 * Wrapper for {@link java.util.concurrent.Future#get()}. If the get() throws 33 * {@link InterruptedException} then the 34 * {@link AccountManagerFuture} is canceled and 35 * {@link android.accounts.OperationCanceledException} is thrown. 36 * @return the {@link android.os.Bundle} that is returned by get() 37 * @throws android.accounts.OperationCanceledException if get() throws the unchecked 38 * CancellationException 39 * or if the Future was interrupted. 40 */ 41 V getResult() throws OperationCanceledException, IOException, AuthenticatorException; 42 43 /** 44 * Wrapper for {@link java.util.concurrent.Future#get()}. If the get() throws 45 * {@link InterruptedException} then the 46 * {@link AccountManagerFuture} is canceled and 47 * {@link android.accounts.OperationCanceledException} is thrown. 48 * @param timeout the maximum time to wait 49 * @param unit the time unit of the timeout argument 50 * @return the {@link android.os.Bundle} that is returned by 51 * {@link java.util.concurrent.Future#get()} 52 * @throws android.accounts.OperationCanceledException if get() throws the unchecked 53 * {@link java.util.concurrent.CancellationException} or if the {@link AccountManagerFuture} 54 * was interrupted. 55 */ 56 V getResult(long timeout, TimeUnit unit) 57 throws OperationCanceledException, IOException, AuthenticatorException; 58 59 /** @deprecated Use {@link #getResult} */ 60 @Deprecated 61 V get() throws InterruptedException, ExecutionException; 62 63 /** @deprecated Use {@link #getResult} */ 64 @Deprecated 65 V get(long timeout, TimeUnit unit) 66 throws InterruptedException, ExecutionException, TimeoutException; 67}