blob: 1cd6a74973bdecfc606e34fcde075e120d274a57 [file] [log] [blame]
Fred Quintana33269202009-04-20 16:05:10 -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
19import android.os.Bundle;
20import android.os.Parcel;
21import android.os.Parcelable;
22import android.os.RemoteException;
23
24/**
Fred Quintana9efe2652009-10-28 22:53:51 -070025 * Used by Account Authenticators to return a response.
Fred Quintana33269202009-04-20 16:05:10 -070026 */
27public class AccountManagerResponse implements Parcelable {
28 private IAccountManagerResponse mResponse;
29
Fred Quintana9efe2652009-10-28 22:53:51 -070030 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070031 public AccountManagerResponse(IAccountManagerResponse response) {
32 mResponse = response;
33 }
34
Fred Quintana9efe2652009-10-28 22:53:51 -070035 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070036 public AccountManagerResponse(Parcel parcel) {
37 mResponse =
38 IAccountManagerResponse.Stub.asInterface(parcel.readStrongBinder());
39 }
40
41 public void onResult(Bundle result) {
42 try {
43 mResponse.onResult(result);
44 } catch (RemoteException e) {
45 // this should never happen
46 }
47 }
48
49 public void onError(int errorCode, String errorMessage) {
50 try {
51 mResponse.onError(errorCode, errorMessage);
52 } catch (RemoteException e) {
53 // this should never happen
54 }
55 }
56
Fred Quintana9efe2652009-10-28 22:53:51 -070057 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070058 public int describeContents() {
59 return 0;
60 }
61
Fred Quintana9efe2652009-10-28 22:53:51 -070062 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070063 public void writeToParcel(Parcel dest, int flags) {
64 dest.writeStrongBinder(mResponse.asBinder());
65 }
66
Fred Quintana9efe2652009-10-28 22:53:51 -070067 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070068 public static final Creator<AccountManagerResponse> CREATOR =
69 new Creator<AccountManagerResponse>() {
70 public AccountManagerResponse createFromParcel(Parcel source) {
71 return new AccountManagerResponse(source);
72 }
73
74 public AccountManagerResponse[] newArray(int size) {
75 return new AccountManagerResponse[size];
76 }
77 };
Fred Quintana9efe2652009-10-28 22:53:51 -070078}