mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-03-13 17:50:23 +01:00
Huawei: More information before firmware installation
This commit is contained in:
parent
756d3b2fea
commit
b4dc1d2358
app/src/main
java/nodomain/freeyourgadget/gadgetbridge/devices/huawei
res/values
@ -54,11 +54,11 @@ public class HuaweiInstallHandler implements InstallHandler {
|
|||||||
|
|
||||||
private HuaweiMusicUtils.FormatRestrictions getRestriction(HuaweiMusicUtils.MusicCapabilities capabilities, String ext) {
|
private HuaweiMusicUtils.FormatRestrictions getRestriction(HuaweiMusicUtils.MusicCapabilities capabilities, String ext) {
|
||||||
List<HuaweiMusicUtils.FormatRestrictions> restrictions = capabilities.formatsRestrictions;
|
List<HuaweiMusicUtils.FormatRestrictions> restrictions = capabilities.formatsRestrictions;
|
||||||
if(restrictions == null)
|
if (restrictions == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for(HuaweiMusicUtils.FormatRestrictions r: restrictions) {
|
for (HuaweiMusicUtils.FormatRestrictions r : restrictions) {
|
||||||
if(ext.equals(r.getName())) {
|
if (ext.equals(r.getName())) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,24 +67,24 @@ public class HuaweiInstallHandler implements InstallHandler {
|
|||||||
|
|
||||||
//TODO: add proper checks
|
//TODO: add proper checks
|
||||||
private boolean checkMediaCompatibility(HuaweiMusicUtils.MusicCapabilities capabilities, HuaweiMusicManager.AudioInfo currentMusicInfo) {
|
private boolean checkMediaCompatibility(HuaweiMusicUtils.MusicCapabilities capabilities, HuaweiMusicManager.AudioInfo currentMusicInfo) {
|
||||||
if(capabilities == null) {
|
if (capabilities == null) {
|
||||||
LOG.error("No media info from device");
|
LOG.error("No media info from device");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String ext = currentMusicInfo.getExtension();
|
String ext = currentMusicInfo.getExtension();
|
||||||
|
|
||||||
List<String> supportedFormats = capabilities.supportedFormats;
|
List<String> supportedFormats = capabilities.supportedFormats;
|
||||||
if(supportedFormats == null) {
|
if (supportedFormats == null) {
|
||||||
LOG.error("Format not supported {}", ext);
|
LOG.error("Format not supported {}", ext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!supportedFormats.contains(ext)) {
|
if (!supportedFormats.contains(ext)) {
|
||||||
LOG.error("Format not supported {}", ext);
|
LOG.error("Format not supported {}", ext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HuaweiMusicUtils.FormatRestrictions restrictions = getRestriction(capabilities, ext);
|
HuaweiMusicUtils.FormatRestrictions restrictions = getRestriction(capabilities, ext);
|
||||||
if(restrictions == null) {
|
if (restrictions == null) {
|
||||||
LOG.info("no restriction for: {}", ext);
|
LOG.info("no restriction for: {}", ext);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ public class HuaweiInstallHandler implements InstallHandler {
|
|||||||
LOG.info("sampleRate {}", Arrays.toString(restrictions.sampleRates));
|
LOG.info("sampleRate {}", Arrays.toString(restrictions.sampleRates));
|
||||||
LOG.info("unknownBitrate {}", restrictions.unknownBitrate);
|
LOG.info("unknownBitrate {}", restrictions.unknownBitrate);
|
||||||
|
|
||||||
if(currentMusicInfo.getChannels() > restrictions.channels) {
|
if (currentMusicInfo.getChannels() > restrictions.channels) {
|
||||||
LOG.error("Not supported channels count {} > {}", currentMusicInfo.getChannels(), restrictions.channels);
|
LOG.error("Not supported channels count {} > {}", currentMusicInfo.getChannels(), restrictions.channels);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -116,24 +116,17 @@ public class HuaweiInstallHandler implements InstallHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(helper.isFirmware) {
|
if (helper.isFirmware) {
|
||||||
this.valid = true; //NOTE: nothing to verify for now
|
this.valid = true; //NOTE: nothing to verify for now
|
||||||
|
|
||||||
installActivity.setInstallEnabled(true);
|
|
||||||
|
|
||||||
GenericItem installItem = new GenericItem();
|
|
||||||
|
|
||||||
installItem.setName(helper.fwInfo.versionName);
|
|
||||||
installActivity.setInstallItem(installItem);
|
|
||||||
if (device.isBusy()) {
|
if (device.isBusy()) {
|
||||||
LOG.error("Firmware cannot be uploaded (device busy)");
|
LOG.error("Firmware cannot be uploaded (device busy)");
|
||||||
installActivity.setInfoText("Firmware cannot be uploaded (device busy)");
|
installActivity.setInfoText("Firmware cannot be uploaded (device busy)");
|
||||||
installActivity.setInfoText(device.getBusyTask());
|
|
||||||
installActivity.setInstallEnabled(false);
|
installActivity.setInstallEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device.isConnected()) {
|
if (!device.isConnected() || !device.isInitialized()) {
|
||||||
LOG.error("Firmware cannot be uploaded(not connected or wrong device)");
|
LOG.error("Firmware cannot be uploaded(not connected or wrong device)");
|
||||||
installActivity.setInfoText("Firmware cannot be uploaded (not connected or wrong device)");
|
installActivity.setInfoText("Firmware cannot be uploaded (not connected or wrong device)");
|
||||||
installActivity.setInstallEnabled(false);
|
installActivity.setInstallEnabled(false);
|
||||||
@ -146,11 +139,20 @@ public class HuaweiInstallHandler implements InstallHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//installItem.setDetails(config.version);
|
GenericItem installItem = new GenericItem();
|
||||||
|
|
||||||
|
installItem.setName(helper.fwInfo.versionName);
|
||||||
|
|
||||||
|
installItem.setDetails(helper.fwInfo.osVersion);
|
||||||
|
|
||||||
installItem.setIcon(R.drawable.ic_firmware);
|
installItem.setIcon(R.drawable.ic_firmware);
|
||||||
|
|
||||||
//installActivity.setInfoText(context.getString(R.string.app_install_info, installItem.getName(), config.version, config.vendor));
|
installActivity.setInstallItem(installItem);
|
||||||
|
|
||||||
|
installActivity.setInfoText(context.getString(R.string.fw_upgrade_notice_huawei, helper.fwInfo.versionName, device.getAliasOrName(), device.getFirmwareVersion()));
|
||||||
|
|
||||||
|
installActivity.setInstallEnabled(true);
|
||||||
|
|
||||||
|
|
||||||
LOG.debug("Initialized HuaweiInstallHandler: Firmware");
|
LOG.debug("Initialized HuaweiInstallHandler: Firmware");
|
||||||
return;
|
return;
|
||||||
@ -252,7 +254,7 @@ public class HuaweiInstallHandler implements InstallHandler {
|
|||||||
final HuaweiCoordinatorSupplier huaweiCoordinatorSupplier = (HuaweiCoordinatorSupplier) coordinator;
|
final HuaweiCoordinatorSupplier huaweiCoordinatorSupplier = (HuaweiCoordinatorSupplier) coordinator;
|
||||||
|
|
||||||
HuaweiMusicUtils.MusicCapabilities capabilities = huaweiCoordinatorSupplier.getHuaweiCoordinator().getExtendedMusicInfoParams();
|
HuaweiMusicUtils.MusicCapabilities capabilities = huaweiCoordinatorSupplier.getHuaweiCoordinator().getExtendedMusicInfoParams();
|
||||||
if(capabilities == null) {
|
if (capabilities == null) {
|
||||||
capabilities = huaweiCoordinatorSupplier.getHuaweiCoordinator().getMusicInfoParams();
|
capabilities = huaweiCoordinatorSupplier.getHuaweiCoordinator().getMusicInfoParams();
|
||||||
}
|
}
|
||||||
HuaweiMusicManager.AudioInfo currentMusicInfo = helper.getMusicInfo();
|
HuaweiMusicManager.AudioInfo currentMusicInfo = helper.getMusicInfo();
|
||||||
|
@ -29,6 +29,7 @@ public class HuaweiOTAFileList {
|
|||||||
public long size;
|
public long size;
|
||||||
public String packageName;
|
public String packageName;
|
||||||
public String versionName;
|
public String versionName;
|
||||||
|
public String osVersion;
|
||||||
public int versionCode;
|
public int versionCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +71,10 @@ public class HuaweiOTAFileList {
|
|||||||
info.size = Long.parseLong(elem.getElementsByTagName("size").item(0).getTextContent());
|
info.size = Long.parseLong(elem.getElementsByTagName("size").item(0).getTextContent());
|
||||||
info.packageName = elem.getElementsByTagName("packageName").item(0).getTextContent();
|
info.packageName = elem.getElementsByTagName("packageName").item(0).getTextContent();
|
||||||
info.versionName = elem.getElementsByTagName("versionName").item(0).getTextContent();
|
info.versionName = elem.getElementsByTagName("versionName").item(0).getTextContent();
|
||||||
|
NodeList osVerNodes = elem.getElementsByTagName("osVersion");
|
||||||
|
if(osVerNodes.getLength() > 0) {
|
||||||
|
info.osVersion = osVerNodes.item(0).getTextContent();
|
||||||
|
}
|
||||||
info.versionCode = Integer.parseInt(elem.getElementsByTagName("versionCode").item(0).getTextContent());
|
info.versionCode = Integer.parseInt(elem.getElementsByTagName("versionCode").item(0).getTextContent());
|
||||||
|
|
||||||
ret.files.add(info);
|
ret.files.add(info);
|
||||||
|
@ -176,6 +176,7 @@
|
|||||||
\n
|
\n
|
||||||
\nPROCEED AT YOUR OWN RISK!</string>
|
\nPROCEED AT YOUR OWN RISK!</string>
|
||||||
<string name="fw_multi_upgrade_notice">You are about to install the %1$s and %2$s firmware, instead of the ones currently on your Mi Band.</string>
|
<string name="fw_multi_upgrade_notice">You are about to install the %1$s and %2$s firmware, instead of the ones currently on your Mi Band.</string>
|
||||||
|
<string name="fw_upgrade_notice_huawei">You are about to upload the %s firmware on your %s.\n\nYour current firmware is %s\n\nYour device will reboot after uploading.\n\nPROCEED AT YOUR OWN RISK!</string>
|
||||||
<string name="miband_firmware_known">This firmware has been tested and is known to be compatible with Gadgetbridge.</string>
|
<string name="miband_firmware_known">This firmware has been tested and is known to be compatible with Gadgetbridge.</string>
|
||||||
<string name="miband_firmware_unknown_warning">"This firmware is untested and may not be compatible with Gadgetbridge.\n\nYou are DISCOURAGED from flashing it!"</string>
|
<string name="miband_firmware_unknown_warning">"This firmware is untested and may not be compatible with Gadgetbridge.\n\nYou are DISCOURAGED from flashing it!"</string>
|
||||||
<string name="miband_firmware_suggest_whitelist">If you still want to proceed and things continue to work properly afterwards, please tell the Gadgetbridge developers to whitelist the %s firmware version.</string>
|
<string name="miband_firmware_suggest_whitelist">If you still want to proceed and things continue to work properly afterwards, please tell the Gadgetbridge developers to whitelist the %s firmware version.</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user