1 /* 2 * Copyright (C) 2016 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 package com.android.bluetooth.pbapclient; 17 18 import android.accounts.AbstractAccountAuthenticator; 19 import android.accounts.Account; 20 import android.accounts.AccountAuthenticatorResponse; 21 import android.accounts.AccountManager; 22 import android.accounts.NetworkErrorException; 23 import android.content.Context; 24 import android.os.Bundle; 25 import android.util.Log; 26 27 public class Authenticator extends AbstractAccountAuthenticator { 28 private static final String TAG = "PbapAuthenticator"; 29 30 public Authenticator(Context context) { 31 super(context); 32 } 33 34 // Editing properties is not supported 35 @Override 36 public Bundle editProperties(AccountAuthenticatorResponse r, String s) { 37 Log.d(TAG, "got call", new Exception()); 38 throw new UnsupportedOperationException(); 39 } 40 41 // Don't add additional accounts 42 @Override 43 public Bundle addAccount(AccountAuthenticatorResponse r, String s, String s2, String[] strings, 44 Bundle bundle) throws NetworkErrorException { 45 Log.d(TAG, "got call", new Exception()); 46 // Don't allow accounts to be added. 47 throw new UnsupportedOperationException(); 48 } 49 50 // Ignore attempts to confirm credentials 51 @Override 52 public Bundle confirmCredentials(AccountAuthenticatorResponse r, Account account, 53 Bundle bundle) throws NetworkErrorException { 54 Log.d(TAG, "got call", new Exception()); 55 return null; 56 } 57 58 // Getting an authentication token is not supported 59 @Override 60 public Bundle getAuthToken(AccountAuthenticatorResponse r, Account account, String s, 61 Bundle bundle) throws NetworkErrorException { 62 Log.d(TAG, "got call", new Exception()); 63 throw new UnsupportedOperationException(); 64 } 65 66 // Getting a label for the auth token is not supported 67 @Override 68 public String getAuthTokenLabel(String s) { 69 Log.d(TAG, "got call", new Exception()); 70 return null; 71 } 72 73 // Updating user credentials is not supported 74 @Override 75 public Bundle updateCredentials(AccountAuthenticatorResponse r, Account account, String s, 76 Bundle bundle) throws NetworkErrorException { 77 Log.d(TAG, "got call", new Exception()); 78 return null; 79 } 80 81 // Checking features for the account is not supported 82 @Override 83 public Bundle hasFeatures(AccountAuthenticatorResponse r, Account account, String[] strings) 84 throws NetworkErrorException { 85 Log.d(TAG, "got call", new Exception()); 86 87 final Bundle result = new Bundle(); 88 result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false); 89 return result; 90 } 91 } 92