
package com.battlelancer.seriesguide.sync;

import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.accounts.NetworkErrorException;
import android.content.Context;
import android.os.Bundle;

public class SgAccountAuthenticator extends AbstractAccountAuthenticator {

    private Context mContext;

    public SgAccountAuthenticator(Context context) {
        super(context);
        mContext = context;
    }

    @Override
    public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
            String authTokenType, String[] requiredFeatures, Bundle options)
            throws NetworkErrorException {

        SyncUtils.createSyncAccount(mContext);

        final Account account = SyncUtils.getSyncAccount(mContext);
        Bundle bundle = new Bundle();
        bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
        bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
        return bundle;
    }

    @Override
    public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account,
            Bundle options) throws NetworkErrorException {
        return null;
    }

    @Override
    public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
        throw new UnsupportedOperationException();
    }

    @Override
    public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account,
            String authTokenType, Bundle options) throws NetworkErrorException {
        return null;
    }

    @Override
    public String getAuthTokenLabel(String authTokenType) {
        return null;
    }

    @Override
    public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account,
            String authTokenType, Bundle options) throws NetworkErrorException {
        return null;
    }

    @Override
    public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account,
            String[] features) throws NetworkErrorException {
        // This call is used to query whether the Authenticator supports
        // specific features. We don't expect to get called, so we always
        // return false (no) for any queries.
        final Bundle result = new Bundle();
        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false);
        return result;
    }

    @Override
    public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response, Account account)
            throws NetworkErrorException {
        final Bundle result = new Bundle();
        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
        return result;
    }

}

@@ -766,25 +766,24 @@
 ption %7B%0A
-%0A
         
 SyncUtil
@@ -778,321 +778,19 @@
     
-SyncUtils.createSyncAccount(mContext);%0A%0A        final Account account = SyncUtils.getSyncAccount(mContext);%0A        Bundle bundle = new Bundle();%0A        bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);%0A        bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);%0A        return bundle
+return null
 ;%0A  
@@ -1340,35 +1340,65 @@
 n %7B%0A        
-return null
+throw new UnsupportedOperationException()
 ;%0A    %7D%0A%0A   
@@ -1472,35 +1472,65 @@
 ) %7B%0A        
-return null
+throw new UnsupportedOperationException()
 ;%0A    %7D%0A%0A   
@@ -1717,35 +1717,65 @@
 n %7B%0A        
-return null
+throw new UnsupportedOperationException()
 ;%0A    %7D%0A%0A   
@@ -1945,327 +1945,49 @@
     
-// This call is used to query whether the Authenticator supports%0A        // specific features. We don't expect to get called, so we always%0A        // return false (no) for any queries.%0A        final Bundle result = new Bundle();%0A        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false);%0A        return result
+throw new UnsupportedOperationException()
 ;%0A  

Disable adding account from Android settings.