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 
17 package android.accounts;
18 
19 import android.os.Bundle;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 import android.os.RemoteException;
23 
24 /**
25  * Used to return a response to the AccountManager.
26  * @hide
27  */
28 public class AccountManagerResponse implements Parcelable {
29     private IAccountManagerResponse mResponse;
30 
31     /** @hide */
AccountManagerResponse(IAccountManagerResponse response)32     public AccountManagerResponse(IAccountManagerResponse response) {
33         mResponse = response;
34     }
35 
36     /** @hide */
AccountManagerResponse(Parcel parcel)37     public AccountManagerResponse(Parcel parcel) {
38         mResponse =
39                 IAccountManagerResponse.Stub.asInterface(parcel.readStrongBinder());
40     }
41 
onResult(Bundle result)42     public void onResult(Bundle result) {
43         try {
44             mResponse.onResult(result);
45         } catch (RemoteException e) {
46             // this should never happen
47         }
48     }
49 
onError(int errorCode, String errorMessage)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 
58     /** @hide */
describeContents()59     public int describeContents() {
60         return 0;
61     }
62 
63     /** @hide */
writeToParcel(Parcel dest, int flags)64     public void writeToParcel(Parcel dest, int flags) {
65         dest.writeStrongBinder(mResponse.asBinder());
66     }
67 
68     /** @hide */
69     public static final Creator<AccountManagerResponse> CREATOR =
70             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     };
79 }
80