Logging to find the cause for seldom device state/notification mismatch

master
cpfeiffer 2015-07-10 21:35:28 +02:00
parent 40be935abd
commit 7c61bbb2be
4 changed files with 43 additions and 4 deletions

View File

@ -1,5 +1,9 @@
###Changelog
####Version 0.4.4
* Support for backup up and restoring of the activity database (via Debug activity)
* Support for graceful upgrades and downgrades, keeping your activity database intact
####Version 0.4.3
* Mi Band: Support for setting alarms
* Mi Band: Bugfix for activity data synchronization

View File

@ -78,12 +78,14 @@ public class BluetoothCommunicationService extends Service {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
GBDevice device = intent.getParcelableExtra("device");
GBDevice device = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
if (mGBDevice.equals(device)) {
mGBDevice = device;
boolean enableReceivers = mDeviceSupport != null && (mDeviceSupport.useAutoConnect() || mGBDevice.isConnected());
GB.setReceiversEnableState(enableReceivers, context);
GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), context);
} else {
LOG.error("Got ACTION_DEVICE_CHANGED from unexpected device: " + mGBDevice);
}
}
}

View File

@ -243,12 +243,12 @@ public class GBDevice implements Parcelable {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof GBDevice)) {
return false;
}
if (obj == this) {
return true;
}
if (!(obj instanceof GBDevice)) {
return false;
}
if (((GBDevice) obj).getAddress().equals(this.mAddress)) {
return true;
}
@ -288,6 +288,11 @@ public class GBDevice implements Parcelable {
mBatteryState = batteryState;
}
@Override
public String toString() {
return "Device " + getName() + ", " + getAddress() + ", " + getStateString();
}
public enum State {
// Note: the order is important!
NOT_CONNECTED,

View File

@ -0,0 +1,28 @@
package nodomain.freeyourgadget.gadgetbridge.database.schema;
import android.database.sqlite.SQLiteDatabase;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.database.DBUpdateScript;
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.*;
/**
* Adds a table "STEPS_PER_DAY".
*/
public class ActivityDBUpdate_6 implements DBUpdateScript {
@Override
public void upgradeSchema(SQLiteDatabase db) {
String CREATE_STEPS_PER_DAY_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_STEPS_PER_DAY + " ("
+ KEY_TIMESTAMP + " INT,"
+ KEY_PROVIDER + " TINYINT,"
+ KEY_STEPS + " TINYINT,"
+ " PRIMARY KEY (" + KEY_TIMESTAMP + "," + KEY_PROVIDER + ") ON CONFLICT REPLACE)" + DBHelper.getWithoutRowId();
db.execSQL(CREATE_STEPS_PER_DAY_TABLE);
}
@Override
public void downgradeSchema(SQLiteDatabase db) {
DBHelper.dropTable(TABLE_STEPS_PER_DAY, db);
}
}