mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Amazfit Bip S: Attempt to fix reboot on notification without subject or body
This commit is contained in:
+15
-11
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user