mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
GBDevice: update caller to use multi-battery methods
This commit is contained in:
@@ -160,10 +160,10 @@ public class Widget extends AppWidgetProvider {
|
|||||||
views.setViewVisibility(R.id.todaywidget_battery_icon, View.GONE);
|
views.setViewVisibility(R.id.todaywidget_battery_icon, View.GONE);
|
||||||
String status = String.format("%1s", deviceForWidget.getStateString(context));
|
String status = String.format("%1s", deviceForWidget.getStateString(context));
|
||||||
if (deviceForWidget.isConnected()) {
|
if (deviceForWidget.isConnected()) {
|
||||||
if (deviceForWidget.getBatteryLevel() > 1) {
|
if (deviceForWidget.getBatteryLevel(0) > 1) {
|
||||||
views.setViewVisibility(R.id.todaywidget_battery_icon, View.VISIBLE);
|
views.setViewVisibility(R.id.todaywidget_battery_icon, View.VISIBLE);
|
||||||
|
|
||||||
status = String.format("%1s%%", deviceForWidget.getBatteryLevel());
|
status = String.format("%1s%%", deviceForWidget.getBatteryLevel(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -178,7 +178,7 @@ public class ControlActivity extends AbstractGBActivity implements JoystickView.
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setBatteryLabel() {
|
private void setBatteryLabel() {
|
||||||
String level = device.getBatteryLevel() > 0 ? String.format("%1s%%", device.getBatteryLevel()) : device.getName();
|
String level = device.getBatteryLevel(0) > 0 ? String.format("%1s%%", device.getBatteryLevel(0)) : device.getName();
|
||||||
batteryPercentage.setText(level);
|
batteryPercentage.setText(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -427,7 +427,7 @@ class HPlusHandlerThread extends GBDeviceIoThread {
|
|||||||
|
|
||||||
prevRealTimeRecord = record;
|
prevRealTimeRecord = record;
|
||||||
|
|
||||||
getDevice().setBatteryLevel(record.battery);
|
getDevice().setBatteryLevel(record.battery, 0);
|
||||||
|
|
||||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
||||||
HPlusHealthSampleProvider provider = new HPlusHealthSampleProvider(getDevice(), dbHandler.getDaoSession());
|
HPlusHealthSampleProvider provider = new HPlusHealthSampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||||
|
|||||||
+1
-1
@@ -719,7 +719,7 @@ public class AsynchronousResponse {
|
|||||||
|
|
||||||
if (resp.multi_level == null) {
|
if (resp.multi_level == null) {
|
||||||
byte batteryLevel = resp.level;
|
byte batteryLevel = resp.level;
|
||||||
this.support.getDevice().setBatteryLevel(batteryLevel);
|
this.support.getDevice().setBatteryLevel(batteryLevel, 0);
|
||||||
|
|
||||||
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
||||||
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ public class GetBatteryLevelRequest extends Request {
|
|||||||
|
|
||||||
if (response.multi_level == null) {
|
if (response.multi_level == null) {
|
||||||
byte batteryLevel = response.level;
|
byte batteryLevel = response.level;
|
||||||
getDevice().setBatteryLevel(batteryLevel);
|
getDevice().setBatteryLevel(batteryLevel, 0);
|
||||||
|
|
||||||
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
||||||
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
||||||
|
|||||||
+1
-1
@@ -454,7 +454,7 @@ public class IGPSportDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
|||||||
public void handleFactoryData(byte[] data) throws InvalidProtocolBufferException {
|
public void handleFactoryData(byte[] data) throws InvalidProtocolBufferException {
|
||||||
Factory.factory_msg factoryMsg = Factory.factory_msg.parseFrom(data);
|
Factory.factory_msg factoryMsg = Factory.factory_msg.parseFrom(data);
|
||||||
if (factoryMsg.hasBattaryMsg()) {
|
if (factoryMsg.hasBattaryMsg()) {
|
||||||
gbDevice.setBatteryLevel(factoryMsg.getBattaryMsg().getPowerPercent());
|
gbDevice.setBatteryLevel(factoryMsg.getBattaryMsg().getPowerPercent(), 0);
|
||||||
}
|
}
|
||||||
if (factoryMsg.getFactorySnMsgList().size() > 0) {
|
if (factoryMsg.getFactorySnMsgList().size() > 0) {
|
||||||
// save serial to volatile address now, need to find way to use it as identifier in database
|
// save serial to volatile address now, need to find way to use it as identifier in database
|
||||||
|
|||||||
+1
-1
@@ -240,7 +240,7 @@ public class MarstekB2500DeviceSupport extends AbstractBTLESingleDeviceSupport {
|
|||||||
devicePrefsEdit.apply();
|
devicePrefsEdit.apply();
|
||||||
devicePrefsEdit.commit();
|
devicePrefsEdit.commit();
|
||||||
|
|
||||||
getDevice().setBatteryLevel(battery_pct);
|
getDevice().setBatteryLevel(battery_pct, 0);
|
||||||
getDevice().sendDeviceUpdateIntent(getContext());
|
getDevice().sendDeviceUpdateIntent(getContext());
|
||||||
|
|
||||||
Intent intent = new Intent(SolarEquipmentStatusActivity.ACTION_SEND_SOLAR_EQUIPMENT_STATUS)
|
Intent intent = new Intent(SolarEquipmentStatusActivity.ACTION_SEND_SOLAR_EQUIPMENT_STATUS)
|
||||||
|
|||||||
+2
-2
@@ -781,10 +781,10 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
}
|
}
|
||||||
case "00002a19-0000-1000-8000-00805f9b34fb": {
|
case "00002a19-0000-1000-8000-00805f9b34fb": {
|
||||||
short level = value[0];
|
short level = value[0];
|
||||||
gbDevice.setBatteryLevel(level);
|
gbDevice.setBatteryLevel(level, 0);
|
||||||
|
|
||||||
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
||||||
batteryInfo.level = gbDevice.getBatteryLevel();
|
batteryInfo.level = gbDevice.getBatteryLevel(0);
|
||||||
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
||||||
handleGBDeviceEvent(batteryInfo);
|
handleGBDeviceEvent(batteryInfo);
|
||||||
break;
|
break;
|
||||||
|
|||||||
+2
-2
@@ -164,10 +164,10 @@ public class MisfitWatchAdapter extends WatchAdapter {
|
|||||||
}
|
}
|
||||||
case "00002a19-0000-1000-8000-00805f9b34fb": {
|
case "00002a19-0000-1000-8000-00805f9b34fb": {
|
||||||
short level = value[0];
|
short level = value[0];
|
||||||
gbDevice.setBatteryLevel(level);
|
gbDevice.setBatteryLevel(level, 0);
|
||||||
|
|
||||||
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
||||||
batteryInfo.level = gbDevice.getBatteryLevel();
|
batteryInfo.level = gbDevice.getBatteryLevel(0);
|
||||||
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
||||||
getDeviceSupport().handleGBDeviceEvent(batteryInfo);
|
getDeviceSupport().handleGBDeviceEvent(batteryInfo);
|
||||||
break;
|
break;
|
||||||
|
|||||||
+2
-2
@@ -57,8 +57,8 @@ public class ConfigurationGetRequest extends FileEncryptedLookupAndGetRequest im
|
|||||||
}else if(item instanceof ConfigurationPutRequest.TimezoneOffsetConfigItem) {
|
}else if(item instanceof ConfigurationPutRequest.TimezoneOffsetConfigItem) {
|
||||||
device.addDeviceInfo(new GenericItem(QHybridSupport.ITEM_TIMEZONE_OFFSET, String.valueOf(((ConfigurationPutRequest.TimezoneOffsetConfigItem) item).getValue())));
|
device.addDeviceInfo(new GenericItem(QHybridSupport.ITEM_TIMEZONE_OFFSET, String.valueOf(((ConfigurationPutRequest.TimezoneOffsetConfigItem) item).getValue())));
|
||||||
}else if(item instanceof ConfigurationPutRequest.BatteryConfigItem){
|
}else if(item instanceof ConfigurationPutRequest.BatteryConfigItem){
|
||||||
device.setBatteryLevel((short) ((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryPercentage());
|
device.setBatteryLevel((short) ((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryPercentage(), 0);
|
||||||
device.setBatteryVoltage(((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryVoltage() / 1000f);
|
device.setBatteryVoltage(((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryVoltage() / 1000f, 0);
|
||||||
|
|
||||||
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
||||||
batteryInfo.level = (short) ((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryPercentage();
|
batteryInfo.level = (short) ((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryPercentage();
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@ public class RoidmiSupport extends AbstractHeadphoneSerialDeviceSupportV2<Roidmi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mDeviceProtocol.supportsBatteryVoltage()) {
|
if (mDeviceProtocol.supportsBatteryVoltage()) {
|
||||||
if (getDevice().getBatteryVoltage() == -1) {
|
if (getDevice().getBatteryVoltage(0) == -1) {
|
||||||
infoMissing = true;
|
infoMissing = true;
|
||||||
|
|
||||||
builder.write(mDeviceProtocol.encodeGetVoltage());
|
builder.write(mDeviceProtocol.encodeGetVoltage());
|
||||||
|
|||||||
+2
-2
@@ -194,8 +194,8 @@ public class VescDeviceSupport extends VescBaseDeviceSupport {
|
|||||||
fullnessPercent = Math.max(fullnessPercent, 0);
|
fullnessPercent = Math.max(fullnessPercent, 0);
|
||||||
fullnessPercent = Math.min(fullnessPercent, 100);
|
fullnessPercent = Math.min(fullnessPercent, 100);
|
||||||
|
|
||||||
getDevice().setBatteryLevel(fullnessPercent);
|
getDevice().setBatteryLevel(fullnessPercent, 0);
|
||||||
getDevice().setBatteryVoltage(voltage);
|
getDevice().setBatteryVoltage(voltage, 0);
|
||||||
getDevice().sendDeviceUpdateIntent(getContext());
|
getDevice().sendDeviceUpdateIntent(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -275,7 +275,7 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
|||||||
int electricLevel = properties.getInt("electricLevel");
|
int electricLevel = properties.getInt("electricLevel");
|
||||||
if (electricLevel != this.electricLevel) {
|
if (electricLevel != this.electricLevel) {
|
||||||
this.electricLevel = electricLevel;
|
this.electricLevel = electricLevel;
|
||||||
getDevice().setBatteryLevel(electricLevel); // update event will be sent when firmware gets read
|
getDevice().setBatteryLevel(electricLevel, 0); // update event will be sent when firmware gets read
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (properties.has("MASTER")) {
|
if (properties.has("MASTER")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user