am 01588aca: Merge "Preserve invariant that sService is not null (although NfcAdapter.get() can return null)" into gingerbread
* commit '01588acaf87cfe9916239b7b26cc6810e0097138': Preserve invariant that sService is not null (although NfcAdapter.get() can return null)
This commit is contained in:
@@ -67,7 +67,11 @@ public final class NfcAdapterExtras {
|
|||||||
|
|
||||||
/** get service handles */
|
/** get service handles */
|
||||||
private static void initService() {
|
private static void initService() {
|
||||||
sService = sAdapter.getNfcAdapterExtrasInterface();
|
final INfcAdapterExtras service = sAdapter.getNfcAdapterExtrasInterface();
|
||||||
|
if (service != null) {
|
||||||
|
// Leave stale rather than receive a null value.
|
||||||
|
sService = service;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,18 +88,19 @@ public final class NfcAdapterExtras {
|
|||||||
if (sSingleton == null) {
|
if (sSingleton == null) {
|
||||||
try {
|
try {
|
||||||
sAdapter = adapter;
|
sAdapter = adapter;
|
||||||
sRouteOff = new CardEmulationRoute(CardEmulationRoute.ROUTE_OFF, null);
|
|
||||||
sSingleton = new NfcAdapterExtras();
|
sSingleton = new NfcAdapterExtras();
|
||||||
sEmbeddedEe = new NfcExecutionEnvironment(sSingleton);
|
sEmbeddedEe = new NfcExecutionEnvironment(sSingleton);
|
||||||
|
sRouteOff = new CardEmulationRoute(CardEmulationRoute.ROUTE_OFF, null);
|
||||||
sRouteOnWhenScreenOn = new CardEmulationRoute(
|
sRouteOnWhenScreenOn = new CardEmulationRoute(
|
||||||
CardEmulationRoute.ROUTE_ON_WHEN_SCREEN_ON, sEmbeddedEe);
|
CardEmulationRoute.ROUTE_ON_WHEN_SCREEN_ON, sEmbeddedEe);
|
||||||
initService();
|
initService();
|
||||||
} finally {
|
} finally {
|
||||||
if (sSingleton == null) {
|
if (sService == null) {
|
||||||
sService = null;
|
|
||||||
sEmbeddedEe = null;
|
|
||||||
sRouteOff = null;
|
|
||||||
sRouteOnWhenScreenOn = null;
|
sRouteOnWhenScreenOn = null;
|
||||||
|
sRouteOff = null;
|
||||||
|
sEmbeddedEe = null;
|
||||||
|
sSingleton = null;
|
||||||
|
sAdapter = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user