Loading core/java/android/nfc/NfcAdapter.java +19 −11 Original line number Original line Diff line number Diff line Loading @@ -600,6 +600,17 @@ public final class NfcAdapter { return offHostSE; return offHostSE; } } private static void retrieveServiceRegisterer() { if (sServiceRegisterer == null) { NfcServiceManager manager = NfcFrameworkInitializer.getNfcServiceManager(); if (manager == null) { Log.e(TAG, "NfcServiceManager is null"); throw new UnsupportedOperationException(); } sServiceRegisterer = manager.getNfcManagerServiceRegisterer(); } } /** /** * Returns the NfcAdapter for application context, * Returns the NfcAdapter for application context, * or throws if NFC is not available. * or throws if NFC is not available. Loading Loading @@ -627,12 +638,7 @@ public final class NfcAdapter { Log.v(TAG, "this device does not have NFC support"); Log.v(TAG, "this device does not have NFC support"); throw new UnsupportedOperationException(); throw new UnsupportedOperationException(); } } NfcServiceManager manager = NfcFrameworkInitializer.getNfcServiceManager(); retrieveServiceRegisterer(); if (manager == null) { Log.e(TAG, "NfcServiceManager is null"); throw new UnsupportedOperationException(); } sServiceRegisterer = manager.getNfcManagerServiceRegisterer(); sService = getServiceInterface(); sService = getServiceInterface(); if (sService == null) { if (sService == null) { Log.e(TAG, "could not retrieve NFC service"); Log.e(TAG, "could not retrieve NFC service"); Loading Loading @@ -706,12 +712,14 @@ public final class NfcAdapter { throw new IllegalArgumentException( throw new IllegalArgumentException( "context not associated with any application (using a mock context?)"); "context not associated with any application (using a mock context?)"); } } retrieveServiceRegisterer(); if (sIsInitialized && sServiceRegisterer.tryGet() == null) { if (sServiceRegisterer.tryGet() == null) { if (sIsInitialized) { synchronized (NfcAdapter.class) { synchronized (NfcAdapter.class) { /* Stale sService pointer */ /* Stale sService pointer */ if (sIsInitialized) sIsInitialized = false; if (sIsInitialized) sIsInitialized = false; } } } return null; return null; } } /* Try to initialize the service */ /* Try to initialize the service */ Loading Loading
core/java/android/nfc/NfcAdapter.java +19 −11 Original line number Original line Diff line number Diff line Loading @@ -600,6 +600,17 @@ public final class NfcAdapter { return offHostSE; return offHostSE; } } private static void retrieveServiceRegisterer() { if (sServiceRegisterer == null) { NfcServiceManager manager = NfcFrameworkInitializer.getNfcServiceManager(); if (manager == null) { Log.e(TAG, "NfcServiceManager is null"); throw new UnsupportedOperationException(); } sServiceRegisterer = manager.getNfcManagerServiceRegisterer(); } } /** /** * Returns the NfcAdapter for application context, * Returns the NfcAdapter for application context, * or throws if NFC is not available. * or throws if NFC is not available. Loading Loading @@ -627,12 +638,7 @@ public final class NfcAdapter { Log.v(TAG, "this device does not have NFC support"); Log.v(TAG, "this device does not have NFC support"); throw new UnsupportedOperationException(); throw new UnsupportedOperationException(); } } NfcServiceManager manager = NfcFrameworkInitializer.getNfcServiceManager(); retrieveServiceRegisterer(); if (manager == null) { Log.e(TAG, "NfcServiceManager is null"); throw new UnsupportedOperationException(); } sServiceRegisterer = manager.getNfcManagerServiceRegisterer(); sService = getServiceInterface(); sService = getServiceInterface(); if (sService == null) { if (sService == null) { Log.e(TAG, "could not retrieve NFC service"); Log.e(TAG, "could not retrieve NFC service"); Loading Loading @@ -706,12 +712,14 @@ public final class NfcAdapter { throw new IllegalArgumentException( throw new IllegalArgumentException( "context not associated with any application (using a mock context?)"); "context not associated with any application (using a mock context?)"); } } retrieveServiceRegisterer(); if (sIsInitialized && sServiceRegisterer.tryGet() == null) { if (sServiceRegisterer.tryGet() == null) { if (sIsInitialized) { synchronized (NfcAdapter.class) { synchronized (NfcAdapter.class) { /* Stale sService pointer */ /* Stale sService pointer */ if (sIsInitialized) sIsInitialized = false; if (sIsInitialized) sIsInitialized = false; } } } return null; return null; } } /* Try to initialize the service */ /* Try to initialize the service */ Loading