@@ -155,6 +155,10 @@ void scenes::stream::tracking()
|
||||
auto receiver_jobj = jni::object<"android/content/BroadcastReceiver">(NULL);
|
||||
auto filter_jobj = jni::new_object<"android/content/IntentFilter">(filter_jstr);
|
||||
|
||||
auto register_receiver = jni::klass("android/content/Context")
|
||||
.method<jni::object<"android/content/Intent">>("registerReceiver", receiver_jobj, filter_jobj);
|
||||
auto get_int_extra = jni::klass("android/content/Intent").method<jni::Int>("getIntExtra", level_jstr, default_jint);
|
||||
|
||||
XrTime next_battery_check = 0;
|
||||
const XrDuration battery_check_interval = 5'000'000'000; // 5s
|
||||
#endif
|
||||
@@ -267,11 +271,11 @@ void scenes::stream::tracking()
|
||||
{
|
||||
timer t2(instance);
|
||||
from_headset::battery battery{};
|
||||
auto intent = ctx.call<jni::object<"android/content/Intent">>("registerReceiver", receiver_jobj, filter_jobj);
|
||||
auto intent = ctx.call<jni::object<"android/content/Intent">>(register_receiver, receiver_jobj, filter_jobj);
|
||||
if (intent)
|
||||
{
|
||||
auto level_jint = intent.call<jni::Int>("getIntExtra", level_jstr, default_jint);
|
||||
auto scale_jint = intent.call<jni::Int>("getIntExtra", scale_jstr, default_jint);
|
||||
auto level_jint = intent.call<jni::Int>(get_int_extra, level_jstr, default_jint);
|
||||
auto scale_jint = intent.call<jni::Int>(get_int_extra, scale_jstr, default_jint);
|
||||
|
||||
if (level_jint && level_jint.value >= 0 && scale_jint && scale_jint.value >= 0)
|
||||
{
|
||||
@@ -279,7 +283,7 @@ void scenes::stream::tracking()
|
||||
battery.charge = (float)(level_jint.value) / (float)(scale_jint.value);
|
||||
}
|
||||
|
||||
auto plugged_jint = intent.call<jni::Int>("getIntExtra", plugged_jstr, default_jint);
|
||||
auto plugged_jint = intent.call<jni::Int>(get_int_extra, plugged_jstr, default_jint);
|
||||
battery.charging = plugged_jint && plugged_jint.value > 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user