1 /* ownCloud Jelly Bean Workaround for lost credentials
3 * Copyright (C) 2013 ownCloud Inc.
6 package com
.owncloud
.android
.workaround
.accounts
;
8 import android
.accounts
.AbstractAccountAuthenticator
;
9 import android
.accounts
.Account
;
10 import android
.accounts
.AccountAuthenticatorResponse
;
11 import android
.accounts
.AccountManager
;
12 import android
.accounts
.NetworkErrorException
;
13 import android
.app
.Service
;
14 import android
.content
.Context
;
15 import android
.content
.Intent
;
16 import android
.os
.Bundle
;
17 import android
.os
.IBinder
;
19 public class AccountAuthenticatorService
extends Service
{
21 private AccountAuthenticator mAuthenticator
;
22 static final public String ACCOUNT_TYPE
= "owncloud";
25 public void onCreate() {
27 mAuthenticator
= new AccountAuthenticator(this);
31 public IBinder
onBind(Intent intent
) {
32 return mAuthenticator
.getIBinder();
36 public static class AccountAuthenticator
extends AbstractAccountAuthenticator
{
38 public AccountAuthenticator(Context context
) {
43 public Bundle
addAccount(AccountAuthenticatorResponse response
,
44 String accountType
, String authTokenType
,
45 String
[] requiredFeatures
, Bundle options
)
46 throws NetworkErrorException
{
47 return getCommonResultBundle();
52 public Bundle
confirmCredentials(AccountAuthenticatorResponse response
,
53 Account account
, Bundle options
) throws NetworkErrorException
{
54 return getCommonResultBundle();
58 public Bundle
editProperties(AccountAuthenticatorResponse response
,
60 return getCommonResultBundle();
64 public Bundle
getAuthToken(AccountAuthenticatorResponse response
,
65 Account account
, String authTokenType
, Bundle options
)
66 throws NetworkErrorException
{
67 return getCommonResultBundle();
71 public String
getAuthTokenLabel(String authTokenType
) {
76 public Bundle
hasFeatures(AccountAuthenticatorResponse response
,
77 Account account
, String
[] features
) throws NetworkErrorException
{
78 return getCommonResultBundle();
82 public Bundle
updateCredentials(AccountAuthenticatorResponse response
,
83 Account account
, String authTokenType
, Bundle options
)
84 throws NetworkErrorException
{
85 return getCommonResultBundle();
89 public Bundle
getAccountRemovalAllowed(
90 AccountAuthenticatorResponse response
, Account account
)
91 throws NetworkErrorException
{
92 return getCommonResultBundle();
95 private Bundle
getCommonResultBundle() {
96 Bundle resultBundle
= new Bundle();
97 resultBundle
.putInt(AccountManager
.KEY_ERROR_CODE
, AccountManager
.ERROR_CODE_UNSUPPORTED_OPERATION
);
98 resultBundle
.putString(AccountManager
.KEY_ERROR_MESSAGE
, "This is just a workaround, not a real account authenticator");