fix: always same accelero value was recorded
This commit is contained in:
@@ -6,6 +6,8 @@ import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
@@ -225,7 +227,7 @@ public class LstForegroundService extends Service implements SensorEventListener
|
||||
}
|
||||
public SensorData(long timestamp, float[] values) {
|
||||
this.timestamp = timestamp;
|
||||
this.values = values;
|
||||
this.values = Arrays.copyOf(values, values.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,10 +235,12 @@ public class LstForegroundService extends Service implements SensorEventListener
|
||||
public static class SensorDataArray {
|
||||
private ArrayList<SensorData> data = new ArrayList<SensorData>();
|
||||
private String meta;
|
||||
private int versionCode;
|
||||
public void add(SensorEvent event) { data.add(new SensorData(event)); }
|
||||
public void add(SensorData d) { data.add(d); }
|
||||
public void clear() { data.clear(); }
|
||||
public void setMeta(String meta) { this.meta = meta; }
|
||||
public void setVersionCode(int versionCode) { this.versionCode = versionCode; }
|
||||
}
|
||||
|
||||
private final SensorDataArray recording = new SensorDataArray();
|
||||
@@ -245,6 +249,11 @@ public class LstForegroundService extends Service implements SensorEventListener
|
||||
private void onStartRecording(String meta) {
|
||||
recordingStartTime = SystemClock.elapsedRealtimeNanos();
|
||||
recording.setMeta(meta);
|
||||
|
||||
try {
|
||||
PackageInfo pInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), 0);
|
||||
recording.setVersionCode(pInfo.versionCode);
|
||||
} catch (PackageManager.NameNotFoundException ignored) {}
|
||||
}
|
||||
private void onStopRecording() {
|
||||
if(listener != null) {
|
||||
|
||||
Reference in New Issue
Block a user