mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
Huawei: Fix notifications handling without key
This commit is contained in:
parent
87871a46e7
commit
4ccf68af0a
@ -55,7 +55,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -42,6 +42,12 @@ public class HuaweiNotificationsManager {
|
|||||||
notificationSpecCache.offer(notificationSpec);
|
notificationSpecCache.offer(notificationSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getNotificationKey(NotificationSpec notificationSpec) {
|
||||||
|
if(!TextUtils.isEmpty(notificationSpec.key)) {
|
||||||
|
return notificationSpec.key;
|
||||||
|
}
|
||||||
|
return "0|" + notificationSpec.sourceAppId + "|" + notificationSpec.getId() + "||0";
|
||||||
|
}
|
||||||
|
|
||||||
public void onNotification(NotificationSpec notificationSpec) {
|
public void onNotification(NotificationSpec notificationSpec) {
|
||||||
|
|
||||||
@ -79,7 +85,7 @@ public class HuaweiNotificationsManager {
|
|||||||
SendNotificationRemoveRequest sendNotificationReq = new SendNotificationRemoveRequest(this.support,
|
SendNotificationRemoveRequest sendNotificationReq = new SendNotificationRemoveRequest(this.support,
|
||||||
SendNotificationRequest.getNotificationType(notificationSpec.type), // notificationType
|
SendNotificationRequest.getNotificationType(notificationSpec.type), // notificationType
|
||||||
notificationSpec.sourceAppId,
|
notificationSpec.sourceAppId,
|
||||||
notificationSpec.key,
|
getNotificationKey(notificationSpec),
|
||||||
id,
|
id,
|
||||||
notificationSpec.channelId,
|
notificationSpec.channelId,
|
||||||
notificationSpec.category);
|
notificationSpec.category);
|
||||||
@ -105,8 +111,8 @@ public class HuaweiNotificationsManager {
|
|||||||
}
|
}
|
||||||
NotificationSpec notificationSpec = null;
|
NotificationSpec notificationSpec = null;
|
||||||
for (NotificationSpec spec : notificationSpecCache) {
|
for (NotificationSpec spec : notificationSpecCache) {
|
||||||
notificationSpec = spec;
|
if (getNotificationKey(spec).equals(response.key)) {
|
||||||
if (notificationSpec.key.equals(response.key)) {
|
notificationSpec = spec;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import static nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiNotificationsManager.getNotificationKey;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -31,7 +31,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||||
|
|
||||||
public class SendNotificationRequest extends Request {
|
public class SendNotificationRequest extends Request {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(SendNotificationRequest.class);
|
private static final Logger LOG = LoggerFactory.getLogger(SendNotificationRequest.class);
|
||||||
|
|
||||||
private HuaweiPacket packet;
|
private HuaweiPacket packet;
|
||||||
@ -54,8 +53,7 @@ public class SendNotificationRequest extends Request {
|
|||||||
return Notifications.NotificationType.sms;
|
return Notifications.NotificationType.sms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void buildNotificationTLVFromNotificationSpec(NotificationSpec notificationSpec) {
|
public void buildNotificationTLVFromNotificationSpec(NotificationSpec notificationSpec) {
|
||||||
String title;
|
String title;
|
||||||
if (notificationSpec.title != null)
|
if (notificationSpec.title != null)
|
||||||
@ -76,7 +74,7 @@ public class SendNotificationRequest extends Request {
|
|||||||
final NotificationSpec.Action action = notificationSpec.attachedActions.get(i);
|
final NotificationSpec.Action action = notificationSpec.attachedActions.get(i);
|
||||||
if (action.type == NotificationSpec.Action.TYPE_WEARABLE_REPLY || action.type == NotificationSpec.Action.TYPE_SYNTECTIC_REPLY_PHONENR) {
|
if (action.type == NotificationSpec.Action.TYPE_WEARABLE_REPLY || action.type == NotificationSpec.Action.TYPE_SYNTECTIC_REPLY_PHONENR) {
|
||||||
//NOTE: store notification key instead action key. The watch returns this key so it is more easier to find action by notification key
|
//NOTE: store notification key instead action key. The watch returns this key so it is more easier to find action by notification key
|
||||||
replyKey = notificationSpec.key;
|
replyKey = getNotificationKey(notificationSpec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +89,7 @@ public class SendNotificationRequest extends Request {
|
|||||||
params.supportsTimestamp = supportProvider.getHuaweiCoordinator().supportsNotificationsTimestamp();
|
params.supportsTimestamp = supportProvider.getHuaweiCoordinator().supportsNotificationsTimestamp();
|
||||||
|
|
||||||
params.notificationId = notificationSpec.getId();
|
params.notificationId = notificationSpec.getId();
|
||||||
params.notificationKey = notificationSpec.key;
|
params.notificationKey = getNotificationKey(notificationSpec);
|
||||||
params.replyKey = replyKey;
|
params.replyKey = replyKey;
|
||||||
params.channelId = notificationSpec.channelId;
|
params.channelId = notificationSpec.channelId;
|
||||||
params.category = notificationSpec.category;
|
params.category = notificationSpec.category;
|
||||||
|
Loading…
Reference in New Issue
Block a user