Pebble: always force 3.x notifications on FW 3.x

live-activity-data
Andreas Shimokawa 2015-07-19 00:26:43 +02:00
parent e6bc406d98
commit f847d834af
1 changed files with 18 additions and 24 deletions

View File

@ -233,45 +233,39 @@ public class PebbleProtocol extends GBDeviceProtocol {
return buf.array(); return buf.array();
} }
@Override private byte[] encodeNotification(int id, String title, String subtitle, String body, byte type) {
public byte[] encodeSMS(String from, String body) {
Long ts = System.currentTimeMillis(); Long ts = System.currentTimeMillis();
ts += (SimpleTimeZone.getDefault().getOffset(ts)); ts += (SimpleTimeZone.getDefault().getOffset(ts));
ts /= 1000; ts /= 1000;
if (isFw3x && mForceProtocol) { if (isFw3x) {
String[] parts = {from, null, body}; // 3.x notification
String[] parts = {title, subtitle, body};
return encodeBlobdbNotification((int) (ts & 0xffffffff), parts); return encodeBlobdbNotification((int) (ts & 0xffffffff), parts);
} else if (!isFw3x && !mForceProtocol) { } else if (mForceProtocol) {
String[] parts = {from, body, ts.toString()}; // 2.x notification
return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_SMS, 0, parts); String[] parts = {title, subtitle, body};
return encodeExtensibleNotification(id, (int) (ts & 0xffffffff), parts);
} else {
// 1.x notification on FW 2.X
String[] parts = {title, body, ts.toString(), subtitle};
return encodeMessage(ENDPOINT_NOTIFICATION, type, 0, parts);
} }
}
String[] parts = {from, null, body}; @Override
return encodeExtensibleNotification(mRandom.nextInt(), (int) (ts & 0xffffffff), parts); public byte[] encodeSMS(String from, String body) {
return encodeNotification(mRandom.nextInt(), from, null, body, NOTIFICATION_SMS);
} }
@Override @Override
public byte[] encodeEmail(String from, String subject, String body) { public byte[] encodeEmail(String from, String subject, String body) {
Long ts = System.currentTimeMillis(); return encodeNotification(mRandom.nextInt(), from, subject, body, NOTIFICATION_EMAIL);
ts += (SimpleTimeZone.getDefault().getOffset(ts));
ts /= 1000;
if (isFw3x && mForceProtocol) {
String[] parts = {from, subject, body};
return encodeBlobdbNotification((int) (ts & 0xffffffff), parts);
} else if (!isFw3x && !mForceProtocol) {
String[] parts = {from, body, ts.toString(), subject};
return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_EMAIL, 0, parts);
}
String[] parts = {from, subject, body};
return encodeExtensibleNotification(mRandom.nextInt(), (int) (ts & 0xffffffff), parts);
} }
@Override @Override
public byte[] encodeGenericNotification(String title, String details) { public byte[] encodeGenericNotification(String title, String details) {
return encodeSMS(title, details); return encodeNotification(mRandom.nextInt(), title, null, details, NOTIFICATION_SMS);
} }
@Override @Override