summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2012-05-31 19:48:31 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-31 19:48:31 -0700
commitdb4c5aeb1b467525549e5e29136b61455d94c0ba (patch)
treef4cc57452c4260e1f2ea8f13623e980e487c88ae /src
parentc2c8f3e11970239c7d5cf9c4c4e3ff5f67e33842 (diff)
parentd560e24e8edf8251a3756400ce5f75bcfdd51b9a (diff)
downloadpackages_apps_nfc-db4c5aeb1b467525549e5e29136b61455d94c0ba.zip
packages_apps_nfc-db4c5aeb1b467525549e5e29136b61455d94c0ba.tar.gz
packages_apps_nfc-db4c5aeb1b467525549e5e29136b61455d94c0ba.tar.bz2
am d560e24e: am f4392711: Add watchdog to applyRouting().
* commit 'd560e24e8edf8251a3756400ce5f75bcfdd51b9a': Add watchdog to applyRouting().
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();
}
}
}