Make the emulator less of a special case

This commit is contained in:
Matti Viljanen 2021-04-26 17:13:11 +03:00
parent 9079c10bd1
commit afe6850d88
No known key found for this signature in database
GPG key ID: CF32A1495158F888
3 changed files with 10 additions and 19 deletions

View file

@ -19,7 +19,6 @@
Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QObject(parent)
{
QString filename;
settings = newSettings;
logger = newLogger;
@ -39,11 +38,8 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
chargerConnectedFile = new QFile("/sys/class/power_supply/usb/present", this);
logV("Reading charger status from" + chargerConnectedFile->fileName());
// ENABLE/DISABLE CHARGING
if(QHostInfo::localHostName().contains("SailfishEmul")) {
logV("Sailfish SDK detected, not using charger control file");
}
else {
QString filename;
// e.g. for Sony Xperia XA2
filename = "/sys/class/power_supply/battery/input_suspend";
if(!chargingEnabledFile && QFile::exists(filename)) {
@ -68,12 +64,10 @@ Battery::Battery(Settings* newSettings, Logger* newLogger, QObject* parent) : QO
disableChargingValue = 1;
}
if(!chargingEnabledFile) {
if(!chargingEnabledFile && !QHostInfo::localHostName().contains("SailfishEmul")) {
logE("Charger control file not found!");
logE("Please contact the developer with your device model!");
}
}
// If we found a usable file, check that it is writable
if(chargingEnabledFile) {

View file

@ -46,15 +46,16 @@ int main(int argc, char *argv[])
bool verbose = false;
bool debug = false;
if(QHostInfo::localHostName().contains("SailfishEmul")) {
verbose = true;
debug = true;
}
for(int i = 0; i < argc; i++) {
if(!strcmp(argv[i],"-v")) {
printf("%s %s\n", APP_NAME, APP_VERSION);
return 0;
}
else if(QHostInfo::localHostName().contains("SailfishEmul")) {
verbose = true;
debug = true;
}
else if(!strcmp(argv[i],"--verbose")) {
verbose = true;
debug = false;

View file

@ -49,10 +49,7 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QObject *parent) : QObject
// ENABLE/DISABLE CHARGING
QString filename;
if(QHostInfo::localHostName().contains("SailfishEmul")) {
logE("Sailfish SDK detected, not using charger control file");
}
else {
// e.g. for Sony Xperia XA2
filename = "/sys/class/power_supply/battery/input_suspend";
if(!chargingEnabledFile && QFile::exists(filename)) {
@ -77,11 +74,10 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QObject *parent) : QObject
disableChargingValue = 1;
}
if(!chargingEnabledFile) {
if(!chargingEnabledFile && QHostInfo::localHostName().contains("SailfishEmul")) {
logE("Charger control file not found!");
logE("Please contact the developer with your device model!");
}
}
// If we found a usable file, check that it is writable
if(chargingEnabledFile) {