2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Answer battery status requests

This commit is contained in:
Albert Vaca
2013-08-14 00:02:31 +02:00
parent 53f8af551d
commit b3ca862ba8

View File

@@ -34,11 +34,12 @@ public class BatteryMonitorPackageInterface extends BasePackageInterface {
}
//Only notify if change is meaningful enough
if (lastPackage == null || (
if (lastPackage == null
|| (
isCharging != lastPackage.getBoolean("isCharging")
|| currentCharge != lastPackage.getInt("currentCharge")
)
) {
|| currentCharge != lastPackage.getInt("currentCharge")
)
) {
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_BATTERY);
np.set("isCharging", isCharging);
np.set("currentCharge", currentCharge);
@@ -63,8 +64,15 @@ public class BatteryMonitorPackageInterface extends BasePackageInterface {
@Override
public boolean onPackageReceived(Device d, NetworkPackage np) {
//Do nothing
return false;
if (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_BATTERY)) return false;
if (np.getBoolean("request")) {
if (lastPackage != null) {
sendPackage(lastPackage);
}
}
return true;
}
@Override