| Nancy Chen | 7c07dfa | 2015-02-12 09:44:41 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.telecom; |
| 18 | import android.accounts.AbstractAccountAuthenticator; |
| 19 | import android.accounts.Account; |
| 20 | import android.accounts.AccountAuthenticatorResponse; |
| 21 | import android.accounts.NetworkErrorException; |
| Nancy Chen | 1df9429 | 2015-04-07 12:21:36 -0700 | [diff] [blame^] | 22 | import android.annotation.SystemApi; |
| Nancy Chen | 7c07dfa | 2015-02-12 09:44:41 -0800 | [diff] [blame] | 23 | import android.app.Service; |
| 24 | import android.content.Context; |
| 25 | import android.content.Intent; |
| 26 | import android.os.Bundle; |
| 27 | import 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 Chen | 1df9429 | 2015-04-07 12:21:36 -0700 | [diff] [blame^] | 32 | * |
| 33 | * @hide |
| Nancy Chen | 7c07dfa | 2015-02-12 09:44:41 -0800 | [diff] [blame] | 34 | */ |
| Nancy Chen | 1df9429 | 2015-04-07 12:21:36 -0700 | [diff] [blame^] | 35 | @SystemApi |
| Nancy Chen | 7c07dfa | 2015-02-12 09:44:41 -0800 | [diff] [blame] | 36 | public 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 | } |