diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2016-03-26 12:29:22 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-03-26 12:29:22 -0700 |
commit | dcf8a4bf72df93241849e5c7ac9b25fd270cbe0d (patch) | |
tree | c02f6252fe4a539d2488ea3c1c8b065d9f8614b3 | |
parent | 5ef39577be3c0188651413415182a95a849c9ee3 (diff) | |
parent | b164a3666ca1f6b07e617e26c2b8d8dca17e6e55 (diff) | |
download | android_packages_apps_Bluetooth-dcf8a4bf72df93241849e5c7ac9b25fd270cbe0d.tar.gz android_packages_apps_Bluetooth-dcf8a4bf72df93241849e5c7ac9b25fd270cbe0d.tar.bz2 android_packages_apps_Bluetooth-dcf8a4bf72df93241849e5c7ac9b25fd270cbe0d.zip |
Merge "Bluetooth-OPP: Use a volatile variable to denote interrupt status"
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java | 18 | ||||
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java | 13 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java index e2ecfc5b8..63de591b5 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java @@ -128,11 +128,13 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { private static final int sSleepTime = 1000; private Uri contentUri; private Context mContext1; + private volatile boolean interrupted = false; public ContentResolverUpdateThread(Context context, Uri cntUri) { super("BtOpp ContentResolverUpdateThread"); mContext1 = context; contentUri = cntUri; + interrupted = false; } @@ -143,19 +145,33 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { ContentValues updateValues; if (V) Log.v(TAG, "Is ContentResolverUpdateThread Interrupted :" + isInterrupted()); /* Check if the Operation is interrupted before entering into loop */ - while (!isInterrupted()) { + while (!interrupted) { updateValues = new ContentValues(); updateValues.put(BluetoothShare.CURRENT_BYTES, position); mContext1.getContentResolver().update(contentUri, updateValues, null, null); + + /* Check if the Operation is interrupted before entering sleep */ + if (interrupted) { + if (V) Log.v(TAG, "ContentResolverUpdateThread was interrupted before sleep !, exiting"); + return; + } + try { Thread.sleep(sSleepTime); } catch (InterruptedException e1) { if (V) Log.v(TAG, "ContentResolverUpdateThread was interrupted (1), exiting"); + interrupted = true; return; } } } + + @Override + public void interrupt() { + interrupted = true; + super.interrupt(); + } } private class ClientThread extends Thread { diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java index 0056450ab..4a90e04ba 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java +++ b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java @@ -173,11 +173,13 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen private static final int sSleepTime = 1000; private Uri contentUri; private Context mContext1; + private volatile boolean interrupted = false; public ContentResolverUpdateThread(Context context, Uri cntUri) { super("BtOpp Server ContentResolverUpdateThread"); mContext1 = context; contentUri = cntUri; + interrupted = false; } @Override @@ -188,14 +190,14 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen if (V) Log.v(TAG, "Is ContentResolverUpdateThread Interrupted :" + isInterrupted()); /* Check if the Operation is interrupted before entering into loop */ - while ( !isInterrupted() ) { + while (!interrupted) { updateValues = new ContentValues(); updateValues.put(BluetoothShare.CURRENT_BYTES, position); mContext1.getContentResolver().update(contentUri, updateValues, null, null); /* Check if the Operation is interrupted before entering sleep */ - if (isInterrupted()) { + if (interrupted) { if (V) Log.v(TAG, "ContentResolverUpdateThread was interrupted before sleep !,"+ " exiting"); return ; @@ -205,10 +207,17 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen } catch (InterruptedException e1) { if (V) Log.v(TAG, "Server ContentResolverUpdateThread was interrupted (1),"+ " exiting"); + interrupted = true; return ; } } } + + @Override + public void interrupt() { + interrupted = true; + super.interrupt(); + } } /* * Called when a ABORT request is received. |