Loading src/com/android/server/telecom/BluetoothPhoneService.java +9 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.IntentFilter; 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; Loading @@ -53,7 +54,8 @@ public final class BluetoothPhoneService extends Service { * 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) { Loading Loading @@ -539,14 +541,19 @@ public final class BluetoothPhoneService extends Service { } 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"); } } } Loading Loading
src/com/android/server/telecom/BluetoothPhoneService.java +9 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.IntentFilter; 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; Loading @@ -53,7 +54,8 @@ public final class BluetoothPhoneService extends Service { * 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) { Loading Loading @@ -539,14 +541,19 @@ public final class BluetoothPhoneService extends Service { } 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"); } } } Loading