blob: b2ea84f4930602fcd2c9094bb7d97d11ddf07f73 [file] [log] [blame]
Fred Quintanaa698f422009-04-08 19:14:54 -07001/*
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 android.os.Bundle;
19
20import java.io.IOException;
21import java.util.concurrent.Future;
22import java.util.concurrent.TimeUnit;
23
24/**
25 * An extension of {@link Future} that provides wrappers for {@link #get()} that handle the various
26 * exceptions that {@link #get()} may return and rethrows them as exceptions specific to
27 * {@link AccountManager}.
28 */
29public interface Future2 extends Future<Bundle> {
30 /**
31 * Wrapper for {@link Future#get()}. If the get() throws {@link InterruptedException} then the
32 * {@link Future2} is canceled and {@link OperationCanceledException} is thrown.
33 * @return the {@link android.os.Bundle} that is returned by {@link Future#get()}
34 * @throws OperationCanceledException if get() throws the unchecked
35 * {@link java.util.concurrent.CancellationException} or if the {@link Future2} was interrupted.
36 * @throws IOException if the request was unable to complete due to a network error
37 * @throws AuthenticatorException if there was an error communicating with the
38 * {@link AbstractAccountAuthenticator}.
39 */
40 Bundle getResult()
41 throws OperationCanceledException, IOException, AuthenticatorException;
42
43 /**
44 * Wrapper for {@link Future#get()}. If the get() throws {@link InterruptedException} then the
45 * {@link Future2} is canceled and {@link OperationCanceledException} is thrown.
46 * @param timeout the maximum time to wait
47 * @param unit the time unit of the timeout argument
48 * @return the {@link android.os.Bundle} that is returned by {@link Future#get()}
49 * @throws OperationCanceledException if get() throws the unchecked
50 * {@link java.util.concurrent.CancellationException} or if the {@link Future2} was interrupted.
51 * @throws IOException if the request was unable to complete due to a network error
52 * @throws AuthenticatorException if there was an error communicating with the
53 * {@link AbstractAccountAuthenticator}.
54 */
55 Bundle getResult(long timeout, TimeUnit unit)
56 throws OperationCanceledException, IOException, AuthenticatorException;
57}