Fred Quintana | 6030734 | 2009-03-24 22:48:12 -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 | |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 19 | import android.os.Bundle; |
| 20 | import android.os.Parcelable; |
| 21 | import android.os.Parcel; |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 22 | import 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 Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 28 | public class AccountAuthenticatorResponse implements Parcelable { |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 29 | private IAccountAuthenticatorResponse mAccountAuthenticatorResponse; |
| 30 | |
| 31 | public AccountAuthenticatorResponse(IAccountAuthenticatorResponse response) { |
| 32 | mAccountAuthenticatorResponse = response; |
| 33 | } |
| 34 | |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 35 | public AccountAuthenticatorResponse(Parcel parcel) { |
| 36 | mAccountAuthenticatorResponse = |
| 37 | IAccountAuthenticatorResponse.Stub.asInterface(parcel.readStrongBinder()); |
| 38 | } |
| 39 | |
| 40 | public void onResult(Bundle result) { |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 41 | try { |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 42 | mAccountAuthenticatorResponse.onResult(result); |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 43 | } catch (RemoteException e) { |
| 44 | // this should never happen |
| 45 | } |
| 46 | } |
| 47 | |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 48 | public void onRequestContinued() { |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 49 | try { |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 50 | mAccountAuthenticatorResponse.onRequestContinued(); |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 51 | } 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 Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 64 | public int describeContents() { |
| 65 | return 0; |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 66 | } |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 67 | |
| 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 Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 82 | } |