summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2015-09-06 03:23:35 +0200
committerSteve Kondik <steve@cyngn.com>2015-10-28 13:30:31 -0700
commit1882a02f21f9e79550000e2b68a37acf21f26ec2 (patch)
tree30b27b06361a0bdd1ad88174b6263d8293964e54 /services/java
parentf826b24a8bcac56a578f98af260a71628139ef38 (diff)
downloadframeworks_base-1882a02f21f9e79550000e2b68a37acf21f26ec2.zip
frameworks_base-1882a02f21f9e79550000e2b68a37acf21f26ec2.tar.gz
frameworks_base-1882a02f21f9e79550000e2b68a37acf21f26ec2.tar.bz2
base: start nfc service prior to systemui
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. Depends on: http://review.cyanogenmod.org/#/c/108684/ Additional info: http://review.cyanogenmod.org/#/c/108411 TICKET: CYNGNOS-848 Change-Id: Iea84c672762a62946e5708396d8d3b56166eaee8 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/SystemServer.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 48deb68..2e4884e 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -1204,6 +1204,15 @@ public final class SystemServer {
Slog.i(TAG, "WebViewFactory preparation");
WebViewFactory.prepareWebViewInSystemServer();
+ // Start Nfc before SystemUi to ensure NfcTile and other apps gets a
+ // valid NfcAdapter from NfcManager
+ try {
+ startNfcService(context);
+ } catch (Throwable e) {
+ // Don't crash. Nfc is an optional service. Just annotate that isn't ready
+ Slog.e(TAG, "Nfc service didn't start. Nfc will not be available.", e);
+ }
+
try {
startSystemUi(context);
} catch (Throwable e) {
@@ -1333,4 +1342,23 @@ public final class SystemServer {
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.OWNER);
}
+
+ static final void startNfcService(Context context) {
+ IPackageManager pm = ActivityThread.getPackageManager();
+ if (pm == null) {
+ Slog.w(TAG, "Cannot get package manager, assuming no NFC feature");
+ return;
+ }
+ try {
+ if (pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName("com.android.nfc",
+ "com.android.nfc.NfcBootstrapService"));
+ context.startServiceAsUser(intent, UserHandle.OWNER);
+ }
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Package manager query failed, assuming no NFC feature", e);
+ return;
+ }
+ }
}