1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/base/fxa/authenticator/FxAccountAuthenticatorService.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +package org.mozilla.gecko.fxa.authenticator; 1.9 + 1.10 +import org.mozilla.gecko.background.common.log.Logger; 1.11 + 1.12 +import android.app.Service; 1.13 +import android.content.Intent; 1.14 +import android.os.IBinder; 1.15 + 1.16 +public class FxAccountAuthenticatorService extends Service { 1.17 + public static final String LOG_TAG = FxAccountAuthenticatorService.class.getSimpleName(); 1.18 + 1.19 + // Lazily initialized by <code>getAuthenticator</code>. 1.20 + protected FxAccountAuthenticator accountAuthenticator = null; 1.21 + 1.22 + protected FxAccountAuthenticator getAuthenticator() { 1.23 + if (accountAuthenticator == null) { 1.24 + accountAuthenticator = new FxAccountAuthenticator(this); 1.25 + } 1.26 + 1.27 + return accountAuthenticator; 1.28 + } 1.29 + 1.30 + @Override 1.31 + public void onCreate() { 1.32 + Logger.debug(LOG_TAG, "onCreate"); 1.33 + 1.34 + accountAuthenticator = getAuthenticator(); 1.35 + } 1.36 + 1.37 + @Override 1.38 + public IBinder onBind(Intent intent) { 1.39 + Logger.debug(LOG_TAG, "onBind"); 1.40 + 1.41 + if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) { 1.42 + return getAuthenticator().getIBinder(); 1.43 + } 1.44 + 1.45 + return null; 1.46 + } 1.47 +}