1 /* 2 * Copyright 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 com.example.android.sampletvinput.syncadapter; 18 19 import android.accounts.AbstractAccountAuthenticator; 20 import android.accounts.Account; 21 import android.accounts.AccountAuthenticatorResponse; 22 import android.accounts.NetworkErrorException; 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 /** 31 * Dummy account service for SyncAdapter. Note that this does nothing because this input uses a feed 32 * which does not require any authentication. 33 */ 34 public class DummyAccountService extends Service { 35 private static final String TAG = "DummyAccountService"; 36 private DummyAuthenticator mAuthenticator; 37 public static final String ACCOUNT_NAME = "DummyAccount"; 38 39 public static Account getAccount(String accountType) { 40 return new Account(ACCOUNT_NAME, accountType); 41 } 42 43 @Override 44 public void onCreate() { 45 mAuthenticator = new DummyAuthenticator(this); 46 } 47 48 @Override 49 public IBinder onBind(Intent intent) { 50 return mAuthenticator.getIBinder(); 51 } 52 53 /** 54 * Dummy Authenticator used in {@link SyncAdapter}. This does nothing for all the operations 55 * since channel/program feed does not require any authentication. 56 */ 57 public class DummyAuthenticator extends AbstractAccountAuthenticator { 58 public DummyAuthenticator(Context context) { 59 super(context); 60 } 61 62 @Override 63 public Bundle editProperties(AccountAuthenticatorResponse accountAuthenticatorResponse, 64 String s) { 65 throw new UnsupportedOperationException(); 66 } 67 68 @Override 69 public Bundle addAccount(AccountAuthenticatorResponse accountAuthenticatorResponse, 70 String s, String s2, String[] strings, Bundle bundle) throws NetworkErrorException { 71 return null; 72 } 73 74 @Override 75 public Bundle confirmCredentials(AccountAuthenticatorResponse accountAuthenticatorResponse, 76 Account account, Bundle bundle) throws NetworkErrorException { 77 return null; 78 } 79 80 @Override 81 public Bundle getAuthToken(AccountAuthenticatorResponse accountAuthenticatorResponse, 82 Account account, String s, Bundle bundle) throws NetworkErrorException { 83 throw new UnsupportedOperationException(); 84 } 85 86 @Override 87 public String getAuthTokenLabel(String s) { 88 throw new UnsupportedOperationException(); 89 } 90 91 @Override 92 public Bundle updateCredentials(AccountAuthenticatorResponse accountAuthenticatorResponse, 93 Account account, String s, Bundle bundle) throws NetworkErrorException { 94 throw new UnsupportedOperationException(); 95 } 96 97 @Override 98 public Bundle hasFeatures(AccountAuthenticatorResponse accountAuthenticatorResponse, 99 Account account, String[] strings) throws NetworkErrorException { 100 throw new UnsupportedOperationException(); 101 } 102 } 103 104 } 105 106