Use a BroadcastReceiver to get the battery info instead of polling
This commit is contained in:
@@ -40,10 +40,6 @@
|
||||
#include "render/scene_renderer.h"
|
||||
#include "utils/async.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "android/battery.h"
|
||||
#endif
|
||||
|
||||
class wivrn_session;
|
||||
|
||||
namespace scenes
|
||||
@@ -117,10 +113,6 @@ class lobby : public scene_impl<lobby>
|
||||
void move_gui(glm::vec3 head_position, glm::vec3 new_gui_position);
|
||||
void tooltip(std::string_view text);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
battery battery_tracker;
|
||||
#endif
|
||||
|
||||
enum class tab
|
||||
{
|
||||
server_list,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "android/battery.h"
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
#include "application.h"
|
||||
@@ -1113,7 +1114,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
||||
|
||||
#ifdef __ANDROID__
|
||||
// Battery status
|
||||
auto status = battery_tracker.get();
|
||||
auto status = get_battery_status();
|
||||
|
||||
const char * battery_icon = nullptr;
|
||||
if (status.charge)
|
||||
|
||||
@@ -161,8 +161,6 @@ void scenes::stream::tracking()
|
||||
// Runtime may use JNI and needs the thread to be attached
|
||||
application::instance().setup_jni();
|
||||
|
||||
battery battery_tracker;
|
||||
|
||||
XrTime next_battery_check = 0;
|
||||
const XrDuration battery_check_interval = 30'000'000'000; // 30s
|
||||
#endif
|
||||
@@ -301,7 +299,7 @@ void scenes::stream::tracking()
|
||||
{
|
||||
timer t2(instance);
|
||||
|
||||
auto status = battery_tracker.get();
|
||||
auto status = get_battery_status();
|
||||
network_session->send_stream(from_headset::battery{
|
||||
.charge = status.charge.value_or(-1),
|
||||
.present = status.charge.has_value(),
|
||||
|
||||
Reference in New Issue
Block a user