blob: 369a7c396e3a0dcf0c17a36fcfb8b56acc37efbf [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 Quintana5994cd22009-11-18 17:00:10 -080025 * Used to return a response to the AccountManager.
26 * @hide
Fred Quintana33269202009-04-20 16:05:10 -070027 */
28public class AccountManagerResponse implements Parcelable {
29 private IAccountManagerResponse mResponse;
30
Fred Quintana9efe2652009-10-28 22:53:51 -070031 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070032 public AccountManagerResponse(IAccountManagerResponse response) {
33 mResponse = response;
34 }
35
Fred Quintana9efe2652009-10-28 22:53:51 -070036 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070037 public AccountManagerResponse(Parcel parcel) {
38 mResponse =
39 IAccountManagerResponse.Stub.asInterface(parcel.readStrongBinder());
40 }
41
42 public void onResult(Bundle result) {
43 try {
44 mResponse.onResult(result);
45 } catch (RemoteException e) {
46 // this should never happen
47 }
48 }
49
50 public void onError(int errorCode, String errorMessage) {
51 try {
52 mResponse.onError(errorCode, errorMessage);
53 } catch (RemoteException e) {
54 // this should never happen
55 }
56 }
57
Fred Quintana9efe2652009-10-28 22:53:51 -070058 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070059 public int describeContents() {
60 return 0;
61 }
62
Fred Quintana9efe2652009-10-28 22:53:51 -070063 /** @hide */
Fred Quintana33269202009-04-20 16:05:10 -070064 public void writeToParcel(Parcel dest, int flags) {
65 dest.writeStrongBinder(mResponse.asBinder());
66 }
67
Fred Quintana9efe2652009-10-28 22:53:51 -070068 /** @hide */
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070069 public static final @android.annotation.NonNull Creator<AccountManagerResponse> CREATOR =
Fred Quintana33269202009-04-20 16:05:10 -070070 new Creator<AccountManagerResponse>() {
71 public AccountManagerResponse createFromParcel(Parcel source) {
72 return new AccountManagerResponse(source);
73 }
74
75 public AccountManagerResponse[] newArray(int size) {
76 return new AccountManagerResponse[size];
77 }
78 };
Fred Quintana9efe2652009-10-28 22:53:51 -070079}