Set default low battery threshold for Sony devices

At least WF-C700N and WF-C510 only support the battery levels 0%, 20%, 50%, 70% and 100%
This commit is contained in:
Marcel 2024-12-27 12:24:36 +01:00
parent b00248ce45
commit 7f439f2a03
2 changed files with 13 additions and 5 deletions

View File

@ -97,16 +97,16 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
final List<BatteryConfig> batteries = new ArrayList<>(3); final List<BatteryConfig> batteries = new ArrayList<>(3);
if (supports(SonyHeadphonesCapabilities.BatterySingle)) { if (supports(SonyHeadphonesCapabilities.BatterySingle)) {
batteries.add(new BatteryConfig(batteries.size())); batteries.add(new BatteryConfig(batteries.size(), GBDevice.BATTERY_ICON_DEFAULT, GBDevice.BATTERY_LABEL_DEFAULT, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
} }
if (supports(SonyHeadphonesCapabilities.BatteryCase)) { if (supports(SonyHeadphonesCapabilities.BatteryCase)) {
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_tws_case, R.string.battery_case)); batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_tws_case, R.string.battery_case, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
} }
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) { if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_l, R.string.left_earbud)); batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_l, R.string.left_earbud, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_r, R.string.right_earbud)); batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_r, R.string.right_earbud, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
} }
return batteries.toArray(new BatteryConfig[0]); return batteries.toArray(new BatteryConfig[0]);
@ -216,6 +216,14 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
return false; return false;
} }
public int getBatteryDefaultLowThreshold() {
return 20;
}
public int getBatteryDefaultFullThreshold() {
return 100;
}
@NonNull @NonNull
@Override @Override
public Class<? extends DeviceSupport> getDeviceSupportClass() { public Class<? extends DeviceSupport> getDeviceSupportClass() {

View File

@ -28,7 +28,7 @@ public class SonyWFC700NCoordinator extends SonyHeadphonesCoordinator {
@Override @Override
protected Pattern getSupportedDeviceName() { protected Pattern getSupportedDeviceName() {
return Pattern.compile(".*WF-C700N.*"); return Pattern.compile("WF-C700N");
} }
@Override @Override