diff options
author | Martijn Coenen <maco@google.com> | 2012-10-25 20:49:48 -0700 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2012-10-25 20:51:05 -0700 |
commit | 1a6bcf3cca90fedfbad33c1cdd6d05af5774fc01 (patch) | |
tree | 9ba23ea50f82859870627189466c72574530ab7e | |
parent | 5cd1d0c05c257bf8004594bdfd1e6b0e9c95428d (diff) | |
download | packages_apps_nfc-1a6bcf3cca90fedfbad33c1cdd6d05af5774fc01.zip packages_apps_nfc-1a6bcf3cca90fedfbad33c1cdd6d05af5774fc01.tar.gz packages_apps_nfc-1a6bcf3cca90fedfbad33c1cdd6d05af5774fc01.tar.bz2 |
Serialize applying card emulation route.
Instead of immediately applying the routing,
serialze the request with any outstanding
commands (including NFC enable/disable). This
prevents race conditions when NFC is being disabled
and the card emu routing gets changed at the same time.
Wait until the AsyncTask is complete, to make sure
that the routing is applied (if possible) by the time
the call returns.
Bug: 7418238
Change-Id: I7d92533179c02f4b6b01a86967737e64532317a1
-rwxr-xr-x | src/com/android/nfc/NfcService.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 551469d..d63f84f 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -1403,7 +1403,16 @@ public class NfcService implements DeviceHostListener { public void setCardEmulationRoute(String pkg, int route) throws RemoteException { NfcService.this.enforceNfceeAdminPerm(pkg); mEeRoutingState = route; - applyRouting(true); + ApplyRoutingTask applyRoutingTask = new ApplyRoutingTask(); + applyRoutingTask.execute(); + try { + // Block until route is set + applyRoutingTask.get(); + } catch (ExecutionException e) { + Log.e(TAG, "failed to set card emulation mode"); + } catch (InterruptedException e) { + Log.e(TAG, "failed to set card emulation mode"); + } } @Override |