merge in lmp-mr1-nova-release history after reset to lmp-mr1-dev
diff --git a/src/com/android/server/telecom/BluetoothPhoneService.java b/src/com/android/server/telecom/BluetoothPhoneService.java
index da39524..9a0cae1 100644
--- a/src/com/android/server/telecom/BluetoothPhoneService.java
+++ b/src/com/android/server/telecom/BluetoothPhoneService.java
@@ -28,6 +28,7 @@
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
+import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.telecom.CallState;
@@ -53,7 +54,8 @@
* Request object for performing synchronous requests to the main thread.
*/
private static class MainThreadRequest {
- Object result;
+ private static final Object RESULT_NOT_SET = new Object();
+ Object result = RESULT_NOT_SET;
int param;
MainThreadRequest(int param) {
@@ -539,14 +541,19 @@
}
private <T> T sendSynchronousRequest(int message, int param) {
+ if (Looper.myLooper() == mHandler.getLooper()) {
+ Log.w(TAG, "This method will deadlock if called from the main thread.");
+ }
+
MainThreadRequest request = new MainThreadRequest(param);
mHandler.obtainMessage(message, request).sendToTarget();
synchronized (request) {
- while (request.result == null) {
+ while (request.result == MainThreadRequest.RESULT_NOT_SET) {
try {
request.wait();
} catch (InterruptedException e) {
// Do nothing, go back and wait until the request is complete.
+ Log.e(TAG, e, "InterruptedException");
}
}
}