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 | 5994cd2 | 2009-11-18 17:00:10 -0800 | [diff] [blame] | 25 | * Used to return a response to the AccountManager. |
| 26 | * @hide |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 27 | */ |
| 28 | public class AccountManagerResponse implements Parcelable { |
| 29 | private IAccountManagerResponse mResponse; |
| 30 | |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame] | 31 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 32 | public AccountManagerResponse(IAccountManagerResponse response) { |
| 33 | mResponse = response; |
| 34 | } |
| 35 | |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame] | 36 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 37 | 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 Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame] | 58 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 59 | public int describeContents() { |
| 60 | return 0; |
| 61 | } |
| 62 | |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame] | 63 | /** @hide */ |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 64 | public void writeToParcel(Parcel dest, int flags) { |
| 65 | dest.writeStrongBinder(mResponse.asBinder()); |
| 66 | } |
| 67 | |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame] | 68 | /** @hide */ |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 69 | public static final @android.annotation.NonNull Creator<AccountManagerResponse> CREATOR = |
Fred Quintana | 3326920 | 2009-04-20 16:05:10 -0700 | [diff] [blame] | 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 | }; |
Fred Quintana | 9efe265 | 2009-10-28 22:53:51 -0700 | [diff] [blame] | 79 | } |