Buggy code:
public class MoSyncSensor implements SensorEventListener { private static final int SEVENT_TYPE = 0 ; private static final int SEVENT_SENSOR_TYPE = 1 ; private static final int SEVENT_SENSOR_VALUES = 2 ; private static final int SEVENT_SIZE = 5 ; private static final int SENSOR_TYPE_OTHER = 0 ; private static final int SENSOR_TYPE_ACCELEROMETER = 1 ; private static final int SENSOR_TYPE_MAGNETIC_FIELD = 2 ; private static final int SENSOR_TYPE_ORIENTATION = 3 ; private static final int SENSOR_TYPE_GYROSCOPE = 4 ; private static final int SENSOR_TYPE_PROXIMITY = 5 ; private static final int SENSOR_TYPES = 6 ; private static final int SENSOR_ERROR_NONE = 0 ; private static final int SENSOR_ERROR_NOT_AVAILABLE = - 1 ; private static final int SENSOR_ERROR_INTERVAL_NOT_SET = - 2 ; private static final int SENSOR_ERROR_ALREADY_ENABLED = - 3 ; private static final int SENSOR_ERROR_NOT_ENABLED = - 4 ; private static final int SENSOR_ERROR_CANNOT_DISABLE = - 5 ; private static final int SENSOR_DELAY_FASTEST = 0 ; private static final int SENSOR_DELAY_GAME = - 1 ; private static final int SENSOR_DELAY_NORMAL = - 2 ; private static final int SENSOR_DELAY_UI = - 3 ; private static final int UIDEVICE_ORIENTATION_UNKNOWN = 0 ; private static final int UIDEVICE_ORIENTATION_PORTRAIT = 1 ; private static final int UIDEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2 ; private static final int UIDEVICE_ORIENTATION_LANDSCAPE_LEFT = 3 ; private static final int UIDEVICE_ORIENTATION_LANDSCAPE_RIGHT = 4 ; private static final int UIDEVICE_ORIENTATION_FACE_UP = 5 ; private static final int UIDEVICE_ORIENTATION_FACE_DOWN = 6 ; private static final int SENSOR_PROXIMITY_VALUE_FAR = 0 ; private static final int SENSOR_PROXIMITY_VALUE_NEAR = 1 ; private static final int SENSOR_DELAY_MULTIPLIER = 1000 ; private static final int ACCELEROMETER_ADJUSTMENT = - 10 ; MoSyncThread mMoSyncThread ; private SensorManager mSensorManager ; private Sensor [ ] mSensorList ; private int [ ] mSensorRates ; private Activity getActivity ( ) { } public MoSyncSensor ( MoSyncThread thread ) { } @ Override public void onAccuracyChanged ( Sensor sensor , int accuracy ) { } @ Override public void onSensorChanged ( SensorEvent arg0 ) { } int maSensorStart ( int sensor , int interval ) { if ( ( sensor < ( MoSyncSensor . SENSOR_TYPE_ACCELEROMETER ) ) || ( sensor > ( MoSyncSensor . SENSOR_TYPE_PROXIMITY ) ) ) { return MoSyncSensor . SENSOR_ERROR_NOT_AVAILABLE ; } int rate = getSensorRate ( interval ) ; int sensorType = getSensorAndroidType ( sensor ) ; if ( ( mSensorList [ ( sensor - 1 ) ] ) != null ) { return MoSyncSensor . SENSOR_ERROR_ALREADY_ENABLED ; } mSensorList [ ( sensor - 1 ) ] = mSensorManager . getDefaultSensor ( sensorType ) ; if ( ( mSensorList [ ( sensor - 1 ) ] ) == null ) { return MoSyncSensor . SENSOR_ERROR_NOT_AVAILABLE ; } <START_BUG> mSensorRates [ ( sensor - 1 ) ] = interval ; <END_BUG> if ( ! ( mSensorManager . registerListener ( this , mSensorList [ ( sensor - 1 ) ] , rate ) ) ) { return MoSyncSensor . SENSOR_ERROR_INTERVAL_NOT_SET ; } return MoSyncSensor . SENSOR_ERROR_NONE ; } int getSensorMoSyncType ( int type ) { } int getSensorAndroidType ( int type ) { } int getSensorRate ( int interval ) { } int maSensorStop ( int sensor ) { } public void onResume ( ) { } public void onPause ( ) { } }

Fix:
mSensorRates [ ( sensor - 1 ) ] = rate ;