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 | |
Artur Satayev | d9b11b0 | 2019-12-10 17:47:51 +0000 | [diff] [blame] | 19 | import android.compat.annotation.UnsupportedAppUsage; |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 20 | import android.os.Bundle; |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 21 | import android.os.Parcel; |
Artur Satayev | d9b11b0 | 2019-12-10 17:47:51 +0000 | [diff] [blame] | 22 | import android.os.Parcelable; |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 23 | import android.os.RemoteException; |
Fred Quintana | f0fd843 | 2010-03-08 12:48:05 -0800 | [diff] [blame] | 24 | import android.util.Log; |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
Fred Quintana | 89c40f5 | 2009-10-05 14:21:53 -0700 | [diff] [blame] | 27 | * Object used to communicate responses back to the AccountManager |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 28 | */ |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 29 | public class AccountAuthenticatorResponse implements Parcelable { |
Fred Quintana | f0fd843 | 2010-03-08 12:48:05 -0800 | [diff] [blame] | 30 | private static final String TAG = "AccountAuthenticator"; |
| 31 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 32 | private IAccountAuthenticatorResponse mAccountAuthenticatorResponse; |
| 33 | |
Fred Quintana | f7ae77c | 2009-10-02 17:19:31 -0700 | [diff] [blame] | 34 | /** |
| 35 | * @hide |
| 36 | */ |
Mathew Inwood | 1fde99a | 2018-08-06 16:43:30 +0100 | [diff] [blame] | 37 | @UnsupportedAppUsage |
Jeff Sharkey | 7a96c39 | 2012-11-15 14:01:46 -0800 | [diff] [blame] | 38 | public AccountAuthenticatorResponse(IAccountAuthenticatorResponse response) { |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 39 | mAccountAuthenticatorResponse = response; |
| 40 | } |
| 41 | |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 42 | public AccountAuthenticatorResponse(Parcel parcel) { |
| 43 | mAccountAuthenticatorResponse = |
| 44 | IAccountAuthenticatorResponse.Stub.asInterface(parcel.readStrongBinder()); |
| 45 | } |
| 46 | |
| 47 | public void onResult(Bundle result) { |
Fred Quintana | f0fd843 | 2010-03-08 12:48:05 -0800 | [diff] [blame] | 48 | if (Log.isLoggable(TAG, Log.VERBOSE)) { |
| 49 | result.keySet(); // force it to be unparcelled |
| 50 | Log.v(TAG, "AccountAuthenticatorResponse.onResult: " |
| 51 | + AccountManager.sanitizeResult(result)); |
| 52 | } |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 53 | try { |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 54 | mAccountAuthenticatorResponse.onResult(result); |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 55 | } catch (RemoteException e) { |
| 56 | // this should never happen |
| 57 | } |
| 58 | } |
| 59 | |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 60 | public void onRequestContinued() { |
Fred Quintana | f0fd843 | 2010-03-08 12:48:05 -0800 | [diff] [blame] | 61 | if (Log.isLoggable(TAG, Log.VERBOSE)) { |
| 62 | Log.v(TAG, "AccountAuthenticatorResponse.onRequestContinued"); |
| 63 | } |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 64 | try { |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 65 | mAccountAuthenticatorResponse.onRequestContinued(); |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 66 | } catch (RemoteException e) { |
| 67 | // this should never happen |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | public void onError(int errorCode, String errorMessage) { |
Fred Quintana | f0fd843 | 2010-03-08 12:48:05 -0800 | [diff] [blame] | 72 | if (Log.isLoggable(TAG, Log.VERBOSE)) { |
| 73 | Log.v(TAG, "AccountAuthenticatorResponse.onError: " + errorCode + ", " + errorMessage); |
| 74 | } |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 75 | try { |
| 76 | mAccountAuthenticatorResponse.onError(errorCode, errorMessage); |
| 77 | } catch (RemoteException e) { |
| 78 | // this should never happen |
| 79 | } |
| 80 | } |
| 81 | |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 82 | public int describeContents() { |
| 83 | return 0; |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 84 | } |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 85 | |
| 86 | public void writeToParcel(Parcel dest, int flags) { |
| 87 | dest.writeStrongBinder(mAccountAuthenticatorResponse.asBinder()); |
| 88 | } |
| 89 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 90 | public static final @android.annotation.NonNull Creator<AccountAuthenticatorResponse> CREATOR = |
Fred Quintana | a698f42 | 2009-04-08 19:14:54 -0700 | [diff] [blame] | 91 | new Creator<AccountAuthenticatorResponse>() { |
| 92 | public AccountAuthenticatorResponse createFromParcel(Parcel source) { |
| 93 | return new AccountAuthenticatorResponse(source); |
| 94 | } |
| 95 | |
| 96 | public AccountAuthenticatorResponse[] newArray(int size) { |
| 97 | return new AccountAuthenticatorResponse[size]; |
| 98 | } |
| 99 | }; |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 100 | } |