diff options
author | Hemant Gupta <hemantg@codeaurora.org> | 2014-08-05 10:10:42 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:23:56 -0600 |
commit | 34906a912695bbbf95d8f8d32e173a6bf1a35cde (patch) | |
tree | fd3d2c165383a2fe9e1a549c9ae9224e1666e65a | |
parent | 65e631579ffa71edee38eada2a4e0d5c388e96c4 (diff) | |
download | android_frameworks_opt_bluetooth-34906a912695bbbf95d8f8d32e173a6bf1a35cde.tar.gz android_frameworks_opt_bluetooth-34906a912695bbbf95d8f8d32e173a6bf1a35cde.tar.bz2 android_frameworks_opt_bluetooth-34906a912695bbbf95d8f8d32e173a6bf1a35cde.zip |
PBAPC: Fix following issues in PBAP Client Code
- Do not disconnect Pbap client session in specific error cases
For a dut initiated get vcard request, if the server is responding
with 'Not Acceptable' response code, do not disconnect the pbap
client session. It allows the user to do other pbap operations
without initiating pbap connection request once again.
- Run the abort and disconnect operation in a seperate thread
This change has been done to start the abort and disconnect
in a seperate thread so that it doesn't block the main thread.
The new thread was not spawned properly with the old implementation
resulting in ANR in the test application.
Change-Id: I0676e11e1ccdbbd9f9c7d1378293e12a3059bd04
CRs-Fixed: 720092, 645818, 799409, 668890
3 files changed, 32 insertions, 13 deletions
diff --git a/src/android/bluetooth/client/pbap/BluetoothPbapCard.java b/src/android/bluetooth/client/pbap/BluetoothPbapCard.java index 6c4fadc..49678cf 100644 --- a/src/android/bluetooth/client/pbap/BluetoothPbapCard.java +++ b/src/android/bluetooth/client/pbap/BluetoothPbapCard.java @@ -50,7 +50,10 @@ public class BluetoothPbapCard { * format is as for vCard N field, so we have up to 5 tokens: LastName; * FirstName; MiddleName; Prefix; Suffix */ - String[] parsedName = name.split(";", 5); + String[] parsedName = new String[0]; + + if ((name != null) && (!(name.isEmpty()))) + parsedName = name.split(";", 5); lastName = parsedName.length < 1 ? null : parsedName[0]; firstName = parsedName.length < 2 ? null : parsedName[1]; diff --git a/src/android/bluetooth/client/pbap/BluetoothPbapObexSession.java b/src/android/bluetooth/client/pbap/BluetoothPbapObexSession.java index f558cc4..2e7675d 100644 --- a/src/android/bluetooth/client/pbap/BluetoothPbapObexSession.java +++ b/src/android/bluetooth/client/pbap/BluetoothPbapObexSession.java @@ -65,12 +65,20 @@ final class BluetoothPbapObexSession { Log.d(TAG, "stop"); if (mObexClientThread != null) { - try { - mObexClientThread.interrupt(); - mObexClientThread.join(); - mObexClientThread = null; - } catch (InterruptedException e) { - } + abort(); + Thread t = new Thread(new Runnable() { + public void run () { + Log.d(TAG, "Spawning a new thread for stopping obex session"); + try { + mObexClientThread.interrupt(); + mObexClientThread.join(); + mObexClientThread = null; + } catch (InterruptedException e) { + } + } + }); + t.start(); + Log.d(TAG, "Exiting from the stopping thread"); } } @@ -82,13 +90,18 @@ final class BluetoothPbapObexSession { * since abort may block until complete GET is processed inside OBEX * session, let's run it in separate thread so it won't block UI */ - (new Thread() { - @Override - public void run() { + Log.d(TAG, "aborting the ongoing request"); + Thread t = new Thread(new Runnable() { + public void run () { + if (mObexClientThread != null && mObexClientThread.mRequest != null) { + Log.d(TAG, "Spawning a new thread for aborting"); mObexClientThread.mRequest.abort(); } - }).run(); - } + } + }); + t.start(); + Log.d(TAG, "Exiting from the abort thread"); + } } public boolean schedule(BluetoothPbapRequest request) { @@ -144,15 +157,18 @@ final class BluetoothPbapObexSession { synchronized (this) { try { if (mRequest == null) { + Log.d(TAG, "waiting for request"); this.wait(); } } catch (InterruptedException e) { + Log.d(TAG, "Interrupted"); mRunning = false; break; } } if (mRunning && mRequest != null) { + Log.d(TAG, "before executing the request mRunning:" + mRunning); try { mRequest.execute(mClientSession); } catch (IOException e) { @@ -167,6 +183,7 @@ final class BluetoothPbapObexSession { mSessionHandler.obtainMessage(OBEX_SESSION_REQUEST_FAILED, mRequest) .sendToTarget(); } + Log.d(TAG, "after executing the request mRunning:" + mRunning); } mRequest = null; diff --git a/src/android/bluetooth/client/pbap/BluetoothPbapSession.java b/src/android/bluetooth/client/pbap/BluetoothPbapSession.java index 70e0ac8..bdb005f 100644 --- a/src/android/bluetooth/client/pbap/BluetoothPbapSession.java +++ b/src/android/bluetooth/client/pbap/BluetoothPbapSession.java @@ -178,7 +178,6 @@ class BluetoothPbapSession implements Callback { Log.d(TAG, "Stop"); stopObexSession(); - stopRfcomm(); } public void abort() { |