| Chunk |
|---|
| Conflicting content |
|---|
// when screen is facing the sky or ground), we completely ignore orientation data.
private static final int MAX_TILT = 75;
<<<<<<< HEAD
// Additional limits on tilt angle to transition to each new orientation. We ignore all
// data with tilt beyond MAX_TILT, but we can set stricter limits on transitions to a
// particular orientation here.
private static final int[] MAX_TRANSITION_TILT = new int[] {MAX_TILT, 65, 65, 40};
// Between this tilt angle and MAX_TILT, we'll allow orientation changes, but we'll filter
// with a higher time constant, making us less sensitive to change. This primarily helps
// prevent momentary orientation changes when placing a device on a table from the side (or
// picking one up).
private static final int PARTIAL_TILT = 50;
// Maximum allowable deviation of the magnitude of the sensor vector from that of gravity,
// in m/s^2. Beyond this, we assume the phone is under external forces and we can't trust
// the sensor data. However, under constantly vibrating conditions (think car mount), we
// still want to pick up changes, so rather than ignore the data, we filter it with a very
// high time constant.
private static final float MAX_DEVIATION_FROM_GRAVITY = 1.5f;
// Actual sampling period corresponding to SensorManager.SENSOR_DELAY_NORMAL. There's no
// way to get this information from SensorManager.
// Note the actual period is generally 3-30ms larger than this depending on the device, but
// that's not enough to significantly skew our results.
private static final int SAMPLING_PERIOD_MS = 200;
// The following time constants are all used in low-pass filtering the accelerometer output.
// See http://en.wikipedia.org/wiki/Low-pass_filter#Discrete-time_realization for
// background.
// When device is near-vertical (screen approximately facing the horizon)
private static final int DEFAULT_TIME_CONSTANT_MS = 100;
// When device is partially tilted towards the sky or ground
private static final int TILTED_TIME_CONSTANT_MS = 500;
// When device is under external acceleration, i.e. not just gravity. We heavily distrust
// such readings.
private static final int ACCELERATING_TIME_CONSTANT_MS = 2000;
private static final float DEFAULT_LOWPASS_ALPHA =
computeLowpassAlpha(DEFAULT_TIME_CONSTANT_MS);
private static final float TILTED_LOWPASS_ALPHA =
computeLowpassAlpha(TILTED_TIME_CONSTANT_MS);
private static final float ACCELERATING_LOWPASS_ALPHA =
computeLowpassAlpha(ACCELERATING_TIME_CONSTANT_MS);
private boolean mAllow180Rotation = false;
private WindowOrientationListener mOrientationListener;
private int mRotation = ROTATION_0; // Current orientation state
private float mTiltAngle = 0; // low-pass filtered
private float mOrientationAngle = 0; // low-pass filtered
/*
* Each "distrust" counter represents our current level of distrust in the data based on
* a certain signal. For each data point that is deemed unreliable based on that signal,
* the counter increases; otherwise, the counter decreases. Exact rules vary.
*/
private int mAccelerationDistrust = 0; // based on magnitude != gravity
private int mTiltDistrust = 0; // based on tilt close to +/- 90 degrees
=======
// The tilt angle range in degrees for each orientation.
// Beyond these tilt angles, we don't even consider transitioning into the
// specified orientation. We place more stringent requirements on unnatural
// orientations than natural ones to make it less likely to accidentally transition
// into those states.
// The first value of each pair is negative so it applies a limit when the device is
// facing down (overhead reading in bed).
// The second value of each pair is positive so it applies a limit when the device is
// facing up (resting on a table).
// The ideal tilt angle is 0 (when the device is vertical) so the limits establish
// how close to vertical the device must be in order to change orientation.
private static final int[][] TILT_TOLERANCE = new int[][] {
/* ROTATION_0 */ { -20, 75 },
/* ROTATION_90 */ { -20, 70 },
/* ROTATION_180 */ { -20, 65 },
/* ROTATION_270 */ { -20, 70 }
};
>>>>>>> eebc944fd13099945b04a99f15173cdaada1ecf2
// The gap angle in degrees between adjacent orientation angles for hysteresis.
// This creates a "dead zone" between the current orientation and a proposed |
| Solution content |
|---|
/* ROTATION_180 */ { -20, 65 },
/* ROTATION_270 */ { -20, 70 }
};
// The gap angle in degrees between adjacent orientation angles for hysteresis.
// when screen is facing the sky or ground), we completely ignore orientation data.
private static final int MAX_TILT = 75;
// The tilt angle range in degrees for each orientation.
// Beyond these tilt angles, we don't even consider transitioning into the
// specified orientation. We place more stringent requirements on unnatural
// orientations than natural ones to make it less likely to accidentally transition
// into those states.
// The first value of each pair is negative so it applies a limit when the device is
// facing down (overhead reading in bed).
// The second value of each pair is positive so it applies a limit when the device is
// facing up (resting on a table).
// The ideal tilt angle is 0 (when the device is vertical) so the limits establish
// how close to vertical the device must be in order to change orientation.
private static final int[][] TILT_TOLERANCE = new int[][] {
/* ROTATION_0 */ { -20, 75 },
/* ROTATION_90 */ { -20, 70 },
// This creates a "dead zone" between the current orientation and a proposed |
| File |
|---|
| WindowOrientationListener.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Attribute |
| Comment |
| Method invocation |
| Chunk |
|---|
| Conflicting content |
|---|
@Override
public void onSensorChanged(SensorEvent event) {
<<<<<<< HEAD
// the vector given in the SensorEvent points straight up (towards the sky) under ideal
// conditions (the phone is not accelerating). i'll call this upVector elsewhere.
float x = event.values[_DATA_X];
float y = event.values[_DATA_Y];
float z = event.values[_DATA_Z];
float magnitude = vectorMagnitude(x, y, z);
float deviation = Math.abs(magnitude - SensorManager.STANDARD_GRAVITY);
handleAccelerationDistrust(deviation);
=======
final boolean log = mOrientationListener.mLogEnabled;
// The vector given in the SensorEvent points straight up (towards the sky) under ideal
// conditions (the phone is not accelerating). I'll call this up vector elsewhere.
float x = event.values[ACCELEROMETER_DATA_X];
float y = event.values[ACCELEROMETER_DATA_Y];
float z = event.values[ACCELEROMETER_DATA_Z];
if (log) {
Slog.v(TAG, "Raw acceleration vector: " +
"x=" + x + ", y=" + y + ", z=" + z);
}
>>>>>>> eebc944fd13099945b04a99f15173cdaada1ecf2
// Apply a low-pass filter to the acceleration up vector in cartesian space.
// Reset the orientation listener state if the samples are too far apart in time |
| Solution content |
|---|
@Override
public void onSensorChanged(SensorEvent event) {
final boolean log = mOrientationListener.mLogEnabled;
// The vector given in the SensorEvent points straight up (towards the sky) under ideal
// conditions (the phone is not accelerating). I'll call this up vector elsewhere.
float x = event.values[ACCELEROMETER_DATA_X];
float y = event.values[ACCELEROMETER_DATA_Y];
float z = event.values[ACCELEROMETER_DATA_Z];
if (log) {
Slog.v(TAG, "Raw acceleration vector: " +
"x=" + x + ", y=" + y + ", z=" + z);
}
// Apply a low-pass filter to the acceleration up vector in cartesian space.
// Reset the orientation listener state if the samples are too far apart in time |
| File |
|---|
| WindowOrientationListener.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Array access |
| Attribute |
| Comment |
| If statement |
| Method invocation |
| Variable |