Merge changes from topic "equalizer"
* changes:
Update Java doc of SensorManager.createDirectChannel
sensors: pass sensor handle along with injected event
diff --git a/core/java/android/hardware/SensorAdditionalInfo.java b/core/java/android/hardware/SensorAdditionalInfo.java
index ea1d01b..0c6a415 100644
--- a/core/java/android/hardware/SensorAdditionalInfo.java
+++ b/core/java/android/hardware/SensorAdditionalInfo.java
@@ -189,6 +189,16 @@
*/
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;
@@ -211,4 +221,13 @@
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);
+ }
}
diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java
index 4bc62b1..e1cd451 100644
--- a/core/java/android/hardware/SensorManager.java
+++ b/core/java/android/hardware/SensorManager.java
@@ -894,8 +894,9 @@
* to free up resource in sensor system associated with the direct channel.
*
* @param mem A {@link android.os.MemoryFile} shared memory object.
- * @return A {@link android.hardware.SensorDirectChannel} object if successful, null otherwise.
+ * @return A {@link android.hardware.SensorDirectChannel} object.
* @throws NullPointerException when mem is null.
+ * @throws UncheckedIOException if not able to create channel.
* @see SensorDirectChannel#close()
* @see #configureDirectChannel(SensorDirectChannel, Sensor, int)
*/
@@ -916,9 +917,9 @@
* to free up resource in sensor system associated with the direct channel.
*
* @param mem A {@link android.hardware.HardwareBuffer} shared memory object.
- * @return A {@link android.hardware.SensorDirectChannel} object if successful,
- * null otherwise.
+ * @return A {@link android.hardware.SensorDirectChannel} object.
* @throws NullPointerException when mem is null.
+ * @throws UncheckedIOException if not able to create channel.
* @see SensorDirectChannel#close()
* @see #configureDirectChannel(SensorDirectChannel, Sensor, int)
*/
diff --git a/core/java/android/hardware/SystemSensorManager.java b/core/java/android/hardware/SystemSensorManager.java
index 0dab5d7..607788d 100644
--- a/core/java/android/hardware/SystemSensorManager.java
+++ b/core/java/android/hardware/SystemSensorManager.java
@@ -68,7 +68,7 @@
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")
@@ -956,7 +956,9 @@
}
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;
}
}
diff --git a/core/jni/android_hardware_SensorManager.cpp b/core/jni/android_hardware_SensorManager.cpp
index 60ac74c..5b327d4 100644
--- a/core/jni/android_hardware_SensorManager.cpp
+++ b/core/jni/android_hardware_SensorManager.cpp
@@ -270,7 +270,7 @@
}
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;
@@ -285,7 +285,7 @@
_env->GetIntArrayRegion(ints, 0, _env->GetArrayLength(ints), int32Vector.editArray());
}
- return mgr->setOperationParameter(type, floatVector, int32Vector);
+ return mgr->setOperationParameter(handle, type, floatVector, int32Vector);
}
//----------------------------------------------------------------------------
@@ -512,7 +512,7 @@
(void*)nativeConfigDirectChannel },
{"nativeSetOperationParameter",
- "(JI[F[I)I",
+ "(JII[F[I)I",
(void*)nativeSetOperationParameter },
};