summaryrefslogtreecommitdiffstats
path: root/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
diff options
context:
space:
mode:
authorzhenchao <zhenchao@codeaurora.org>2016-03-04 16:31:14 +0800
committerzhenchao <zhenchao@codeaurora.org>2016-03-04 16:32:30 +0800
commitb164a3666ca1f6b07e617e26c2b8d8dca17e6e55 (patch)
tree78919c8b756eeb6a16ad9601c5f65fa57bf22663 /src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
parent2e6201061cf74cb776c6fa36accead920f3b7b1e (diff)
downloadandroid_packages_apps_Bluetooth-b164a3666ca1f6b07e617e26c2b8d8dca17e6e55.tar.gz
android_packages_apps_Bluetooth-b164a3666ca1f6b07e617e26c2b8d8dca17e6e55.tar.bz2
android_packages_apps_Bluetooth-b164a3666ca1f6b07e617e26c2b8d8dca17e6e55.zip
Bluetooth-OPP: Use a volatile variable to denote interrupt status
Sometimes, isInterrupted() can not return true and no interruptedException throw after uiUpdateThread.interrupt(), which cause the dead loop in ContentResolverUpdateThread. So a volatie variable is used instead of isInterrupted() to denote interrupt status. CRs-Fixed: 979690 Change-Id: I45ec1c20b5a381ba75aca589c28a0ddd94573d0c
Diffstat (limited to 'src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java')
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
index 2113fe4d5..07e0c7689 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.