diff --git a/client/application.cpp b/client/application.cpp index fae1f2a8..86810fa6 100644 --- a/client/application.cpp +++ b/client/application.cpp @@ -954,6 +954,8 @@ void application::set_wifi_locks(bool enabled) jni::string lock_name("WiVRn"); + static int api_level = jni::klass("android/os/Build$VERSION").field("SDK_INT"); + auto app = act.call>("getApplication"); auto ctx = app.call>("getApplicationContext"); auto wifi_service_id = ctx.klass().field("WIFI_SERVICE"); @@ -970,7 +972,10 @@ void application::set_wifi_locks(bool enabled) spdlog::info("MulticastLock is not acquired"); } - auto wifi_lock = system_service.call>("createWifiLock", jni::Int(3) /*WIFI_MODE_FULL_HIGH_PERF*/, lock_name); + auto wifi_lock = system_service.call>( + "createWifiLock", + jni::Int(api_level >= 29 ? 4 /*WIFI_MODE_FULL_LOW_LATENCY*/ : 3 /*WIFI_MODE_FULL_HIGH_PERF*/), + lock_name); wifi_lock.call("setReferenceCounted", jni::Bool(false)); wifi_lock.call(enabled ? "acquire" : "release"); if (wifi_lock.call("isHeld")) diff --git a/client/jnipp.h b/client/jnipp.h index 4c40be48..cc479da3 100644 --- a/client/jnipp.h +++ b/client/jnipp.h @@ -124,6 +124,11 @@ struct klass self.reset(env.GetObjectClass(instance)); } + klass(const char * name) : + self(jni_thread::env().FindClass(name)) + { + } + template T field(const std::string & name) { @@ -165,6 +170,8 @@ struct Bool struct Int { + constexpr static auto static_field = &_JNIEnv::GetStaticIntField; + static std::string type() { return "I";