Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 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 | /** |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame^] | 25 | * Used by Account Authenticators to return a response. |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 26 | */ |
| 27 | public class AccountManagerResponse implements Parcelable { |
| 28 | private IAccountManagerResponse mResponse; |
| 29 | |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame^] | 30 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 31 | public AccountManagerResponse(IAccountManagerResponse response) { |
| 32 | mResponse = response; |
| 33 | } |
| 34 | |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame^] | 35 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 36 | 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 Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame^] | 57 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 58 | public int describeContents() { |
| 59 | return 0; |
| 60 | } |
| 61 | |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame^] | 62 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 63 | public void writeToParcel(Parcel dest, int flags) { |
| 64 | dest.writeStrongBinder(mResponse.asBinder()); |
| 65 | } |
| 66 | |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame^] | 67 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 68 | 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 Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame^] | 78 | } |