blob: bcc9f90c35f1800c72d968f1cd4f63041107c8b3 [file] [log] [blame]
Fred Quintana60307342009-03-24 22:48:12 -07001/*
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
Mathew Inwoodad576cc2018-08-06 16:51:18 +010019import android.annotation.UnsupportedAppUsage;
Fred Quintanaa698f422009-04-08 19:14:54 -070020import android.os.Bundle;
21import android.os.Parcelable;
22import android.os.Parcel;
Fred Quintana60307342009-03-24 22:48:12 -070023import android.os.RemoteException;
Fred Quintanaf0fd8432010-03-08 12:48:05 -080024import android.util.Log;
Fred Quintana60307342009-03-24 22:48:12 -070025
26/**
Fred Quintana89c40f52009-10-05 14:21:53 -070027 * Object used to communicate responses back to the AccountManager
Fred Quintana60307342009-03-24 22:48:12 -070028 */
Fred Quintanaa698f422009-04-08 19:14:54 -070029public class AccountAuthenticatorResponse implements Parcelable {
Fred Quintanaf0fd8432010-03-08 12:48:05 -080030 private static final String TAG = "AccountAuthenticator";
31
Fred Quintana60307342009-03-24 22:48:12 -070032 private IAccountAuthenticatorResponse mAccountAuthenticatorResponse;
33
Fred Quintanaf7ae77c2009-10-02 17:19:31 -070034 /**
35 * @hide
36 */
Mathew Inwoodad576cc2018-08-06 16:51:18 +010037 @UnsupportedAppUsage
Jeff Sharkey7a96c392012-11-15 14:01:46 -080038 public AccountAuthenticatorResponse(IAccountAuthenticatorResponse response) {
Fred Quintana60307342009-03-24 22:48:12 -070039 mAccountAuthenticatorResponse = response;
40 }
41
Fred Quintanaa698f422009-04-08 19:14:54 -070042 public AccountAuthenticatorResponse(Parcel parcel) {
43 mAccountAuthenticatorResponse =
44 IAccountAuthenticatorResponse.Stub.asInterface(parcel.readStrongBinder());
45 }
46
47 public void onResult(Bundle result) {
Fred Quintanaf0fd8432010-03-08 12:48:05 -080048 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 Quintana60307342009-03-24 22:48:12 -070053 try {
Fred Quintanaa698f422009-04-08 19:14:54 -070054 mAccountAuthenticatorResponse.onResult(result);
Fred Quintana60307342009-03-24 22:48:12 -070055 } catch (RemoteException e) {
56 // this should never happen
57 }
58 }
59
Fred Quintanaa698f422009-04-08 19:14:54 -070060 public void onRequestContinued() {
Fred Quintanaf0fd8432010-03-08 12:48:05 -080061 if (Log.isLoggable(TAG, Log.VERBOSE)) {
62 Log.v(TAG, "AccountAuthenticatorResponse.onRequestContinued");
63 }
Fred Quintana60307342009-03-24 22:48:12 -070064 try {
Fred Quintanaa698f422009-04-08 19:14:54 -070065 mAccountAuthenticatorResponse.onRequestContinued();
Fred Quintana60307342009-03-24 22:48:12 -070066 } catch (RemoteException e) {
67 // this should never happen
68 }
69 }
70
71 public void onError(int errorCode, String errorMessage) {
Fred Quintanaf0fd8432010-03-08 12:48:05 -080072 if (Log.isLoggable(TAG, Log.VERBOSE)) {
73 Log.v(TAG, "AccountAuthenticatorResponse.onError: " + errorCode + ", " + errorMessage);
74 }
Fred Quintana60307342009-03-24 22:48:12 -070075 try {
76 mAccountAuthenticatorResponse.onError(errorCode, errorMessage);
77 } catch (RemoteException e) {
78 // this should never happen
79 }
80 }
81
Fred Quintanaa698f422009-04-08 19:14:54 -070082 public int describeContents() {
83 return 0;
Fred Quintana60307342009-03-24 22:48:12 -070084 }
Fred Quintanaa698f422009-04-08 19:14:54 -070085
86 public void writeToParcel(Parcel dest, int flags) {
87 dest.writeStrongBinder(mAccountAuthenticatorResponse.asBinder());
88 }
89
90 public static final Creator<AccountAuthenticatorResponse> CREATOR =
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 Quintana60307342009-03-24 22:48:12 -0700100}