Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Try to fix BLE sensor replacement without breaking focus
Browse files Browse the repository at this point in the history
BUG=32810660

Change-Id: Id7eefc92d5c74fc33cd1f2fe7f0c45c0b96c22b4
  • Loading branch information
dsaff committed Nov 11, 2016
1 parent 6e80cac commit 5958666
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ public boolean isSameSensor(ConnectableSensor other) {
return mSpec.isSameSensor(other.mSpec);
}

public boolean isUnchanged(ConnectableSensor other) {
if (mSpec == null) {
return Objects.equals(other.mConnectedSensorId, mConnectedSensorId);
}
return mSpec.isSameSensorAndSpec(other.mSpec);
}

public boolean isBuiltIn() {
return mSpec == null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,9 @@ public boolean isScanning() {
/**
* @return true if anything is changed.
*/
public boolean setExperimentId(String experimentId, SensorRegistry sr) {
if (Objects.equals(experimentId, mExperimentId)) {
return false;
}
public void setExperimentId(String experimentId, SensorRegistry sr) {
mExperimentId = experimentId;
refresh(false, sr);
return true;
}

private SensorGroup getPairedGroup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public boolean addAvailableSensor(String sensorKey, ConnectableSensor sensor) {
mSensorMap.put(sensorKey, sensor);
int parentIndex = findParentIndex(sensorKey);
if (parentIndex >= 0) {
if (!previousSensor.isSameSensor(sensor)) {
if (!previousSensor.isUnchanged(sensor)) {
notifyChildItemChanged(findParentIndex(sensorKey), findChildIndex(sensorKey));
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ public void refreshAfterLoad() {
}

private void setExperimentId(String experimentId) {
if (!mRegistry.setExperimentId(experimentId, mSensorRegistry)) {
// Nothing changed, no need to reload.
return;
}
mRegistry.setExperimentId(experimentId, mSensorRegistry);
AppSingleton.getInstance(getActivity()).getDataController().getExperimentById(
experimentId,
new LoggingConsumer<Experiment>(TAG, "load experiment for name") {
Expand Down

0 comments on commit 5958666

Please sign in to comment.