diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2015-09-06 02:51:33 +0200 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 14:31:00 -0800 |
commit | 7bc697ba42a368c01c46c4d546e069c1f2601fd6 (patch) | |
tree | 32d91398f857830072e407f556e051392bc91a69 | |
parent | 78365a7693b9ea30d241bbdd4bd890d9d8d98491 (diff) | |
download | android_packages_apps_Nfc-7bc697ba42a368c01c46c4d546e069c1f2601fd6.tar.gz android_packages_apps_Nfc-7bc697ba42a368c01c46c4d546e069c1f2601fd6.tar.bz2 android_packages_apps_Nfc-7bc697ba42a368c01c46c4d546e069c1f2601fd6.zip |
nfc: create a bootstrap service
Since registration of NfcService as a manager service happens in the first run of the Nfc app,
and since the SystemUi makes use of this manager service through the NfcTile, NfcManager
can lead into a null reference for the NfcAdapter because the NfcService isn't registered
when the SystemUi starts (this condition depends on the device speed to bring up the call
to the apps).
This change adds a noop service that allow to be called by SystemServer before start the
systemui and ensure that NfcService is available before apps start using NfcManager.
Additional info: http://review.cyanogenmod.org/#/c/108411
TICKET: CYNGNOS-848
Change-Id: I052ab0cfc8b62fbc3798ab3c0d0eccfad01419ff
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rwxr-xr-x | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | src/com/android/nfc/NfcBootstrapService.java | 39 |
2 files changed, 41 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index eea72fd4..cc415948 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -138,5 +138,7 @@ <service android:name=".handover.PeripheralHandoverService" /> + + <service android:name=".NfcBootstrapService" exported="true" /> </application> </manifest> diff --git a/src/com/android/nfc/NfcBootstrapService.java b/src/com/android/nfc/NfcBootstrapService.java new file mode 100644 index 00000000..1b2b7b1b --- /dev/null +++ b/src/com/android/nfc/NfcBootstrapService.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.nfc; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + +/** + * This is just a no-op service to allow Nfc app being started at boot time. + */ +public class NfcBootstrapService extends Service { + + @Override + public IBinder onBind(Intent intent) { + return null; + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + stopSelf(startId); + return Service.START_NOT_STICKY; + } + +} |