convert byte and short values related to activity tracking to int
This avoids a lot of problems because java - does not know unsigned values - jvm and dalvic do not internally support byte and short - sqlite does not know them either
This commit is contained in:
parent
c4dc972804
commit
ed85fd5011
|
@ -261,26 +261,26 @@ public class GBApplication extends Application {
|
|||
|
||||
private void migratePrefs(int oldVersion) {
|
||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
||||
switch (oldVersion) {
|
||||
switch (oldVersion) {
|
||||
case 0:
|
||||
String legacyGender = sharedPrefs.getString("mi_user_gender", null);
|
||||
String legacyHeight = sharedPrefs.getString("mi_user_height_cm", null);
|
||||
String legacyWeigth = sharedPrefs.getString("mi_user_weight_kg", null);
|
||||
String legacyYOB = sharedPrefs.getString("mi_user_year_of_birth",null);
|
||||
if(legacyGender != null) {
|
||||
String legacyYOB = sharedPrefs.getString("mi_user_year_of_birth", null);
|
||||
if (legacyGender != null) {
|
||||
int gender = "male".equals(legacyGender) ? 1 : "female".equals(legacyGender) ? 0 : 2;
|
||||
editor.putString(ActivityUser.PREF_USER_GENDER, Integer.toString(gender));
|
||||
editor.remove("mi_user_gender");
|
||||
}
|
||||
if(legacyHeight != null) {
|
||||
if (legacyHeight != null) {
|
||||
editor.putString(ActivityUser.PREF_USER_HEIGHT_CM, legacyHeight);
|
||||
editor.remove("mi_user_height_cm");
|
||||
}
|
||||
if(legacyWeigth != null) {
|
||||
if (legacyWeigth != null) {
|
||||
editor.putString(ActivityUser.PREF_USER_WEIGHT_KG, legacyWeigth);
|
||||
editor.remove("mi_user_weight_kg");
|
||||
}
|
||||
if(legacyYOB != null) {
|
||||
if (legacyYOB != null) {
|
||||
editor.putString(ActivityUser.PREF_USER_YEAR_OF_BIRTH, legacyYOB);
|
||||
editor.remove("mi_user_year_of_birth");
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.view.View;
|
|||
|
||||
import com.github.mikephil.charting.charts.BarLineChartBase;
|
||||
import com.github.mikephil.charting.charts.Chart;
|
||||
import com.github.mikephil.charting.charts.CombinedChart;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
|
@ -29,7 +28,6 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashSet;
|
||||
|
@ -86,6 +84,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||
}
|
||||
|
||||
public abstract String getTitle();
|
||||
|
||||
public boolean supportsHeartrate() {
|
||||
return supportsHeartrateChart;
|
||||
}
|
||||
|
@ -166,7 +165,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||
protected ChartsHost getChartsHost() {
|
||||
return (ChartsHost) getActivity();
|
||||
}
|
||||
|
||||
|
||||
private void setEndDate(Date date) {
|
||||
getChartsHost().setEndDate(date);
|
||||
}
|
||||
|
@ -447,7 +446,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||
}
|
||||
activityEntries.add(createBarEntry(value, i));
|
||||
if (hr) {
|
||||
heartrateEntries.add(createLineEntry(sample.getCustomShortValue(), i));
|
||||
heartrateEntries.add(createLineEntry(sample.getCustomValue(), i));
|
||||
}
|
||||
|
||||
String xLabel = "";
|
||||
|
|
|
@ -49,6 +49,7 @@ public class CustomBarChart extends BarChart {
|
|||
/**
|
||||
* Call this to set the next value for the Entry to be animated.
|
||||
* Call animateY() when ready to do that.
|
||||
*
|
||||
* @param nextValue
|
||||
*/
|
||||
public void setSingleEntryYValue(float nextValue) {
|
||||
|
|
|
@ -315,9 +315,9 @@ public class LiveActivityFragment extends AbstractChartFragment {
|
|||
List<String> xLabels = new ArrayList<>();
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
|
||||
entries.add(new BarEntry(0,0));
|
||||
entries.add(new BarEntry(0, 0));
|
||||
entries.add(entry);
|
||||
entries.add(new BarEntry(0,2));
|
||||
entries.add(new BarEntry(0, 2));
|
||||
colors.add(akActivity.color);
|
||||
colors.add(akActivity.color);
|
||||
colors.add(akActivity.color);
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.BarLineChartBase;
|
||||
import com.github.mikephil.charting.charts.Chart;
|
||||
import com.github.mikephil.charting.charts.CombinedChart;
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarLineChartBase;
|
||||
import com.github.mikephil.charting.charts.Chart;
|
||||
import com.github.mikephil.charting.charts.CombinedChart;
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
|
|
|
@ -22,15 +22,15 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
|||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.DATABASE_NAME;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_CUSTOM_SHORT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_INTENSITY;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_PROVIDER;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_STEPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_TIMESTAMP;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_TYPE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_CUSTOM_SHORT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_GBACTIVITYSAMPLES;
|
||||
|
||||
public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHandler {
|
||||
public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHandler {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ActivityDatabaseHandler.class);
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHa
|
|||
values.put(KEY_PROVIDER, sample.getProvider().getID());
|
||||
values.put(KEY_INTENSITY, sample.getRawIntensity());
|
||||
values.put(KEY_STEPS, sample.getSteps());
|
||||
values.put(KEY_CUSTOM_SHORT, sample.getCustomShortValue());
|
||||
values.put(KEY_CUSTOM_SHORT, sample.getCustomValue());
|
||||
values.put(KEY_TYPE, sample.getRawKind());
|
||||
|
||||
db.insert(TABLE_GBACTIVITYSAMPLES, null, values);
|
||||
|
@ -112,14 +112,15 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHa
|
|||
/**
|
||||
* Adds the a new sample to the database
|
||||
*
|
||||
* @param timestamp the timestamp of the same, second-based!
|
||||
* @param provider the SampleProvider ID
|
||||
* @param intensity the sample's raw intensity value
|
||||
* @param steps the sample's steps value
|
||||
* @param kind the raw activity kind of the sample
|
||||
* @param timestamp the timestamp of the same, second-based!
|
||||
* @param provider the SampleProvider ID
|
||||
* @param intensity the sample's raw intensity value
|
||||
* @param steps the sample's steps value
|
||||
* @param kind the raw activity kind of the sample
|
||||
* @param customShortValue
|
||||
*/
|
||||
@Override
|
||||
public void addGBActivitySample(int timestamp, byte provider, short intensity, short steps, byte kind, short customShortValue) {
|
||||
public void addGBActivitySample(int timestamp, int provider, int intensity, int steps, int kind, int customShortValue) {
|
||||
if (intensity < 0) {
|
||||
LOG.error("negative intensity received, ignoring");
|
||||
intensity = 0;
|
||||
|
@ -164,7 +165,7 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHa
|
|||
statement.bindLong(3, activitySample.getRawIntensity());
|
||||
statement.bindLong(4, activitySample.getSteps());
|
||||
statement.bindLong(5, activitySample.getRawKind());
|
||||
statement.bindLong(6, activitySample.getCustomShortValue());
|
||||
statement.bindLong(6, activitySample.getCustomValue());
|
||||
statement.execute();
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
|
@ -242,7 +243,7 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHa
|
|||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder(" and (");
|
||||
byte[] dbActivityTypes = ActivityKind.mapToDBActivityTypes(activityTypes, provider);
|
||||
int[] dbActivityTypes = ActivityKind.mapToDBActivityTypes(activityTypes, provider);
|
||||
for (int i = 0; i < dbActivityTypes.length; i++) {
|
||||
builder.append(" type=").append(dbActivityTypes[i]);
|
||||
if (i + 1 < dbActivityTypes.length) {
|
||||
|
@ -254,7 +255,7 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHa
|
|||
}
|
||||
|
||||
@Override
|
||||
public void changeStoredSamplesType(int timestampFrom, int timestampTo, byte kind, SampleProvider provider) {
|
||||
public void changeStoredSamplesType(int timestampFrom, int timestampTo, int kind, SampleProvider provider) {
|
||||
try (SQLiteDatabase db = this.getReadableDatabase()) {
|
||||
String sql = "UPDATE " + TABLE_GBACTIVITYSAMPLES + " SET " + KEY_TYPE + "= ? WHERE "
|
||||
+ KEY_PROVIDER + " = ? AND "
|
||||
|
|
|
@ -24,13 +24,13 @@ public interface DBHandler {
|
|||
|
||||
List<ActivitySample> getSleepSamples(int tsFrom, int tsTo, SampleProvider provider);
|
||||
|
||||
void addGBActivitySample(int timestamp, byte provider, short intensity, short steps, byte kind, short heartrate);
|
||||
void addGBActivitySample(int timestamp, int provider, int intensity, int steps, int kind, int heartrate);
|
||||
|
||||
void addGBActivitySamples(ActivitySample[] activitySamples);
|
||||
|
||||
SQLiteDatabase getWritableDatabase();
|
||||
|
||||
void changeStoredSamplesType(int timestampFrom, int timestampTo, byte kind, SampleProvider provider);
|
||||
void changeStoredSamplesType(int timestampFrom, int timestampTo, int kind, SampleProvider provider);
|
||||
|
||||
int fetchLatestTimestamp(SampleProvider provider);
|
||||
|
||||
|
|
|
@ -2,15 +2,10 @@ 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.KEY_CUSTOM_SHORT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_PROVIDER;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_STEPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_TIMESTAMP;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_GBACTIVITYSAMPLES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_STEPS_PER_DAY;
|
||||
|
||||
/**
|
||||
* Adds a column "customShort" to the table "GBActivitySamples"
|
||||
|
|
|
@ -12,7 +12,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|||
* This interface is implemented at least once for every supported gadget device.
|
||||
* It allows Gadgetbridge to generically deal with different kinds of devices
|
||||
* without actually knowing the details of any device.
|
||||
*
|
||||
* <p/>
|
||||
* Instances will be created as needed and asked whether they support a given
|
||||
* device. If a coordinator answers true, it will be used to assist in handling
|
||||
* the given device.
|
||||
|
@ -22,6 +22,7 @@ public interface DeviceCoordinator {
|
|||
|
||||
/**
|
||||
* Checks whether this candidate handles the given candidate.
|
||||
*
|
||||
* @param candidate
|
||||
* @return true if this coordinator handles the given candidate.
|
||||
*/
|
||||
|
@ -29,6 +30,7 @@ public interface DeviceCoordinator {
|
|||
|
||||
/**
|
||||
* Checks whether this candidate handles the given device.
|
||||
*
|
||||
* @param device
|
||||
* @return true if this coordinator handles the given device.
|
||||
*/
|
||||
|
@ -36,6 +38,7 @@ public interface DeviceCoordinator {
|
|||
|
||||
/**
|
||||
* Returns the kind of device type this coordinator supports.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
DeviceType getDeviceType();
|
||||
|
@ -43,6 +46,7 @@ public interface DeviceCoordinator {
|
|||
/**
|
||||
* Returns the Activity class to be started in order to perform a pairing of a
|
||||
* given device.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Class<? extends Activity> getPairingActivity();
|
||||
|
@ -50,6 +54,7 @@ public interface DeviceCoordinator {
|
|||
/**
|
||||
* Returns the Activity class that will be used as the primary activity
|
||||
* for the given device.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Class<? extends Activity> getPrimaryActivity();
|
||||
|
@ -57,6 +62,7 @@ public interface DeviceCoordinator {
|
|||
/**
|
||||
* Returns true if activity data fetching is supported by the device
|
||||
* (with this coordinator).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean supportsActivityDataFetching();
|
||||
|
@ -65,6 +71,7 @@ public interface DeviceCoordinator {
|
|||
* Returns true if activity data fetching is supported AND possible at this
|
||||
* very moment. This will consider the device state (being connected/disconnected/busy...)
|
||||
* etc.
|
||||
*
|
||||
* @param device
|
||||
* @return
|
||||
*/
|
||||
|
@ -72,6 +79,7 @@ public interface DeviceCoordinator {
|
|||
|
||||
/**
|
||||
* Returns the sample provider for the device being supported.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
SampleProvider getSampleProvider();
|
||||
|
@ -79,6 +87,7 @@ public interface DeviceCoordinator {
|
|||
/**
|
||||
* Finds an install handler for the given uri that can install the given
|
||||
* uri on the device being managed.
|
||||
*
|
||||
* @param uri
|
||||
* @param context
|
||||
* @return the install handler or null if that uri cannot be installed on the device
|
||||
|
@ -87,6 +96,7 @@ public interface DeviceCoordinator {
|
|||
|
||||
/**
|
||||
* Returns true if this device/coordinator supports taking screenshots.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean supportsScreenshots();
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.devices;
|
||||
|
||||
public interface SampleProvider {
|
||||
byte PROVIDER_MIBAND = 0;
|
||||
byte PROVIDER_PEBBLE_MORPHEUZ = 1;
|
||||
byte PROVIDER_PEBBLE_GADGETBRIDGE = 2;
|
||||
byte PROVIDER_PEBBLE_MISFIT = 3;
|
||||
byte PROVIDER_PEBBLE_HEALTH = 4;
|
||||
int PROVIDER_MIBAND = 0;
|
||||
int PROVIDER_PEBBLE_MORPHEUZ = 1;
|
||||
int PROVIDER_PEBBLE_GADGETBRIDGE = 2;
|
||||
int PROVIDER_PEBBLE_MISFIT = 3;
|
||||
int PROVIDER_PEBBLE_HEALTH = 4;
|
||||
|
||||
byte PROVIDER_UNKNOWN = 100;
|
||||
int PROVIDER_UNKNOWN = 100;
|
||||
|
||||
int normalizeType(byte rawType);
|
||||
int normalizeType(int rawType);
|
||||
|
||||
byte toRawActivityKind(int activityKind);
|
||||
int toRawActivityKind(int activityKind);
|
||||
|
||||
float normalizeIntensity(short rawIntensity);
|
||||
float normalizeIntensity(int rawIntensity);
|
||||
|
||||
byte getID();
|
||||
int getID();
|
||||
}
|
||||
|
|
|
@ -15,22 +15,22 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||
|
||||
private static final class UnknownSampleProvider implements SampleProvider {
|
||||
@Override
|
||||
public int normalizeType(byte rawType) {
|
||||
public int normalizeType(int rawType) {
|
||||
return ActivityKind.TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte toRawActivityKind(int activityKind) {
|
||||
public int toRawActivityKind(int activityKind) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float normalizeIntensity(short rawIntensity) {
|
||||
public float normalizeIntensity(int rawIntensity) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getID() {
|
||||
public int getID() {
|
||||
return PROVIDER_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class MiBandSampleProvider implements SampleProvider {
|
|||
private final float movementDivisor = 180.0f; //256.0f;
|
||||
|
||||
@Override
|
||||
public int normalizeType(byte rawType) {
|
||||
public int normalizeType(int rawType) {
|
||||
switch (rawType) {
|
||||
case TYPE_DEEP_SLEEP:
|
||||
return ActivityKind.TYPE_DEEP_SLEEP;
|
||||
|
@ -42,7 +42,7 @@ public class MiBandSampleProvider implements SampleProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte toRawActivityKind(int activityKind) {
|
||||
public int toRawActivityKind(int activityKind) {
|
||||
switch (activityKind) {
|
||||
case ActivityKind.TYPE_ACTIVITY:
|
||||
return TYPE_ACTIVITY;
|
||||
|
@ -59,12 +59,12 @@ public class MiBandSampleProvider implements SampleProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public float normalizeIntensity(short rawIntensity) {
|
||||
public float normalizeIntensity(int rawIntensity) {
|
||||
return rawIntensity / movementDivisor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getID() {
|
||||
public int getID() {
|
||||
return SampleProvider.PROVIDER_MIBAND;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,9 +161,9 @@ public class MiBandService {
|
|||
public static final byte COMMAND_SET_REALTIME_STEP = 0x10;
|
||||
|
||||
// Test HR
|
||||
public static final byte COMMAND_SET_HR_SLEEP = 0x0;
|
||||
public static final byte COMMAND_SET__HR_CONTINUOUS = 0x1;
|
||||
public static final byte COMMAND_SET_HR_MANUAL = 0x2;
|
||||
public static final byte COMMAND_SET_HR_SLEEP = 0x0;
|
||||
public static final byte COMMAND_SET__HR_CONTINUOUS = 0x1;
|
||||
public static final byte COMMAND_SET_HR_MANUAL = 0x2;
|
||||
|
||||
|
||||
/* FURTHER COMMANDS: unchecked therefore left commented
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.devices.miband;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.DeviceInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.CheckSums;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class UserInfo {
|
||||
|
||||
private final String btAddress;
|
||||
|
@ -91,7 +91,7 @@ public class UserInfo {
|
|||
aliasFrom = 11;
|
||||
}
|
||||
|
||||
byte[] aliasBytes = alias.substring(0, Math.min(alias.length(), 19-aliasFrom)).getBytes();
|
||||
byte[] aliasBytes = alias.substring(0, Math.min(alias.length(), 19 - aliasFrom)).getBytes();
|
||||
System.arraycopy(aliasBytes, 0, sequence, aliasFrom, aliasBytes.length);
|
||||
|
||||
byte[] crcSequence = Arrays.copyOf(sequence, 19);
|
||||
|
|
|
@ -4,27 +4,27 @@ import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
|||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
|
||||
public class HealthSampleProvider implements SampleProvider {
|
||||
public static final byte TYPE_DEEP_SLEEP = 5;
|
||||
public static final byte TYPE_LIGHT_SLEEP = 4;
|
||||
public static final byte TYPE_ACTIVITY = -1;
|
||||
public static final int TYPE_DEEP_SLEEP = 5;
|
||||
public static final int TYPE_LIGHT_SLEEP = 4;
|
||||
public static final int TYPE_ACTIVITY = -1;
|
||||
|
||||
protected final float movementDivisor = 8000f;
|
||||
|
||||
@Override
|
||||
public int normalizeType(byte rawType) {
|
||||
public int normalizeType(int rawType) {
|
||||
switch (rawType) {
|
||||
case TYPE_DEEP_SLEEP:
|
||||
return ActivityKind.TYPE_DEEP_SLEEP;
|
||||
case TYPE_LIGHT_SLEEP:
|
||||
return ActivityKind.TYPE_LIGHT_SLEEP;
|
||||
case TYPE_ACTIVITY:
|
||||
default:
|
||||
return ActivityKind.TYPE_UNKNOWN;
|
||||
}
|
||||
case TYPE_DEEP_SLEEP:
|
||||
return ActivityKind.TYPE_DEEP_SLEEP;
|
||||
case TYPE_LIGHT_SLEEP:
|
||||
return ActivityKind.TYPE_LIGHT_SLEEP;
|
||||
case TYPE_ACTIVITY:
|
||||
default:
|
||||
return ActivityKind.TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte toRawActivityKind(int activityKind) {
|
||||
public int toRawActivityKind(int activityKind) {
|
||||
switch (activityKind) {
|
||||
case ActivityKind.TYPE_ACTIVITY:
|
||||
return TYPE_ACTIVITY;
|
||||
|
@ -40,13 +40,13 @@ public class HealthSampleProvider implements SampleProvider {
|
|||
|
||||
|
||||
@Override
|
||||
public float normalizeIntensity(short rawIntensity) {
|
||||
public float normalizeIntensity(int rawIntensity) {
|
||||
return rawIntensity / movementDivisor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte getID() {
|
||||
public int getID() {
|
||||
return SampleProvider.PROVIDER_PEBBLE_HEALTH;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,24 +7,24 @@ public class MisfitSampleProvider implements SampleProvider {
|
|||
protected final float movementDivisor = 300f;
|
||||
|
||||
@Override
|
||||
public int normalizeType(byte rawType) {
|
||||
public int normalizeType(int rawType) {
|
||||
return (int) rawType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte toRawActivityKind(int activityKind) {
|
||||
public int toRawActivityKind(int activityKind) {
|
||||
return (byte) activityKind;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float normalizeIntensity(short rawIntensity) {
|
||||
public float normalizeIntensity(int rawIntensity) {
|
||||
return rawIntensity / movementDivisor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte getID() {
|
||||
public int getID() {
|
||||
return SampleProvider.PROVIDER_PEBBLE_MISFIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class MorpheuzSampleProvider implements SampleProvider {
|
|||
protected float movementDivisor = 5000f;
|
||||
|
||||
@Override
|
||||
public int normalizeType(byte rawType) {
|
||||
public int normalizeType(int rawType) {
|
||||
switch (rawType) {
|
||||
case TYPE_DEEP_SLEEP:
|
||||
return ActivityKind.TYPE_DEEP_SLEEP;
|
||||
|
@ -28,7 +28,7 @@ public class MorpheuzSampleProvider implements SampleProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte toRawActivityKind(int activityKind) {
|
||||
public int toRawActivityKind(int activityKind) {
|
||||
switch (activityKind) {
|
||||
case ActivityKind.TYPE_ACTIVITY:
|
||||
return TYPE_ACTIVITY;
|
||||
|
@ -43,12 +43,12 @@ public class MorpheuzSampleProvider implements SampleProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public float normalizeIntensity(short rawIntensity) {
|
||||
public float normalizeIntensity(int rawIntensity) {
|
||||
return rawIntensity / movementDivisor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getID() {
|
||||
public int getID() {
|
||||
return SampleProvider.PROVIDER_PEBBLE_MORPHEUZ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public class PebbleGadgetBridgeSampleProvider extends MorpheuzSampleProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte getID() {
|
||||
public int getID() {
|
||||
return SampleProvider.PROVIDER_PEBBLE_GADGETBRIDGE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import android.os.PowerManager;
|
|||
import android.preference.PreferenceManager;
|
||||
import android.telephony.SmsMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
|
|
|
@ -7,21 +7,21 @@ import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
|||
public class GBActivitySample implements ActivitySample {
|
||||
private final int timestamp;
|
||||
private final SampleProvider provider;
|
||||
private final short intensity;
|
||||
private final short steps;
|
||||
private final byte type;
|
||||
private final short customShortValue;
|
||||
private final int intensity;
|
||||
private final int steps;
|
||||
private final int type;
|
||||
private final int customValue;
|
||||
|
||||
public GBActivitySample(SampleProvider provider, int timestamp, short intensity, short steps, byte type) {
|
||||
this(provider, timestamp, intensity, steps, type, (short) 0);
|
||||
public GBActivitySample(SampleProvider provider, int timestamp, int intensity, int steps, int type) {
|
||||
this(provider, timestamp, intensity, steps, type, 0);
|
||||
}
|
||||
|
||||
public GBActivitySample(SampleProvider provider, int timestamp, short intensity, short steps, byte type, short customShortValue) {
|
||||
public GBActivitySample(SampleProvider provider, int timestamp, int intensity, int steps, int type, int customValue) {
|
||||
this.timestamp = timestamp;
|
||||
this.provider = provider;
|
||||
this.intensity = intensity;
|
||||
this.steps = steps;
|
||||
this.customShortValue = customShortValue;
|
||||
this.customValue = customValue;
|
||||
this.type = type;
|
||||
validate();
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ public class GBActivitySample implements ActivitySample {
|
|||
if (timestamp < 0) {
|
||||
throw new IllegalArgumentException("timestamp must be >= 0");
|
||||
}
|
||||
if (customShortValue < 0) {
|
||||
throw new IllegalArgumentException("customShortValue must be >= 0");
|
||||
if (customValue < 0) {
|
||||
throw new IllegalArgumentException("customValue must be >= 0");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class GBActivitySample implements ActivitySample {
|
|||
}
|
||||
|
||||
@Override
|
||||
public short getRawIntensity() {
|
||||
public int getRawIntensity() {
|
||||
return intensity;
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,12 @@ public class GBActivitySample implements ActivitySample {
|
|||
}
|
||||
|
||||
@Override
|
||||
public short getSteps() {
|
||||
public int getSteps() {
|
||||
return steps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRawKind() {
|
||||
public int getRawKind() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ public class GBActivitySample implements ActivitySample {
|
|||
}
|
||||
|
||||
@Override
|
||||
public short getCustomShortValue() {
|
||||
return customShortValue;
|
||||
public int getCustomValue() {
|
||||
return customValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,7 +87,7 @@ public class GBActivitySample implements ActivitySample {
|
|||
"timestamp=" + DateTimeUtils.formatDateTime(DateTimeUtils.parseTimeStamp(timestamp)) +
|
||||
", intensity=" + getIntensity() +
|
||||
", steps=" + getSteps() +
|
||||
", customShortValue=" + getCustomShortValue() +
|
||||
", customValue=" + getCustomValue() +
|
||||
", type=" + getKind() +
|
||||
'}';
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ public class ActivityKind {
|
|||
public static final int TYPE_SLEEP = TYPE_LIGHT_SLEEP | TYPE_DEEP_SLEEP;
|
||||
public static final int TYPE_ALL = TYPE_ACTIVITY | TYPE_SLEEP | TYPE_NOT_WORN;
|
||||
|
||||
public static byte[] mapToDBActivityTypes(int types, SampleProvider provider) {
|
||||
byte[] result = new byte[3];
|
||||
public static int[] mapToDBActivityTypes(int types, SampleProvider provider) {
|
||||
int[] result = new int[3];
|
||||
int i = 0;
|
||||
if ((types & ActivityKind.TYPE_ACTIVITY) != 0) {
|
||||
result[i++] = provider.toRawActivityKind(TYPE_ACTIVITY);
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface ActivitySample {
|
|||
/**
|
||||
* Returns the raw activity kind value as recorded by the SampleProvider
|
||||
*/
|
||||
byte getRawKind();
|
||||
int getRawKind();
|
||||
|
||||
/**
|
||||
* Returns the activity kind value as recorded by the SampleProvider
|
||||
|
@ -30,7 +30,7 @@ public interface ActivitySample {
|
|||
/**
|
||||
* Returns the raw intensity value as recorded by the SampleProvider
|
||||
*/
|
||||
short getRawIntensity();
|
||||
int getRawIntensity();
|
||||
|
||||
/**
|
||||
* Returns the normalized intensity value between 0 and 1
|
||||
|
@ -40,7 +40,7 @@ public interface ActivitySample {
|
|||
/**
|
||||
* Returns the number of steps performed during the period of this sample
|
||||
*/
|
||||
short getSteps();
|
||||
int getSteps();
|
||||
|
||||
short getCustomShortValue();
|
||||
int getCustomValue();
|
||||
}
|
||||
|
|
|
@ -29,28 +29,28 @@ public class ActivityUser {
|
|||
public static final String PREF_USER_WEIGHT_KG = "activity_user_weight_kg";
|
||||
|
||||
public int getActivityUserWeightKg() {
|
||||
if(activityUserWeightKg == null) {
|
||||
if (activityUserWeightKg == null) {
|
||||
fetchPreferences();
|
||||
}
|
||||
return activityUserWeightKg;
|
||||
}
|
||||
|
||||
public int getActivityUserGender() {
|
||||
if(activityUserGender == null) {
|
||||
if (activityUserGender == null) {
|
||||
fetchPreferences();
|
||||
}
|
||||
return activityUserGender;
|
||||
}
|
||||
|
||||
public int getActivityUserYearOfBirth() {
|
||||
if(activityUserYearOfBirth == null) {
|
||||
if (activityUserYearOfBirth == null) {
|
||||
fetchPreferences();
|
||||
}
|
||||
return activityUserYearOfBirth;
|
||||
}
|
||||
|
||||
public int getActivityUserHeightCm() {
|
||||
if(activityUserHeightCm == null) {
|
||||
if (activityUserHeightCm == null) {
|
||||
fetchPreferences();
|
||||
}
|
||||
return activityUserHeightCm;
|
||||
|
|
|
@ -22,7 +22,7 @@ public class CalendarEvents {
|
|||
// needed for miband:
|
||||
// time
|
||||
|
||||
private static final String[] EVENT_INSTANCE_PROJECTION = new String[] {
|
||||
private static final String[] EVENT_INSTANCE_PROJECTION = new String[]{
|
||||
Instances._ID,
|
||||
Instances.BEGIN,
|
||||
Instances.END,
|
||||
|
@ -67,9 +67,9 @@ public class CalendarEvents {
|
|||
evtCursor.getString(5),
|
||||
evtCursor.getString(6),
|
||||
evtCursor.getString(7)
|
||||
);
|
||||
);
|
||||
calendarEventList.add(calEvent);
|
||||
} while(evtCursor.moveToNext());
|
||||
} while (evtCursor.moveToNext());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class CalendarEvents {
|
|||
}
|
||||
|
||||
public int getBeginSeconds() {
|
||||
return (int)(begin/1000);
|
||||
return (int) (begin / 1000);
|
||||
}
|
||||
|
||||
public long getEnd() {
|
||||
|
@ -112,11 +112,11 @@ public class CalendarEvents {
|
|||
}
|
||||
|
||||
public int getDurationSeconds() {
|
||||
return (int)((getDuration())/1000);
|
||||
return (int) ((getDuration()) / 1000);
|
||||
}
|
||||
|
||||
public short getDurationMinutes() {
|
||||
return (short)(getDurationSeconds()/60);
|
||||
return (short) (getDurationSeconds() / 60);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.service;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -11,10 +10,8 @@ import java.util.EnumSet;
|
|||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBandSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class DeviceSupportFactory {
|
||||
|
|
|
@ -36,6 +36,7 @@ public abstract class AbstractBTLEOperation<T extends AbstractBTLEDeviceSupport>
|
|||
* Performs this operation. The whole operation is asynchronous, i.e.
|
||||
* this method quickly returns before the actual operation is finished.
|
||||
* Calls #prePerform() and, if successful, #doPerform().
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
|
@ -48,6 +49,7 @@ public abstract class AbstractBTLEOperation<T extends AbstractBTLEDeviceSupport>
|
|||
|
||||
/**
|
||||
* Hook for subclasses to perform something before #doPerform() is invoked.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void prePerform() throws IOException {
|
||||
|
@ -58,6 +60,7 @@ public abstract class AbstractBTLEOperation<T extends AbstractBTLEDeviceSupport>
|
|||
* successfully.
|
||||
* Note that subclasses HAVE TO call #operationFinished() when the entire
|
||||
* opreation is done (successful or not).
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected abstract void doPerform() throws IOException;
|
||||
|
@ -65,6 +68,7 @@ public abstract class AbstractBTLEOperation<T extends AbstractBTLEDeviceSupport>
|
|||
/**
|
||||
* You MUST call this method when the operation has finished, either
|
||||
* successfull or unsuccessfully.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void operationFinished() throws IOException {
|
||||
|
|
|
@ -422,7 +422,7 @@ public final class BtLEQueue {
|
|||
for (byte b : characteristic.getValue()) {
|
||||
content += String.format(" 0x%1x", b);
|
||||
}
|
||||
LOG.debug("characteristic changed: " + characteristic.getUuid() + " value: " + content );
|
||||
LOG.debug("characteristic changed: " + characteristic.getUuid() + " value: " + content);
|
||||
}
|
||||
if (!checkCorrectGattInstance(gatt, "characteristic changed")) {
|
||||
return;
|
||||
|
|
|
@ -74,7 +74,7 @@ public interface GattCallback {
|
|||
* @see BluetoothGattCallback#onDescriptorRead(BluetoothGatt, BluetoothGattDescriptor, int)
|
||||
*/
|
||||
void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
|
||||
int status);
|
||||
int status);
|
||||
|
||||
/**
|
||||
* @param gatt
|
||||
|
@ -83,7 +83,7 @@ public interface GattCallback {
|
|||
* @see BluetoothGattCallback#onDescriptorWrite(BluetoothGatt, BluetoothGattDescriptor, int)
|
||||
*/
|
||||
void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
|
||||
int status);
|
||||
int status);
|
||||
//
|
||||
// /**
|
||||
// * @see BluetoothGattCallback#onReliableWriteCompleted(BluetoothGatt, int)
|
||||
|
|
|
@ -41,7 +41,7 @@ public class DeviceInfo extends AbstractInfo {
|
|||
|
||||
public static int getInt(byte[] data, int from, int len) {
|
||||
int ret = 0;
|
||||
for(int i = 0; i < len; ++i) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
ret |= (data[from + i] & 255) << i * 8;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -141,7 +141,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
// is not available. And at this point, we don't even know whether we support it, because
|
||||
// no device info is available yet. We would have to do the check in a custom NotifyAction.
|
||||
// if (supportsHeartRate()) {
|
||||
builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT), enable);
|
||||
builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT), enable);
|
||||
// }
|
||||
|
||||
return this;
|
||||
|
@ -206,12 +206,12 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
|
||||
static final byte[] reboot = new byte[]{MiBandService.COMMAND_REBOOT};
|
||||
|
||||
static final byte[] startHeartMeasurementManual = new byte[]{ 0x15, MiBandService.COMMAND_SET_HR_MANUAL, 1};
|
||||
static final byte[] stopHeartMeasurementManual = new byte[]{ 0x15, MiBandService.COMMAND_SET_HR_MANUAL, 0};
|
||||
static final byte[] startHeartMeasurementContinuous = new byte[]{ 0x15, MiBandService.COMMAND_SET__HR_CONTINUOUS, 1};
|
||||
static final byte[] stopHeartMeasurementContinuous = new byte[]{ 0x15, MiBandService.COMMAND_SET__HR_CONTINUOUS, 0};
|
||||
static final byte[] startHeartMeasurementSleep = new byte[]{ 0x15, MiBandService.COMMAND_SET_HR_SLEEP, 1};
|
||||
static final byte[] stopHeartMeasurementSleep = new byte[]{ 0x15, MiBandService.COMMAND_SET_HR_SLEEP, 0};
|
||||
static final byte[] startHeartMeasurementManual = new byte[]{0x15, MiBandService.COMMAND_SET_HR_MANUAL, 1};
|
||||
static final byte[] stopHeartMeasurementManual = new byte[]{0x15, MiBandService.COMMAND_SET_HR_MANUAL, 0};
|
||||
static final byte[] startHeartMeasurementContinuous = new byte[]{0x15, MiBandService.COMMAND_SET__HR_CONTINUOUS, 1};
|
||||
static final byte[] stopHeartMeasurementContinuous = new byte[]{0x15, MiBandService.COMMAND_SET__HR_CONTINUOUS, 0};
|
||||
static final byte[] startHeartMeasurementSleep = new byte[]{0x15, MiBandService.COMMAND_SET_HR_SLEEP, 1};
|
||||
static final byte[] stopHeartMeasurementSleep = new byte[]{0x15, MiBandService.COMMAND_SET_HR_SLEEP, 0};
|
||||
|
||||
static final byte[] startRealTimeStepsNotifications = new byte[]{MiBandService.COMMAND_SET_REALTIME_STEPS_NOTIFICATION, 1};
|
||||
static final byte[] stopRealTimeStepsNotifications = new byte[]{MiBandService.COMMAND_SET_REALTIME_STEPS_NOTIFICATION, 0};
|
||||
|
@ -283,6 +283,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
}
|
||||
return this;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Part of device initialization process. Do not call manually.
|
||||
*
|
||||
|
@ -531,6 +532,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
LOG.error("Unable to reboot MI", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHearRateTest() {
|
||||
if (supportsHeartRate()) {
|
||||
|
@ -673,11 +675,10 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
} else if (MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS.equals(characteristicUUID)) {
|
||||
handleRealtimeSteps(characteristic.getValue());
|
||||
} else if (MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS.equals(characteristicUUID)) {
|
||||
handleRealtimeSteps(characteristic.getValue());
|
||||
} else if (MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT.equals(characteristicUUID)) {
|
||||
handleRealtimeSteps(characteristic.getValue());
|
||||
} else if (MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT.equals(characteristicUUID)) {
|
||||
logHeartrate(characteristic.getValue());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
LOG.info("Unhandled characteristic changed: " + characteristicUUID);
|
||||
logMessageContent(characteristic.getValue());
|
||||
}
|
||||
|
@ -698,7 +699,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
} else if (MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT.equals(characteristicUUID)) {
|
||||
logHeartrate(characteristic.getValue());
|
||||
} else {
|
||||
LOG.info("Unhandled characteristic read: "+ characteristicUUID);
|
||||
LOG.info("Unhandled characteristic read: " + characteristicUUID);
|
||||
logMessageContent(characteristic.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -927,11 +928,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
|
||||
if (availableSlots > 0) {
|
||||
CalendarEvents upcomingEvents = new CalendarEvents();
|
||||
List<CalendarEvents.CalendarEvent> mEvents = upcomingEvents.getCalendarEventList(getContext());
|
||||
List<CalendarEvents.CalendarEvent> mEvents = upcomingEvents.getCalendarEventList(getContext());
|
||||
|
||||
int iteration = 0;
|
||||
ArrayList<GBAlarm> alarmList = new ArrayList<>();
|
||||
for(CalendarEvents.CalendarEvent mEvt : mEvents) {
|
||||
for (CalendarEvents.CalendarEvent mEvt : mEvents) {
|
||||
if (iteration >= availableSlots || iteration > 2) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -41,8 +41,9 @@ public abstract class AbstractMiBandOperation extends AbstractBTLEOperation<MiBa
|
|||
* Enables or disables certain kinds of notifications that could interfere with this
|
||||
* operation. Call this method once initially to disable other notifications, and once
|
||||
* when this operation has finished.
|
||||
*
|
||||
* @param builder
|
||||
* @param enable true to enable, false to disable the other notifications
|
||||
* @param enable true to enable, false to disable the other notifications
|
||||
*/
|
||||
protected void enableOtherNotifications(TransactionBuilder builder, boolean enable) {
|
||||
builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS), enable)
|
||||
|
|
|
@ -314,7 +314,7 @@ public class FetchActivityOperation extends AbstractMiBandOperation {
|
|||
try (SQLiteDatabase db = dbHandler.getWritableDatabase()) { // explicitly keep the db open while looping over the samples
|
||||
int timestampInSeconds = (int) (activityStruct.activityDataTimestampProgress.getTimeInMillis() / 1000);
|
||||
if ((activityStruct.activityDataHolderProgress % bpm) != 0) {
|
||||
throw new IllegalStateException("Unexpected data, progress should be mutiple of " + bpm +": " + activityStruct.activityDataHolderProgress);
|
||||
throw new IllegalStateException("Unexpected data, progress should be mutiple of " + bpm + ": " + activityStruct.activityDataHolderProgress);
|
||||
}
|
||||
int numSamples = activityStruct.activityDataHolderProgress / bpm;
|
||||
ActivitySample[] samples = new ActivitySample[numSamples];
|
||||
|
|
|
@ -191,10 +191,10 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
|
|||
|
||||
if ((i > 0) && (i % 50 == 0)) {
|
||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[]{MiBandService.COMMAND_SYNC});
|
||||
builder.add(new SetProgressAction("Firmware update in progress", true, (int)(((float) firmwareProgress) / len * 100), getContext()));
|
||||
builder.add(new SetProgressAction("Firmware update in progress", true, (int) (((float) firmwareProgress) / len * 100), getContext()));
|
||||
}
|
||||
|
||||
LOG.info("Firmware update progress:" + firmwareProgress + " total len:" + len + " progress:" + (int)(((float) firmwareProgress) / len * 100));
|
||||
LOG.info("Firmware update progress:" + firmwareProgress + " total len:" + len + " progress:" + (int) (((float) firmwareProgress) / len * 100));
|
||||
}
|
||||
|
||||
if (!(len % packetLength == 0)) {
|
||||
|
|
|
@ -52,10 +52,10 @@ public class AppMessageHandlerGBPebble extends AppMessageHandler {
|
|||
db = GBApplication.acquireDB();
|
||||
while (samples_remaining-- > 0) {
|
||||
short sample = samplesBuffer.getShort();
|
||||
byte type = (byte) ((sample & 0xe000) >>> 13);
|
||||
byte intensity = (byte) ((sample & 0x1f80) >>> 7);
|
||||
byte steps = (byte) (sample & 0x007f);
|
||||
db.addGBActivitySample(timestamp + offset_seconds, SampleProvider.PROVIDER_PEBBLE_GADGETBRIDGE, (short) (intensity & 0xff), (short) (steps & 0xff), type, (short)0);
|
||||
int type = ((sample & 0xe000) >>> 13);
|
||||
int intensity = ((sample & 0x1f80) >>> 7);
|
||||
int steps = (sample & 0x007f);
|
||||
db.addGBActivitySample(timestamp + offset_seconds, SampleProvider.PROVIDER_PEBBLE_GADGETBRIDGE, intensity, steps, type, 0);
|
||||
offset_seconds += 60;
|
||||
}
|
||||
} catch (GBException e) {
|
||||
|
|
|
@ -75,7 +75,7 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
|||
short sample = buf.getShort();
|
||||
int steps = 0;
|
||||
int intensity = 0;
|
||||
byte activityKind = ActivityKind.TYPE_UNKNOWN;
|
||||
int activityKind = ActivityKind.TYPE_UNKNOWN;
|
||||
|
||||
if (((sample & 0x83ff) == 0x0001) && ((sample & 0xff00) <= 0x4800)) {
|
||||
// sleep seems to be from 0x2401 to 0x4801 (0b0IIIII0000000001) where I = intensity ?
|
||||
|
@ -101,7 +101,7 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
|||
totalSteps += steps;
|
||||
LOG.info("got steps for sample " + i + " : " + steps + "(" + Integer.toHexString(sample & 0xffff) + ")");
|
||||
|
||||
activitySamples[i] = new GBActivitySample(sampleProvider, timestamp + i * 60, (short) intensity, (short) steps, activityKind);
|
||||
activitySamples[i] = new GBActivitySample(sampleProvider, timestamp + i * 60, intensity, steps, activityKind);
|
||||
}
|
||||
LOG.info("total steps for above period: " + totalSteps);
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public class AppMessageHandlerMorpheuz extends AppMessageHandler {
|
|||
DBHandler db = null;
|
||||
try {
|
||||
db = GBApplication.acquireDB();
|
||||
db.addGBActivitySample(recording_base_timestamp + index * 600, SampleProvider.PROVIDER_PEBBLE_MORPHEUZ, intensity, (byte) 0, type, (short)0);
|
||||
db.addGBActivitySample(recording_base_timestamp + index * 600, SampleProvider.PROVIDER_PEBBLE_MORPHEUZ, intensity, (byte) 0, type, (short) 0);
|
||||
} catch (GBException e) {
|
||||
LOG.error("Error acquiring database", e);
|
||||
} finally {
|
||||
|
|
|
@ -77,7 +77,7 @@ public class AppMessageHandlerTimeStylePebble extends AppMessageHandler {
|
|||
|
||||
//byte[] weatherMessage=encodeTimeStylePebbleWeather();
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(ackMessage.length + testMessage.length );
|
||||
ByteBuffer buf = ByteBuffer.allocate(ackMessage.length + testMessage.length);
|
||||
|
||||
// encode ack and put in front of push message (hack for acknowledging the last message)
|
||||
buf.put(ackMessage);
|
||||
|
@ -98,7 +98,7 @@ public class AppMessageHandlerTimeStylePebble extends AppMessageHandler {
|
|||
return weatherMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public GBDeviceEvent[] handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
|
||||
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
|
||||
sendBytes.encodedBytes = encodeTimeStylePebbleConfig();
|
||||
|
|
|
@ -19,7 +19,7 @@ class DatalogSession {
|
|||
this.itemSize = itemSize;
|
||||
}
|
||||
|
||||
boolean handleMessage (ByteBuffer buf, int length) {
|
||||
boolean handleMessage(ByteBuffer buf, int length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble;
|
||||
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble;
|
||||
|
||||
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -61,7 +59,8 @@ public class DatalogSessionHealthSteps extends DatalogSession {
|
|||
|
||||
for (int recordIdx = 0; recordIdx < recordNum; recordIdx++) {
|
||||
datalogMessage.position(beginOfRecordPosition + recordIdx * recordLength); //we may not consume all the bytes of a record
|
||||
stepsRecords[recordIdx] = new StepsRecord(timestamp, datalogMessage.get(), datalogMessage.get(), datalogMessage.getShort(), datalogMessage.get(), datalogMessage.get());
|
||||
stepsRecords[recordIdx] = new StepsRecord(timestamp, datalogMessage.get() & 0xff, datalogMessage.get() & 0xff, datalogMessage.getShort() & 0xffff);
|
||||
datalogMessage.getShort(); // skip
|
||||
timestamp += 60;
|
||||
}
|
||||
|
||||
|
@ -82,7 +81,7 @@ public class DatalogSessionHealthSteps extends DatalogSession {
|
|||
sampleProvider,
|
||||
stepsRecord.timestamp,
|
||||
stepsRecord.intensity,
|
||||
(short) (stepsRecord.steps & 0xff),
|
||||
stepsRecord.steps,
|
||||
sampleProvider.toRawActivityKind(ActivityKind.TYPE_ACTIVITY));
|
||||
}
|
||||
|
||||
|
@ -100,11 +99,11 @@ public class DatalogSessionHealthSteps extends DatalogSession {
|
|||
|
||||
private class StepsRecord {
|
||||
int timestamp;
|
||||
byte steps;
|
||||
byte orientation;
|
||||
short intensity;
|
||||
int steps;
|
||||
int orientation;
|
||||
int intensity;
|
||||
|
||||
public StepsRecord(int timestamp, byte steps, byte orientation, short intensity, byte throwAway1, byte throwAway2) {
|
||||
public StepsRecord(int timestamp, int steps, int orientation, int intensity) {
|
||||
this.timestamp = timestamp;
|
||||
this.steps = steps;
|
||||
this.orientation = orientation;
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.preference.PreferenceManager;
|
|||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
|
Loading…
Reference in New Issue