AccountAuthenticatorResponse.java revision f7ae77cd67f1a3993b8e56c1af4720a7adf4e69d
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 17package android.accounts; 18 19import android.os.Bundle; 20import android.os.Parcelable; 21import android.os.Parcel; 22import android.os.RemoteException; 23 24/** 25 * Object that wraps calls to an {@link IAccountAuthenticatorResponse} object. 26 * TODO: this interface is still in flux 27 */ 28public class AccountAuthenticatorResponse implements Parcelable { 29 private IAccountAuthenticatorResponse mAccountAuthenticatorResponse; 30 31 /** 32 * @hide 33 */ 34 /* package private */ AccountAuthenticatorResponse(IAccountAuthenticatorResponse response) { 35 mAccountAuthenticatorResponse = response; 36 } 37 38 public AccountAuthenticatorResponse(Parcel parcel) { 39 mAccountAuthenticatorResponse = 40 IAccountAuthenticatorResponse.Stub.asInterface(parcel.readStrongBinder()); 41 } 42 43 public void onResult(Bundle result) { 44 try { 45 mAccountAuthenticatorResponse.onResult(result); 46 } catch (RemoteException e) { 47 // this should never happen 48 } 49 } 50 51 public void onRequestContinued() { 52 try { 53 mAccountAuthenticatorResponse.onRequestContinued(); 54 } catch (RemoteException e) { 55 // this should never happen 56 } 57 } 58 59 public void onError(int errorCode, String errorMessage) { 60 try { 61 mAccountAuthenticatorResponse.onError(errorCode, errorMessage); 62 } catch (RemoteException e) { 63 // this should never happen 64 } 65 } 66 67 public int describeContents() { 68 return 0; 69 } 70 71 public void writeToParcel(Parcel dest, int flags) { 72 dest.writeStrongBinder(mAccountAuthenticatorResponse.asBinder()); 73 } 74 75 public static final Creator<AccountAuthenticatorResponse> CREATOR = 76 new Creator<AccountAuthenticatorResponse>() { 77 public AccountAuthenticatorResponse createFromParcel(Parcel source) { 78 return new AccountAuthenticatorResponse(source); 79 } 80 81 public AccountAuthenticatorResponse[] newArray(int size) { 82 return new AccountAuthenticatorResponse[size]; 83 } 84 }; 85} 86