Amazfit Bip S: Attempt to fix reboot on notification without subject or body

This commit is contained in:
José Rebelo
2026-05-17 16:23:38 +01:00
parent 3fe42f3d8f
commit 09022454b8
@@ -893,23 +893,27 @@ public abstract class HuamiSupport extends AbstractBTLESingleDeviceSupport
* @return * @return
*/ */
public String getNotificationBody(NotificationSpec notificationSpec) { public String getNotificationBody(NotificationSpec notificationSpec) {
String senderOrTitle = StringUtils.getFirstOf(notificationSpec.sender, notificationSpec.title); final StringBuilder sb = new StringBuilder();
if (senderOrTitle.isEmpty()) { final String senderOrTitle = StringUtils.getFirstOf(notificationSpec.sender, notificationSpec.title);
if (!senderOrTitle.isEmpty()) {
sb.append(StringUtils.truncate(senderOrTitle, 32));
} else {
// if we have no title we have to send at least something on some devices, else they reboot (Bip S) // if we have no title we have to send at least something on some devices, else they reboot (Bip S)
senderOrTitle = " "; sb.append(" ");
} }
String message = StringUtils.truncate(senderOrTitle, 32) + "\0"; sb.append("\0");
if (notificationSpec.subject != null) { if (!StringUtils.isNullOrEmpty(notificationSpec.subject)) {
message += StringUtils.truncate(notificationSpec.subject, 128) + "\n\n"; sb.append(StringUtils.truncate(notificationSpec.subject, 128)).append("\n\n");
} }
if (notificationSpec.body != null) { if (!StringUtils.isNullOrEmpty(notificationSpec.body)) {
message += StringUtils.truncate(notificationSpec.body, 512); sb.append(StringUtils.truncate(notificationSpec.body, 512)).append("\n\n");
} }
if (notificationSpec.body == null && notificationSpec.subject == null) { if (StringUtils.isNullOrEmpty(notificationSpec.subject) && StringUtils.isNullOrEmpty(notificationSpec.body)) {
message += " "; // if we have no body we have to send at least something on some devices, else they reboot (Bip S) // if we have no body we have to send at least something on some devices, else they reboot (Bip S)
sb.append(" ");
} }
return message; return sb.toString();
} }
/** /**