ipc/android: Force client entering resume state before IPC setup

This commit is contained in:
Jarvis Huang 2021-10-19 11:53:16 +08:00 committed by Ryan Pavlik
parent c635375dc7
commit 6b8349c887

View file

@ -19,8 +19,6 @@
#include "wrap/android.app.h"
#include <android/api-level.h>
using wrap::android::app::Activity;
using wrap::org::freedesktop::monado::ipc::Client;
using xrt::auxiliary::android::getAppInfo;
@ -87,10 +85,9 @@ ipc_client_android_create(struct _JavaVM *vm, void *activity)
int
ipc_client_android_blocking_connect(struct ipc_client_android *ica)
{
// Before android Q, onServiceConnected always returns on main thread, which might cause deadlock.
if (android_get_device_api_level() < __ANDROID_API_Q__) {
// To avoid deadlock on main thread, force client entering resume state
// before setting up IPC/surface
android_looper_poll_until_activity_resumed();
}
try {
int fd = ica->client.blockingConnect(ica->activity, XRT_ANDROID_PACKAGE);