Merge changes from topic "equalizer"

* changes:
  Update Java doc of SensorManager.createDirectChannel
  sensors: pass sensor handle along with injected event
This commit is contained in:
Peng Xu
2017-09-23 00:17:10 +00:00
committed by Gerrit Code Review
4 changed files with 30 additions and 8 deletions

View File

@@ -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;
@@ -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);
}
}

View File

@@ -894,8 +894,9 @@ public abstract class SensorManager {
* 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 @@ public abstract class SensorManager {
* 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)
*/

View File

@@ -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")
@@ -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;
}
}

View File

@@ -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;
@@ -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);
}
//----------------------------------------------------------------------------
@@ -512,7 +512,7 @@ static const JNINativeMethod gSystemSensorManagerMethods[] = {
(void*)nativeConfigDirectChannel },
{"nativeSetOperationParameter",
"(JI[F[I)I",
"(JII[F[I)I",
(void*)nativeSetOperationParameter },
};