Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | package org.mozilla.gecko.fxa.authenticator; |
michael@0 | 6 | |
michael@0 | 7 | import org.mozilla.gecko.background.common.log.Logger; |
michael@0 | 8 | |
michael@0 | 9 | import android.app.Service; |
michael@0 | 10 | import android.content.Intent; |
michael@0 | 11 | import android.os.IBinder; |
michael@0 | 12 | |
michael@0 | 13 | public class FxAccountAuthenticatorService extends Service { |
michael@0 | 14 | public static final String LOG_TAG = FxAccountAuthenticatorService.class.getSimpleName(); |
michael@0 | 15 | |
michael@0 | 16 | // Lazily initialized by <code>getAuthenticator</code>. |
michael@0 | 17 | protected FxAccountAuthenticator accountAuthenticator = null; |
michael@0 | 18 | |
michael@0 | 19 | protected FxAccountAuthenticator getAuthenticator() { |
michael@0 | 20 | if (accountAuthenticator == null) { |
michael@0 | 21 | accountAuthenticator = new FxAccountAuthenticator(this); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | return accountAuthenticator; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | @Override |
michael@0 | 28 | public void onCreate() { |
michael@0 | 29 | Logger.debug(LOG_TAG, "onCreate"); |
michael@0 | 30 | |
michael@0 | 31 | accountAuthenticator = getAuthenticator(); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | @Override |
michael@0 | 35 | public IBinder onBind(Intent intent) { |
michael@0 | 36 | Logger.debug(LOG_TAG, "onBind"); |
michael@0 | 37 | |
michael@0 | 38 | if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) { |
michael@0 | 39 | return getAuthenticator().getIBinder(); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | return null; |
michael@0 | 43 | } |
michael@0 | 44 | } |