mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-10 12:09:27 +01:00
Pebble: add dev option to force latest notification protocol usage
When enabled it forces to use 3.x notifications on FW 3.x (2.x notifcations on FW 2.x) When disabled 2.x notification on FW 2.x and 1.x notifications on FW 2.x are used (which is recommended) This allows Pebble Time users to do further tests.
This commit is contained in:
parent
e562fa9870
commit
7e1700250f
@ -115,6 +115,10 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||
mBtSocket = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
mPebbleProtocol.setForceProtocol(sharedPrefs.getBoolean("pebble_force_protocol", false));
|
||||
|
||||
gbDevice.setState(GBDevice.State.CONNECTED);
|
||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||
|
||||
|
@ -165,6 +165,8 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
private static Random mRandom = new Random();
|
||||
|
||||
boolean isFw3x = false;
|
||||
boolean mForceProtocol = false;
|
||||
|
||||
byte last_id = -1;
|
||||
private ArrayList<UUID> tmpUUIDS = new ArrayList<>();
|
||||
|
||||
@ -221,13 +223,16 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
ts += (SimpleTimeZone.getDefault().getOffset(ts));
|
||||
ts /= 1000;
|
||||
|
||||
if (isFw3x) {
|
||||
if (isFw3x && mForceProtocol) {
|
||||
String[] parts = {from, null, body};
|
||||
return encodeBlobdbNotification((int) (ts & 0xffffffff), parts);
|
||||
} else {
|
||||
} else if (!isFw3x && !mForceProtocol) {
|
||||
String[] parts = {from, body, ts.toString()};
|
||||
return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_SMS, 0, parts);
|
||||
}
|
||||
|
||||
String[] parts = {from, null, body};
|
||||
return encodeExtensibleNotification(mRandom.nextInt(), (int) (ts & 0xffffffff), parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,13 +241,16 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
ts += (SimpleTimeZone.getDefault().getOffset(ts));
|
||||
ts /= 1000;
|
||||
|
||||
if (isFw3x) {
|
||||
if (isFw3x && mForceProtocol) {
|
||||
String[] parts = {from, subject, body};
|
||||
return encodeBlobdbNotification((int) (ts & 0xffffffff), parts);
|
||||
} else {
|
||||
} 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
|
||||
@ -913,4 +921,9 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public void setForceProtocol(boolean force) {
|
||||
LOG.info("setting force protocol to " + force);
|
||||
mForceProtocol = force;
|
||||
}
|
||||
}
|
||||
|
@ -93,4 +93,5 @@
|
||||
<string name="pref_header_vibration_count">Anzahl der Vibrationen</string>
|
||||
<string name="pref_write_logfiles">Log-Dateien schreiben (Neustart erforderlich)</string>
|
||||
<string name="title_activity_sleepmonitor">Schlafmonitor</string>
|
||||
<string name="pref_title_pebble_settings">Pebble Einstellungen</string>
|
||||
</resources>
|
||||
|
@ -42,6 +42,10 @@
|
||||
<string name="pref_header_development">Developer Options</string>
|
||||
<string name="pref_title_development_miaddr">Mi Band address</string>
|
||||
|
||||
<string name="pref_title_pebble_settings">Pebble Settings</string>
|
||||
<string name="pref_title_pebble_forceprotocol">Force Notification Protocol</string>
|
||||
<string name="pref_summary_pebble_forceprotocol">This option forces using the latest notification protocol depending on the firmware version. ENABLE ONLY IF YOU KNOW WHAT YOU ARE DOING!</string>
|
||||
|
||||
|
||||
<string name="not_connected">not connected</string>
|
||||
<string name="connecting">connecting</string>
|
||||
|
@ -59,6 +59,19 @@
|
||||
<Preference
|
||||
android:key="pref_key_miband"
|
||||
android:title="@string/preferences_miband_settings" />
|
||||
<PreferenceScreen
|
||||
android:key="pref_key_pebble"
|
||||
android:title="@string/pref_title_pebble_settings" >
|
||||
<PreferenceCategory
|
||||
android:key="pref_key_development"
|
||||
android:title="@string/pref_header_development">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_force_protocol"
|
||||
android:title="@string/pref_title_pebble_forceprotocol"
|
||||
android:summary="@string/pref_summary_pebble_forceprotocol" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
Loading…
Reference in New Issue
Block a user