Skip to content

Commit

Permalink
Bug 1470994 - remove unused accuracy field from SensorData; r=gsvelto
Browse files Browse the repository at this point in the history
Reviewers: gsvelto

Reviewed By: gsvelto

Bug #: 1470994

Differential Revision: https://phabricator.services.mozilla.com/D1817
  • Loading branch information
Alex Gaynor committed Jun 27, 2018
1 parent 203735f commit 185632a
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 54 deletions.
1 change: 0 additions & 1 deletion dom/system/nsDeviceSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ class DeviceSensorTestEvent : public Runnable
sensorData.values().AppendElement(0.5f);
sensorData.values().AppendElement(0.5f);
sensorData.values().AppendElement(0.5f);
sensorData.accuracy() = SENSOR_ACCURACY_UNRELIABLE;
mTarget->Notify(sensorData);
return NS_OK;
}
Expand Down
21 changes: 0 additions & 21 deletions hal/HalSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ class SensorData;

typedef Observer<SensorData> ISensorObserver;

/**
* Enumeration of sensor accuracy types.
*/
enum SensorAccuracyType {
SENSOR_ACCURACY_UNKNOWN = -1,
SENSOR_ACCURACY_UNRELIABLE,
SENSOR_ACCURACY_LOW,
SENSOR_ACCURACY_MED,
SENSOR_ACCURACY_HIGH,
NUM_SENSOR_ACCURACY_TYPE
};

class SensorAccuracy;

typedef Observer<SensorAccuracy> ISensorAccuracyObserver;
Expand All @@ -66,15 +54,6 @@ namespace IPC {
mozilla::hal::SENSOR_UNKNOWN,
mozilla::hal::NUM_SENSOR_TYPE> {
};

template <>
struct ParamTraits<mozilla::hal::SensorAccuracyType>:
public ContiguousEnumSerializer<
mozilla::hal::SensorAccuracyType,
mozilla::hal::SENSOR_ACCURACY_UNKNOWN,
mozilla::hal::NUM_SENSOR_ACCURACY_TYPE> {

};
} // namespace IPC

#endif /* __HAL_SENSOR_H_ */
3 changes: 1 addition & 2 deletions hal/cocoa/CocoaSensor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@

hal::SensorData sdata(sensor,
PR_Now(),
values,
hal::SENSOR_ACCURACY_UNKNOWN);
values);
hal::NotifySensorChange(sdata);
}
}
Expand Down
2 changes: 0 additions & 2 deletions hal/sandbox/PHal.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ include "mozilla/GfxMessageUtils.h";

using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientation.h";
using mozilla::hal::SensorType from "mozilla/HalSensor.h";
using mozilla::hal::SensorAccuracyType from "mozilla/HalSensor.h";
using mozilla::hal::WakeLockControl from "mozilla/HalTypes.h";
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
using nsIntRect from "nsRect.h";
Expand All @@ -30,7 +29,6 @@ struct SensorData {
SensorType sensor;
PRTime timestamp;
float[] values;
SensorAccuracyType accuracy;
};

struct NetworkInformation {
Expand Down
3 changes: 1 addition & 2 deletions hal/windows/WindowsSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ class SensorEvent final : public ISensorEvents {

hal::SensorData sdata(hal::SENSOR_ACCELERATION,
PR_Now(),
values,
hal::SENSOR_ACCURACY_UNKNOWN);
values);
hal::NotifySensorChange(sdata);

return S_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ private static void enableLocationHighAccuracy(final boolean enable) {

@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
/* package */ static native void onSensorChanged(int hal_type, float x, float y, float z,
float w, int accuracy, long time);
float w, long time);

@WrapForJNI(calledFrom = "any", dispatchTo = "gecko")
/* package */ static native void onLocationChanged(double latitude, double longitude,
Expand All @@ -415,26 +415,11 @@ private static class DefaultListeners implements SensorEventListener,
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}

private static int HalSensorAccuracyFor(int androidAccuracy) {
switch (androidAccuracy) {
case SensorManager.SENSOR_STATUS_UNRELIABLE:
return GeckoHalDefines.SENSOR_ACCURACY_UNRELIABLE;
case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
return GeckoHalDefines.SENSOR_ACCURACY_LOW;
case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
return GeckoHalDefines.SENSOR_ACCURACY_MED;
case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
return GeckoHalDefines.SENSOR_ACCURACY_HIGH;
}
return GeckoHalDefines.SENSOR_ACCURACY_UNKNOWN;
}

@Override
public void onSensorChanged(SensorEvent s) {
int sensor_type = s.sensor.getType();
int hal_type = 0;
float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
final int accuracy = HalSensorAccuracyFor(s.accuracy);
// SensorEvent timestamp is in nanoseconds, Gecko expects microseconds.
final long time = s.timestamp / 1000;

Expand Down Expand Up @@ -493,7 +478,7 @@ public void onSensorChanged(SensorEvent s) {
break;
}

GeckoAppShell.onSensorChanged(hal_type, x, y, z, w, accuracy, time);
GeckoAppShell.onSensorChanged(hal_type, x, y, z, w, time);
}

// Geolocation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,4 @@ public class GeckoHalDefines
public static final int SENSOR_LIGHT = 5;
public static final int SENSOR_ROTATION_VECTOR = 6;
public static final int SENSOR_GAME_ROTATION_VECTOR = 7;

public static final int SENSOR_ACCURACY_UNKNOWN = -1;
public static final int SENSOR_ACCURACY_UNRELIABLE = 0;
public static final int SENSOR_ACCURACY_LOW = 1;
public static final int SENSOR_ACCURACY_MED = 2;
public static final int SENSOR_ACCURACY_HIGH = 3;
};
5 changes: 2 additions & 3 deletions widget/android/nsAppShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class GeckoAppShellSupport final
}

static void OnSensorChanged(int32_t aType, float aX, float aY, float aZ,
float aW, int32_t aAccuracy, int64_t aTime)
float aW, int64_t aTime)
{
AutoTArray<float, 4> values;

Expand Down Expand Up @@ -336,8 +336,7 @@ class GeckoAppShellSupport final
"Unknown sensor type %d", aType);
}

hal::SensorData sdata(hal::SensorType(aType), aTime, values,
hal::SensorAccuracyType(aAccuracy));
hal::SensorData sdata(hal::SensorType(aType), aTime, values);
hal::NotifySensorChange(sdata);
}

Expand Down

0 comments on commit 185632a

Please sign in to comment.