michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.fxa.authenticator; michael@0: michael@0: import org.mozilla.gecko.background.common.log.Logger; michael@0: michael@0: import android.app.Service; michael@0: import android.content.Intent; michael@0: import android.os.IBinder; michael@0: michael@0: public class FxAccountAuthenticatorService extends Service { michael@0: public static final String LOG_TAG = FxAccountAuthenticatorService.class.getSimpleName(); michael@0: michael@0: // Lazily initialized by getAuthenticator. michael@0: protected FxAccountAuthenticator accountAuthenticator = null; michael@0: michael@0: protected FxAccountAuthenticator getAuthenticator() { michael@0: if (accountAuthenticator == null) { michael@0: accountAuthenticator = new FxAccountAuthenticator(this); michael@0: } michael@0: michael@0: return accountAuthenticator; michael@0: } michael@0: michael@0: @Override michael@0: public void onCreate() { michael@0: Logger.debug(LOG_TAG, "onCreate"); michael@0: michael@0: accountAuthenticator = getAuthenticator(); michael@0: } michael@0: michael@0: @Override michael@0: public IBinder onBind(Intent intent) { michael@0: Logger.debug(LOG_TAG, "onBind"); michael@0: michael@0: if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) { michael@0: return getAuthenticator().getIBinder(); michael@0: } michael@0: michael@0: return null; michael@0: } michael@0: }