blob: 7aa105d57bbef9e8549b72db88cd89bb478d6191 [file] [log] [blame]
Nancy Chen7c07dfa2015-02-12 09:44:41 -08001/*
2 * Copyright (C) 2015 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.telecom;
18import android.accounts.AbstractAccountAuthenticator;
19import android.accounts.Account;
20import android.accounts.AccountAuthenticatorResponse;
21import android.accounts.NetworkErrorException;
Nancy Chen1df94292015-04-07 12:21:36 -070022import android.annotation.SystemApi;
Nancy Chen7c07dfa2015-02-12 09:44:41 -080023import android.app.Service;
24import android.content.Context;
25import android.content.Intent;
26import android.os.Bundle;
27import android.os.IBinder;
28
29/**
30 * A generic stub account authenticator service often used for sync adapters that do not directly
31 * involve accounts.
Nancy Chen1df94292015-04-07 12:21:36 -070032 *
33 * @hide
Nancy Chen7c07dfa2015-02-12 09:44:41 -080034 */
Nancy Chen1df94292015-04-07 12:21:36 -070035@SystemApi
Nancy Chen7c07dfa2015-02-12 09:44:41 -080036public class AuthenticatorService extends Service {
37 private static Authenticator mAuthenticator;
38
39 @Override
40 public void onCreate() {
41 mAuthenticator = new Authenticator(this);
42 }
43
44 @Override
45 public IBinder onBind(Intent intent) {
46 return mAuthenticator.getIBinder();
47 }
48
49 /**
50 * Stub account authenticator. All methods either return null or throw an exception.
51 */
52 public class Authenticator extends AbstractAccountAuthenticator {
53 public Authenticator(Context context) {
54 super(context);
55 }
56
57 @Override
58 public Bundle editProperties(AccountAuthenticatorResponse accountAuthenticatorResponse,
59 String s) {
60 throw new UnsupportedOperationException();
61 }
62
63 @Override
64 public Bundle addAccount(AccountAuthenticatorResponse accountAuthenticatorResponse,
65 String s, String s2, String[] strings, Bundle bundle)
66 throws NetworkErrorException {
67 return null;
68 }
69
70 @Override
71 public Bundle confirmCredentials(AccountAuthenticatorResponse accountAuthenticatorResponse,
72 Account account, Bundle bundle)
73 throws NetworkErrorException {
74 return null;
75 }
76
77 @Override
78 public Bundle getAuthToken(AccountAuthenticatorResponse accountAuthenticatorResponse,
79 Account account, String s, Bundle bundle)
80 throws NetworkErrorException {
81 throw new UnsupportedOperationException();
82 }
83
84 @Override
85 public String getAuthTokenLabel(String s) {
86 throw new UnsupportedOperationException();
87 }
88
89 @Override
90 public Bundle updateCredentials(AccountAuthenticatorResponse accountAuthenticatorResponse,
91 Account account, String s, Bundle bundle)
92 throws NetworkErrorException {
93 throw new UnsupportedOperationException();
94 }
95
96 @Override
97 public Bundle hasFeatures(AccountAuthenticatorResponse accountAuthenticatorResponse,
98 Account account, String[] strings)
99 throws NetworkErrorException {
100 throw new UnsupportedOperationException();
101 }
102 }
103}