summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2012-05-31 18:00:59 -0700
committerMartijn Coenen <maco@google.com>2012-05-31 18:20:19 -0700
commitf439271150e4548f116919e0254d57655421581c (patch)
treefb50d03343334796681ab2bc9dc821c370617e18 /src
parent5c1c4487e6b1d67995507d882e10f92871158904 (diff)
downloadpackages_apps_nfc-f439271150e4548f116919e0254d57655421581c.zip
packages_apps_nfc-f439271150e4548f116919e0254d57655421581c.tar.gz
packages_apps_nfc-f439271150e4548f116919e0254d57655421581c.tar.bz2
Add watchdog to applyRouting().
We've seen some devices hang in doSelectSecureElement, probably waiting for a response from the HW. Root cause is unknown, may be due to a different access pattern of Wallet or OTAProxy. Until we can reproduce better and find the root cause, watchdog this method. Added advantage is that we can have the relevant context in the logs when the crash occurs. Bug: 6585958 Change-Id: Ic797ea479869a68173fcd42049cc4ba8d009d2e0
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/nfc/NfcService.java99
1 files changed, 53 insertions, 46 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 7b3c456..602b25d 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -1407,62 +1407,69 @@ public class NfcService extends Application implements DeviceHostListener {
// PN544 cannot be reconfigured while EE is open
return;
}
+ WatchDogThread watchDog = new WatchDogThread();
- if (PN544_QUIRK_DISCONNECT_BEFORE_RECONFIGURE && mScreenState == SCREEN_STATE_OFF) {
- /* TODO undo this after the LLCP stack is fixed.
- * Use a different sequence when turning the screen off to
- * workaround race conditions in pn544 libnfc. The race occurs
- * when we change routing while there is a P2P target connect.
- * The async LLCP callback will crash since the routing code
- * is overwriting globals it relies on.
- */
- if (POLLING_MODE > SCREEN_STATE_OFF) {
- if (force || mNfcPollingEnabled) {
- Log.d(TAG, "NFC-C OFF, disconnect");
- mNfcPollingEnabled = false;
- mDeviceHost.disableDiscovery();
- maybeDisconnectTarget();
+ try {
+ watchDog.start();
+
+ if (PN544_QUIRK_DISCONNECT_BEFORE_RECONFIGURE && mScreenState == SCREEN_STATE_OFF) {
+ /* TODO undo this after the LLCP stack is fixed.
+ * Use a different sequence when turning the screen off to
+ * workaround race conditions in pn544 libnfc. The race occurs
+ * when we change routing while there is a P2P target connect.
+ * The async LLCP callback will crash since the routing code
+ * is overwriting globals it relies on.
+ */
+ if (POLLING_MODE > SCREEN_STATE_OFF) {
+ if (force || mNfcPollingEnabled) {
+ Log.d(TAG, "NFC-C OFF, disconnect");
+ mNfcPollingEnabled = false;
+ mDeviceHost.disableDiscovery();
+ maybeDisconnectTarget();
+ }
}
+ if (mEeRoutingState == ROUTE_ON_WHEN_SCREEN_ON) {
+ if (force || mNfceeRouteEnabled) {
+ Log.d(TAG, "NFC-EE OFF");
+ mNfceeRouteEnabled = false;
+ mDeviceHost.doDeselectSecureElement();
+ }
+ }
+ return;
}
- if (mEeRoutingState == ROUTE_ON_WHEN_SCREEN_ON) {
- if (force || mNfceeRouteEnabled) {
+
+ // configure NFC-EE routing
+ if (mScreenState >= SCREEN_STATE_ON_LOCKED &&
+ mEeRoutingState == ROUTE_ON_WHEN_SCREEN_ON) {
+ if (force || !mNfceeRouteEnabled) {
+ Log.d(TAG, "NFC-EE ON");
+ mNfceeRouteEnabled = true;
+ mDeviceHost.doSelectSecureElement();
+ }
+ } else {
+ if (force || mNfceeRouteEnabled) {
Log.d(TAG, "NFC-EE OFF");
mNfceeRouteEnabled = false;
mDeviceHost.doDeselectSecureElement();
}
}
- return;
- }
-
- // configure NFC-EE routing
- if (mScreenState >= SCREEN_STATE_ON_LOCKED &&
- mEeRoutingState == ROUTE_ON_WHEN_SCREEN_ON) {
- if (force || !mNfceeRouteEnabled) {
- Log.d(TAG, "NFC-EE ON");
- mNfceeRouteEnabled = true;
- mDeviceHost.doSelectSecureElement();
- }
- } else {
- if (force || mNfceeRouteEnabled) {
- Log.d(TAG, "NFC-EE OFF");
- mNfceeRouteEnabled = false;
- mDeviceHost.doDeselectSecureElement();
- }
- }
- // configure NFC-C polling
- if (mScreenState >= POLLING_MODE) {
- if (force || !mNfcPollingEnabled) {
- Log.d(TAG, "NFC-C ON");
- mNfcPollingEnabled = true;
- mDeviceHost.enableDiscovery();
- }
- } else {
- if (force || mNfcPollingEnabled) {
- Log.d(TAG, "NFC-C OFF");
- mNfcPollingEnabled = false;
- mDeviceHost.disableDiscovery();
+ // configure NFC-C polling
+ if (mScreenState >= POLLING_MODE) {
+ if (force || !mNfcPollingEnabled) {
+ Log.d(TAG, "NFC-C ON");
+ mNfcPollingEnabled = true;
+ mDeviceHost.enableDiscovery();
+ }
+ } else {
+ if (force || mNfcPollingEnabled) {
+ Log.d(TAG, "NFC-C OFF");
+ mNfcPollingEnabled = false;
+ mDeviceHost.disableDiscovery();
+ }
}
+ } finally {
+ watchDog.cancel();
}
}
}