File tree Expand file tree Collapse file tree
nfc-extras/java/com/android/nfc_extras Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ public final class NfcAdapterExtras {
6767
6868 /** get service handles */
6969 private static void initService () {
70- sService = sAdapter .getNfcAdapterExtrasInterface ();
70+ final INfcAdapterExtras service = sAdapter .getNfcAdapterExtrasInterface ();
71+ if (service != null ) {
72+ // Leave stale rather than receive a null value.
73+ sService = service ;
74+ }
7175 }
7276
7377 /**
@@ -84,18 +88,19 @@ public static NfcAdapterExtras get(NfcAdapter adapter) {
8488 if (sSingleton == null ) {
8589 try {
8690 sAdapter = adapter ;
87- sRouteOff = new CardEmulationRoute (CardEmulationRoute .ROUTE_OFF , null );
8891 sSingleton = new NfcAdapterExtras ();
8992 sEmbeddedEe = new NfcExecutionEnvironment (sSingleton );
93+ sRouteOff = new CardEmulationRoute (CardEmulationRoute .ROUTE_OFF , null );
9094 sRouteOnWhenScreenOn = new CardEmulationRoute (
9195 CardEmulationRoute .ROUTE_ON_WHEN_SCREEN_ON , sEmbeddedEe );
9296 initService ();
9397 } finally {
94- if (sSingleton == null ) {
95- sService = null ;
96- sEmbeddedEe = null ;
97- sRouteOff = null ;
98+ if (sService == null ) {
9899 sRouteOnWhenScreenOn = null ;
100+ sRouteOff = null ;
101+ sEmbeddedEe = null ;
102+ sSingleton = null ;
103+ sAdapter = null ;
99104 }
100105 }
101106 }
You can’t perform that action at this time.
0 commit comments