Loading core/java/android/hardware/SensorAdditionalInfo.java +19 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,16 @@ public class SensorAdditionalInfo { */ public static final int TYPE_MAGNETIC_FIELD_CALIBRATION = 0x30004; /** * Custom sensor info: array of float values interpreted by sensor based on the type * Any type between TYPE_CUSTOM_INFO <= info_type < TYPE_DEBUG_INFO may be * used to send custom sensor info. * @hide */ public static final int TYPE_CUSTOM_INFO = 0x10000000; /** @hide */ public static final int TYPE_DEBUG_INFO = 0x40000000; SensorAdditionalInfo( Sensor aSensor, int aType, int aSerial, int [] aIntValues, float [] aFloatValues) { sensor = aSensor; Loading @@ -211,4 +221,13 @@ public class SensorAdditionalInfo { null, TYPE_LOCAL_GEOMAGNETIC_FIELD, 0, null, new float[] { strength, declination, inclination}); } /** @hide */ public static SensorAdditionalInfo createCustomInfo(Sensor aSensor, int type, float [] data) { if (type < TYPE_CUSTOM_INFO || type >= TYPE_DEBUG_INFO || aSensor == null) { throw new IllegalArgumentException("invalid parameter(s): type: " + type + "; sensor: " + aSensor); } return new SensorAdditionalInfo(aSensor, type, 0, null, data); } } core/java/android/hardware/SystemSensorManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public class SystemSensorManager extends SensorManager { long nativeInstance, int channelHandle, int sensorHandle, int rate); private static native int nativeSetOperationParameter( long nativeInstance, int type, float[] floatValues, int[] intValues); long nativeInstance, int handle, int type, float[] floatValues, int[] intValues); private static final Object sLock = new Object(); @GuardedBy("sLock") Loading Loading @@ -956,7 +956,9 @@ public class SystemSensorManager extends SensorManager { } protected boolean setOperationParameterImpl(SensorAdditionalInfo parameter) { int handle = -1; if (parameter.sensor != null) handle = parameter.sensor.getHandle(); return nativeSetOperationParameter( mNativeInstance, parameter.type, parameter.floatValues, parameter.intValues) == 0; mNativeInstance, handle, parameter.type, parameter.floatValues, parameter.intValues) == 0; } } core/jni/android_hardware_SensorManager.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -270,7 +270,7 @@ static jint nativeConfigDirectChannel(JNIEnv *_env, jclass _this, jlong sensorMa } static jint nativeSetOperationParameter(JNIEnv *_env, jclass _this, jlong sensorManager, jint type, jfloatArray floats, jintArray ints) { jint handle, jint type, jfloatArray floats, jintArray ints) { SensorManager* mgr = reinterpret_cast<SensorManager*>(sensorManager); Vector<float> floatVector; Vector<int32_t> int32Vector; Loading @@ -285,7 +285,7 @@ static jint nativeSetOperationParameter(JNIEnv *_env, jclass _this, jlong sensor _env->GetIntArrayRegion(ints, 0, _env->GetArrayLength(ints), int32Vector.editArray()); } return mgr->setOperationParameter(type, floatVector, int32Vector); return mgr->setOperationParameter(handle, type, floatVector, int32Vector); } //---------------------------------------------------------------------------- Loading Loading @@ -512,7 +512,7 @@ static const JNINativeMethod gSystemSensorManagerMethods[] = { (void*)nativeConfigDirectChannel }, {"nativeSetOperationParameter", "(JI[F[I)I", "(JII[F[I)I", (void*)nativeSetOperationParameter }, }; Loading Loading
core/java/android/hardware/SensorAdditionalInfo.java +19 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,16 @@ public class SensorAdditionalInfo { */ public static final int TYPE_MAGNETIC_FIELD_CALIBRATION = 0x30004; /** * Custom sensor info: array of float values interpreted by sensor based on the type * Any type between TYPE_CUSTOM_INFO <= info_type < TYPE_DEBUG_INFO may be * used to send custom sensor info. * @hide */ public static final int TYPE_CUSTOM_INFO = 0x10000000; /** @hide */ public static final int TYPE_DEBUG_INFO = 0x40000000; SensorAdditionalInfo( Sensor aSensor, int aType, int aSerial, int [] aIntValues, float [] aFloatValues) { sensor = aSensor; Loading @@ -211,4 +221,13 @@ public class SensorAdditionalInfo { null, TYPE_LOCAL_GEOMAGNETIC_FIELD, 0, null, new float[] { strength, declination, inclination}); } /** @hide */ public static SensorAdditionalInfo createCustomInfo(Sensor aSensor, int type, float [] data) { if (type < TYPE_CUSTOM_INFO || type >= TYPE_DEBUG_INFO || aSensor == null) { throw new IllegalArgumentException("invalid parameter(s): type: " + type + "; sensor: " + aSensor); } return new SensorAdditionalInfo(aSensor, type, 0, null, data); } }
core/java/android/hardware/SystemSensorManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public class SystemSensorManager extends SensorManager { long nativeInstance, int channelHandle, int sensorHandle, int rate); private static native int nativeSetOperationParameter( long nativeInstance, int type, float[] floatValues, int[] intValues); long nativeInstance, int handle, int type, float[] floatValues, int[] intValues); private static final Object sLock = new Object(); @GuardedBy("sLock") Loading Loading @@ -956,7 +956,9 @@ public class SystemSensorManager extends SensorManager { } protected boolean setOperationParameterImpl(SensorAdditionalInfo parameter) { int handle = -1; if (parameter.sensor != null) handle = parameter.sensor.getHandle(); return nativeSetOperationParameter( mNativeInstance, parameter.type, parameter.floatValues, parameter.intValues) == 0; mNativeInstance, handle, parameter.type, parameter.floatValues, parameter.intValues) == 0; } }
core/jni/android_hardware_SensorManager.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -270,7 +270,7 @@ static jint nativeConfigDirectChannel(JNIEnv *_env, jclass _this, jlong sensorMa } static jint nativeSetOperationParameter(JNIEnv *_env, jclass _this, jlong sensorManager, jint type, jfloatArray floats, jintArray ints) { jint handle, jint type, jfloatArray floats, jintArray ints) { SensorManager* mgr = reinterpret_cast<SensorManager*>(sensorManager); Vector<float> floatVector; Vector<int32_t> int32Vector; Loading @@ -285,7 +285,7 @@ static jint nativeSetOperationParameter(JNIEnv *_env, jclass _this, jlong sensor _env->GetIntArrayRegion(ints, 0, _env->GetArrayLength(ints), int32Vector.editArray()); } return mgr->setOperationParameter(type, floatVector, int32Vector); return mgr->setOperationParameter(handle, type, floatVector, int32Vector); } //---------------------------------------------------------------------------- Loading Loading @@ -512,7 +512,7 @@ static const JNINativeMethod gSystemSensorManagerMethods[] = { (void*)nativeConfigDirectChannel }, {"nativeSetOperationParameter", "(JI[F[I)I", "(JII[F[I)I", (void*)nativeSetOperationParameter }, }; Loading