Commit b983836f authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Support Bluetooth batteries

There's currently no generic Bluetooth device type in UPower, so we get them of "unknown" type.
Check for whether it comes from Bluez to determine it's a Bluetooth battery.

Differential Revision: https://phabricator.kde.org/D17345
parent 5497c37c
......@@ -58,6 +58,8 @@ Solid::Battery::BatteryType FakeBattery::type() const
return Solid::Battery::CameraBattery;
} else if (name == "gaminginput") {
return Solid::Battery::GamingInputBattery;
} else if (name == "bluetooth") {
return Solid::Battery::BluetoothBattery;
} else {
return Solid::Battery::UnknownBattery;
}
......
......@@ -74,6 +74,14 @@ Solid::Battery::BatteryType Battery::type() const
case UP_DEVICE_KIND_GAMING_INPUT:
result = Solid::Battery::GamingInputBattery;
break;
case UP_DEVICE_KIND_UNKNOWN: {
// There is currently no "Bluetooth battery" type, so check if it comes from Bluez
if (m_device.data()->prop("NativePath").toString().startsWith(QLatin1String("/org/bluez/"))) {
result = Solid::Battery::BluetoothBattery;
}
break;
}
}
return result;
}
......
......@@ -99,6 +99,11 @@ bool UPowerDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type
case UP_DEVICE_KIND_GAMING_INPUT:
return true;
case UP_DEVICE_KIND_UNKNOWN:
// There is currently no "Bluetooth battery" type, so check if it comes from Bluez
if (prop("NativePath").toString().startsWith(QLatin1String("/org/bluez/"))) {
return true;
}
return false;
case UP_DEVICE_KIND_LINE_POWER:
case UP_DEVICE_KIND_MONITOR:
case UP_DEVICE_KIND_MEDIA_PLAYER:
......
......@@ -75,12 +75,15 @@ public:
* - PhoneBattery : A battery in a phone
* - MonitorBattery : A battery in a monitor
* - GamingInputBattery : A battery in a gaming input device (for example a wireless game pad)
* - BluetoothBattery: A generic Bluetooth device battery (if its type isn't known, a Bluetooth
* mouse would normally show up as a MouseBattery), @since 5.54
* - UnknownBattery : A battery in an unknown device
*/
enum BatteryType { UnknownBattery, PdaBattery, UpsBattery,
PrimaryBattery, MouseBattery, KeyboardBattery,
KeyboardMouseBattery, CameraBattery,
PhoneBattery, MonitorBattery, GamingInputBattery
PhoneBattery, MonitorBattery, GamingInputBattery,
BluetoothBattery
};
Q_ENUM(BatteryType)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment