added some logging

This commit is contained in:
dakhnod 2019-11-21 23:22:55 +01:00
parent d344bfa6da
commit e1aa88d22a
3 changed files with 68 additions and 56 deletions

View File

@ -57,6 +57,8 @@ import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem; import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
import nodomain.freeyourgadget.gadgetbridge.model.ItemWithDetails;
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.DeviceInfo;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.buttonconfig.ConfigPayload; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.buttonconfig.ConfigPayload;
@ -394,10 +396,18 @@ public class ConfigActivity extends AbstractGBActivity {
}); });
} }
final String buttonJson = device.getDeviceInfo(FossilWatchAdapter.ITEM_BUTTONS).getDetails(); ItemWithDetails buttonInfo = device.getDeviceInfo(FossilWatchAdapter.ITEM_BUTTONS);
if (buttonJson != null && !buttonJson.isEmpty()) {
try { try {
final JSONArray buttonConfig = new JSONArray(buttonJson); JSONArray buttonConfig = new JSONArray(new String[]{"Unknown", "Unknown", "Unknown"});
String buttonJson = null;
if (buttonInfo != null) {
buttonJson = buttonInfo.getDetails();
}
if (buttonJson != null && !buttonJson.isEmpty()) {
buttonConfig = new JSONArray(buttonJson);
}
final JSONArray finalButtonConfig = buttonConfig;
LinearLayout buttonLayout = findViewById(R.id.buttonConfigLayout); LinearLayout buttonLayout = findViewById(R.id.buttonConfigLayout);
buttonLayout.removeAllViews(); buttonLayout.removeAllViews();
findViewById(R.id.buttonOverwriteButtons).setVisibility(View.GONE); findViewById(R.id.buttonOverwriteButtons).setVisibility(View.GONE);
@ -427,10 +437,9 @@ public class ConfigActivity extends AbstractGBActivity {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dialog.cancel(); dialog.cancel();
ConfigPayload selected = payloads[which]; ConfigPayload selected = payloads[which];
try { try {
buttonConfig.put(currentIndex, selected.toString()); finalButtonConfig.put(currentIndex, selected.toString());
device.addDeviceInfo(new GenericItem(FossilWatchAdapter.ITEM_BUTTONS, buttonConfig.toString())); device.addDeviceInfo(new GenericItem(FossilWatchAdapter.ITEM_BUTTONS, finalButtonConfig.toString()));
updateSettings(); updateSettings();
LocalBroadcastManager.getInstance(ConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS)); LocalBroadcastManager.getInstance(ConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
} catch (JSONException e) { } catch (JSONException e) {
@ -446,10 +455,9 @@ public class ConfigActivity extends AbstractGBActivity {
buttonLayout.addView(buttonTextView); buttonLayout.addView(buttonTextView);
} }
} catch (JSONException e) { } catch (
JSONException e) {
e.printStackTrace(); e.printStackTrace();
GB.toast("error parsing button config", Toast.LENGTH_LONG, GB.ERROR);
}
} }
} }
}); });

View File

@ -447,6 +447,9 @@ public class FossilWatchAdapter extends WatchAdapter {
@Override @Override
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) { public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
super.onMtuChanged(gatt, mtu, status); super.onMtuChanged(gatt, mtu, status);
log("MTU changed: " + mtu);
this.MTU = mtu; this.MTU = mtu;
getDeviceSupport().getDevice().addDeviceInfo(new GenericItem(ITEM_MTU, String.valueOf(mtu))); getDeviceSupport().getDevice().addDeviceInfo(new GenericItem(ITEM_MTU, String.valueOf(mtu)));

View File

@ -4,9 +4,10 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem; import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileGetRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileLookupAndGetRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileLookupAndGetRequest;
public class ConfigurationGetRequest extends FileLookupAndGetRequest { public class ConfigurationGetRequest extends FileGetRequest {
public ConfigurationGetRequest(FossilWatchAdapter adapter) { public ConfigurationGetRequest(FossilWatchAdapter adapter) {
super((byte) 8, adapter); super((byte) 8, adapter);
} }