AccountAuthenticatorResponse.java revision 603073430bbcb1bd29db7afb9b14e2732ad589fb
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 */
16
17package android.accounts;
18
19import android.os.RemoteException;
20
21/**
22 * Object that wraps calls to an {@link IAccountAuthenticatorResponse} object.
23 * TODO: this interface is still in flux
24 */
25public class AccountAuthenticatorResponse {
26    private IAccountAuthenticatorResponse mAccountAuthenticatorResponse;
27
28    public AccountAuthenticatorResponse(IAccountAuthenticatorResponse response) {
29        mAccountAuthenticatorResponse = response;
30    }
31
32    public void onFinished(int result) {
33        try {
34            mAccountAuthenticatorResponse.onIntResult(result);
35        } catch (RemoteException e) {
36            // this should never happen
37        }
38    }
39
40    public void onFinished(String result) {
41        try {
42            mAccountAuthenticatorResponse.onStringResult(result);
43        } catch (RemoteException e) {
44            // this should never happen
45        }
46    }
47
48    public void onFinished(boolean result) {
49        try {
50            mAccountAuthenticatorResponse.onBooleanResult(result);
51        } catch (RemoteException e) {
52            // this should never happen
53        }
54    }
55
56    public void onError(int errorCode, String errorMessage) {
57        try {
58            mAccountAuthenticatorResponse.onError(errorCode, errorMessage);
59        } catch (RemoteException e) {
60            // this should never happen
61        }
62    }
63
64    public IAccountAuthenticatorResponse getIAccountAuthenticatorResponse() {
65        return mAccountAuthenticatorResponse;
66    }
67}
68