mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
(Android) Changed system status polling to run on the main thread
This commit is contained in:
parent
53bae28335
commit
b47b6d41d8
|
|
@ -49,20 +49,31 @@ SystemStatus::SystemStatus() noexcept
|
||||||
, mHasBattery {false}
|
, mHasBattery {false}
|
||||||
, mBatteryCharging {false}
|
, mBatteryCharging {false}
|
||||||
, mBatteryCapacity {0}
|
, mBatteryCapacity {0}
|
||||||
|
|
||||||
{
|
{
|
||||||
setCheckFlags();
|
setCheckFlags();
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
// Polling the device status is very fast on Android and it's quite problematic to run
|
||||||
|
// these calls in a separate thread anyway.
|
||||||
|
getStatusBluetooth();
|
||||||
|
getStatusWifi();
|
||||||
|
getStatusCellular();
|
||||||
|
getStatusBattery();
|
||||||
|
#else
|
||||||
mPollThread = std::make_unique<std::thread>(&SystemStatus::pollStatus, this);
|
mPollThread = std::make_unique<std::thread>(&SystemStatus::pollStatus, this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemStatus::~SystemStatus()
|
SystemStatus::~SystemStatus()
|
||||||
{
|
{
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
mExitPolling = true;
|
mExitPolling = true;
|
||||||
|
|
||||||
if (mPollThread != nullptr && mPollThread->joinable()) {
|
if (mPollThread != nullptr && mPollThread->joinable()) {
|
||||||
mPollThread->join();
|
mPollThread->join();
|
||||||
mPollThread.reset();
|
mPollThread.reset();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemStatus& SystemStatus::getInstance()
|
SystemStatus& SystemStatus::getInstance()
|
||||||
|
|
@ -82,6 +93,10 @@ void SystemStatus::setCheckFlags()
|
||||||
|
|
||||||
void SystemStatus::setPolling(const bool state)
|
void SystemStatus::setPolling(const bool state)
|
||||||
{
|
{
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (state == false) {
|
if (state == false) {
|
||||||
mExitPolling = true;
|
mExitPolling = true;
|
||||||
if (mPollThread != nullptr && mPollThread->joinable()) {
|
if (mPollThread != nullptr && mPollThread->joinable()) {
|
||||||
|
|
@ -97,6 +112,13 @@ void SystemStatus::setPolling(const bool state)
|
||||||
|
|
||||||
SystemStatus::Status SystemStatus::getStatus()
|
SystemStatus::Status SystemStatus::getStatus()
|
||||||
{
|
{
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
getStatusBluetooth();
|
||||||
|
getStatusWifi();
|
||||||
|
getStatusCellular();
|
||||||
|
getStatusBattery();
|
||||||
|
#endif
|
||||||
|
|
||||||
mStatus.hasBluetooth = mHasBluetooth;
|
mStatus.hasBluetooth = mHasBluetooth;
|
||||||
mStatus.hasWifi = mHasWifi;
|
mStatus.hasWifi = mHasWifi;
|
||||||
mStatus.hasCellular = mHasCellular;
|
mStatus.hasCellular = mHasCellular;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue