Use better wifi low latency if available
This commit is contained in:
@@ -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<jni::Int>("SDK_INT");
|
||||
|
||||
auto app = act.call<jni::object<"android/app/Application">>("getApplication");
|
||||
auto ctx = app.call<jni::object<"android/content/Context">>("getApplicationContext");
|
||||
auto wifi_service_id = ctx.klass().field<jni::string>("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<jni::object<"android/net/wifi/WifiManager$WifiLock">>("createWifiLock", jni::Int(3) /*WIFI_MODE_FULL_HIGH_PERF*/, lock_name);
|
||||
auto wifi_lock = system_service.call<jni::object<"android/net/wifi/WifiManager$WifiLock">>(
|
||||
"createWifiLock",
|
||||
jni::Int(api_level >= 29 ? 4 /*WIFI_MODE_FULL_LOW_LATENCY*/ : 3 /*WIFI_MODE_FULL_HIGH_PERF*/),
|
||||
lock_name);
|
||||
wifi_lock.call<void>("setReferenceCounted", jni::Bool(false));
|
||||
wifi_lock.call<void>(enabled ? "acquire" : "release");
|
||||
if (wifi_lock.call<jni::Bool>("isHeld"))
|
||||
|
||||
@@ -124,6 +124,11 @@ struct klass
|
||||
self.reset(env.GetObjectClass(instance));
|
||||
}
|
||||
|
||||
klass(const char * name) :
|
||||
self(jni_thread::env().FindClass(name))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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";
|
||||
|
||||
Reference in New Issue
Block a user