File tree 1 file changed +11
-6
lines changed
nfc-extras/java/com/android/nfc_extras
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ public final class NfcAdapterExtras {
67
67
68
68
/** get service handles */
69
69
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
+ }
71
75
}
72
76
73
77
/**
@@ -84,18 +88,19 @@ public static NfcAdapterExtras get(NfcAdapter adapter) {
84
88
if (sSingleton == null ) {
85
89
try {
86
90
sAdapter = adapter ;
87
- sRouteOff = new CardEmulationRoute (CardEmulationRoute .ROUTE_OFF , null );
88
91
sSingleton = new NfcAdapterExtras ();
89
92
sEmbeddedEe = new NfcExecutionEnvironment (sSingleton );
93
+ sRouteOff = new CardEmulationRoute (CardEmulationRoute .ROUTE_OFF , null );
90
94
sRouteOnWhenScreenOn = new CardEmulationRoute (
91
95
CardEmulationRoute .ROUTE_ON_WHEN_SCREEN_ON , sEmbeddedEe );
92
96
initService ();
93
97
} finally {
94
- if (sSingleton == null ) {
95
- sService = null ;
96
- sEmbeddedEe = null ;
97
- sRouteOff = null ;
98
+ if (sService == null ) {
98
99
sRouteOnWhenScreenOn = null ;
100
+ sRouteOff = null ;
101
+ sEmbeddedEe = null ;
102
+ sSingleton = null ;
103
+ sAdapter = null ;
99
104
}
100
105
}
101
106
}
You can’t perform that action at this time.
0 commit comments