blob: 7198046cfa25445581d11cd7276f14cfbe61e7ab [file] [log] [blame]
Fred Quintana60307342009-03-24 22:48:12 -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 */
16
17package android.accounts;
18
Fred Quintanaa698f422009-04-08 19:14:54 -070019import android.os.Bundle;
20import android.os.Parcelable;
21import android.os.Parcel;
Fred Quintana60307342009-03-24 22:48:12 -070022import android.os.RemoteException;
23
24/**
25 * Object that wraps calls to an {@link IAccountAuthenticatorResponse} object.
26 * TODO: this interface is still in flux
27 */
Fred Quintanaa698f422009-04-08 19:14:54 -070028public class AccountAuthenticatorResponse implements Parcelable {
Fred Quintana60307342009-03-24 22:48:12 -070029 private IAccountAuthenticatorResponse mAccountAuthenticatorResponse;
30
31 public AccountAuthenticatorResponse(IAccountAuthenticatorResponse response) {
32 mAccountAuthenticatorResponse = response;
33 }
34
Fred Quintanaa698f422009-04-08 19:14:54 -070035 public AccountAuthenticatorResponse(Parcel parcel) {
36 mAccountAuthenticatorResponse =
37 IAccountAuthenticatorResponse.Stub.asInterface(parcel.readStrongBinder());
38 }
39
40 public void onResult(Bundle result) {
Fred Quintana60307342009-03-24 22:48:12 -070041 try {
Fred Quintanaa698f422009-04-08 19:14:54 -070042 mAccountAuthenticatorResponse.onResult(result);
Fred Quintana60307342009-03-24 22:48:12 -070043 } catch (RemoteException e) {
44 // this should never happen
45 }
46 }
47
Fred Quintanaa698f422009-04-08 19:14:54 -070048 public void onRequestContinued() {
Fred Quintana60307342009-03-24 22:48:12 -070049 try {
Fred Quintanaa698f422009-04-08 19:14:54 -070050 mAccountAuthenticatorResponse.onRequestContinued();
Fred Quintana60307342009-03-24 22:48:12 -070051 } 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
Fred Quintanaa698f422009-04-08 19:14:54 -070064 public int describeContents() {
65 return 0;
Fred Quintana60307342009-03-24 22:48:12 -070066 }
Fred Quintanaa698f422009-04-08 19:14:54 -070067
68 public void writeToParcel(Parcel dest, int flags) {
69 dest.writeStrongBinder(mAccountAuthenticatorResponse.asBinder());
70 }
71
72 public static final Creator<AccountAuthenticatorResponse> CREATOR =
73 new Creator<AccountAuthenticatorResponse>() {
74 public AccountAuthenticatorResponse createFromParcel(Parcel source) {
75 return new AccountAuthenticatorResponse(source);
76 }
77
78 public AccountAuthenticatorResponse[] newArray(int size) {
79 return new AccountAuthenticatorResponse[size];
80 }
81 };
Fred Quintana60307342009-03-24 22:48:12 -070082}