Loading core/java/android/hardware/Sensor.java +22 −12 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.compat.annotation.UnsupportedAppUsage; import android.hardware.input.InputSensorInfo; import android.hardware.input.InputSensorInfo; import android.os.Build; import android.os.Build; import java.util.UUID; /** /** * Class representing a sensor. Use {@link SensorManager#getSensorList} to get * Class representing a sensor. Use {@link SensorManager#getSensorList} to get * the list of available sensors. For more information about Android sensors, * the list of available sensors. For more information about Android sensors, Loading Loading @@ -925,6 +927,7 @@ public final class Sensor { @UnsupportedAppUsage @UnsupportedAppUsage private int mFlags; private int mFlags; private int mId; private int mId; private UUID mUuid; Sensor() { Sensor() { } } Loading @@ -951,6 +954,8 @@ public final class Sensor { this.mMaxDelay = sensorInfo.getMaxDelay(); this.mMaxDelay = sensorInfo.getMaxDelay(); this.mFlags = sensorInfo.getFlags(); this.mFlags = sensorInfo.getFlags(); this.mId = sensorInfo.getId(); this.mId = sensorInfo.getId(); // The UUID is never specified when creating a sensor from Input manager this.mUuid = new UUID((long) this.mId, 0); } } /** /** Loading Loading @@ -1040,11 +1045,9 @@ public final class Sensor { } } /** /** * Do not use. * Reserved for system and audio servers. * * When called from an unauthorized context, the UUID will contain the * This method throws an UnsupportedOperationException. * sensor ID in the MSB and 0 in the LSB. * * Use getId() if you want a unique ID. * * * @see getId * @see getId * * Loading @@ -1052,7 +1055,7 @@ public final class Sensor { */ */ @SystemApi @SystemApi public java.util.UUID getUuid() { public java.util.UUID getUuid() { throw new UnsupportedOperationException(); return mUuid; } } /** /** Loading Loading @@ -1286,17 +1289,24 @@ public final class Sensor { } } /** /** * Sets the ID associated with the sensor. * Sets the UUID associated with the sensor. * * * The method name is misleading; while this ID is based on the UUID, * NOTE: to be used only by native bindings in SensorManager. * we do not pass in the actual UUID. * * @see #getUuid */ private void setUuid(long msb, long lsb) { mUuid = new UUID(msb, lsb); } /** * Sets the ID associated with the sensor. * * * NOTE: to be used only by native bindings in SensorManager. * NOTE: to be used only by native bindings in SensorManager. * * * @see #getId * @see #getId */ */ private void setUuid(long msb, long lsb) { private void setId(int id) { // TODO(b/29547335): Rename this method to setId. mId = id; mId = (int) msb; } } } } core/jni/android_hardware_SensorManager.cpp +6 −3 Original line number Original line Diff line number Diff line Loading @@ -66,6 +66,7 @@ struct SensorOffsets jfieldID flags; jfieldID flags; //methods //methods jmethodID setType; jmethodID setType; jmethodID setId; jmethodID setUuid; jmethodID setUuid; jmethodID init; jmethodID init; } gSensorOffsets; } gSensorOffsets; Loading Loading @@ -112,6 +113,7 @@ nativeClassInit (JNIEnv *_env, jclass _this) sensorOffsets.flags = GetFieldIDOrDie(_env,sensorClass, "mFlags", "I"); sensorOffsets.flags = GetFieldIDOrDie(_env,sensorClass, "mFlags", "I"); sensorOffsets.setType = GetMethodIDOrDie(_env,sensorClass, "setType", "(I)Z"); sensorOffsets.setType = GetMethodIDOrDie(_env,sensorClass, "setType", "(I)Z"); sensorOffsets.setId = GetMethodIDOrDie(_env,sensorClass, "setId", "(I)V"); sensorOffsets.setUuid = GetMethodIDOrDie(_env,sensorClass, "setUuid", "(JJ)V"); sensorOffsets.setUuid = GetMethodIDOrDie(_env,sensorClass, "setUuid", "(JJ)V"); sensorOffsets.init = GetMethodIDOrDie(_env,sensorClass, "<init>", "()V"); sensorOffsets.init = GetMethodIDOrDie(_env,sensorClass, "<init>", "()V"); Loading Loading @@ -188,9 +190,10 @@ translateNativeSensorToJavaSensor(JNIEnv *env, jobject sensor, const Sensor& nat env->SetObjectField(sensor, sensorOffsets.stringType, stringType); env->SetObjectField(sensor, sensorOffsets.stringType, stringType); } } // TODO(b/29547335): Rename "setUuid" method to "setId". int32_t id = nativeSensor.getId(); int64_t id = nativeSensor.getId(); env->CallVoidMethod(sensor, sensorOffsets.setId, id); env->CallVoidMethod(sensor, sensorOffsets.setUuid, id, 0); Sensor::uuid_t uuid = nativeSensor.getUuid(); env->CallVoidMethod(sensor, sensorOffsets.setUuid, id, uuid.i64[0], uuid.i64[1]); } } return sensor; return sensor; } } Loading Loading
core/java/android/hardware/Sensor.java +22 −12 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.compat.annotation.UnsupportedAppUsage; import android.hardware.input.InputSensorInfo; import android.hardware.input.InputSensorInfo; import android.os.Build; import android.os.Build; import java.util.UUID; /** /** * Class representing a sensor. Use {@link SensorManager#getSensorList} to get * Class representing a sensor. Use {@link SensorManager#getSensorList} to get * the list of available sensors. For more information about Android sensors, * the list of available sensors. For more information about Android sensors, Loading Loading @@ -925,6 +927,7 @@ public final class Sensor { @UnsupportedAppUsage @UnsupportedAppUsage private int mFlags; private int mFlags; private int mId; private int mId; private UUID mUuid; Sensor() { Sensor() { } } Loading @@ -951,6 +954,8 @@ public final class Sensor { this.mMaxDelay = sensorInfo.getMaxDelay(); this.mMaxDelay = sensorInfo.getMaxDelay(); this.mFlags = sensorInfo.getFlags(); this.mFlags = sensorInfo.getFlags(); this.mId = sensorInfo.getId(); this.mId = sensorInfo.getId(); // The UUID is never specified when creating a sensor from Input manager this.mUuid = new UUID((long) this.mId, 0); } } /** /** Loading Loading @@ -1040,11 +1045,9 @@ public final class Sensor { } } /** /** * Do not use. * Reserved for system and audio servers. * * When called from an unauthorized context, the UUID will contain the * This method throws an UnsupportedOperationException. * sensor ID in the MSB and 0 in the LSB. * * Use getId() if you want a unique ID. * * * @see getId * @see getId * * Loading @@ -1052,7 +1055,7 @@ public final class Sensor { */ */ @SystemApi @SystemApi public java.util.UUID getUuid() { public java.util.UUID getUuid() { throw new UnsupportedOperationException(); return mUuid; } } /** /** Loading Loading @@ -1286,17 +1289,24 @@ public final class Sensor { } } /** /** * Sets the ID associated with the sensor. * Sets the UUID associated with the sensor. * * * The method name is misleading; while this ID is based on the UUID, * NOTE: to be used only by native bindings in SensorManager. * we do not pass in the actual UUID. * * @see #getUuid */ private void setUuid(long msb, long lsb) { mUuid = new UUID(msb, lsb); } /** * Sets the ID associated with the sensor. * * * NOTE: to be used only by native bindings in SensorManager. * NOTE: to be used only by native bindings in SensorManager. * * * @see #getId * @see #getId */ */ private void setUuid(long msb, long lsb) { private void setId(int id) { // TODO(b/29547335): Rename this method to setId. mId = id; mId = (int) msb; } } } }
core/jni/android_hardware_SensorManager.cpp +6 −3 Original line number Original line Diff line number Diff line Loading @@ -66,6 +66,7 @@ struct SensorOffsets jfieldID flags; jfieldID flags; //methods //methods jmethodID setType; jmethodID setType; jmethodID setId; jmethodID setUuid; jmethodID setUuid; jmethodID init; jmethodID init; } gSensorOffsets; } gSensorOffsets; Loading Loading @@ -112,6 +113,7 @@ nativeClassInit (JNIEnv *_env, jclass _this) sensorOffsets.flags = GetFieldIDOrDie(_env,sensorClass, "mFlags", "I"); sensorOffsets.flags = GetFieldIDOrDie(_env,sensorClass, "mFlags", "I"); sensorOffsets.setType = GetMethodIDOrDie(_env,sensorClass, "setType", "(I)Z"); sensorOffsets.setType = GetMethodIDOrDie(_env,sensorClass, "setType", "(I)Z"); sensorOffsets.setId = GetMethodIDOrDie(_env,sensorClass, "setId", "(I)V"); sensorOffsets.setUuid = GetMethodIDOrDie(_env,sensorClass, "setUuid", "(JJ)V"); sensorOffsets.setUuid = GetMethodIDOrDie(_env,sensorClass, "setUuid", "(JJ)V"); sensorOffsets.init = GetMethodIDOrDie(_env,sensorClass, "<init>", "()V"); sensorOffsets.init = GetMethodIDOrDie(_env,sensorClass, "<init>", "()V"); Loading Loading @@ -188,9 +190,10 @@ translateNativeSensorToJavaSensor(JNIEnv *env, jobject sensor, const Sensor& nat env->SetObjectField(sensor, sensorOffsets.stringType, stringType); env->SetObjectField(sensor, sensorOffsets.stringType, stringType); } } // TODO(b/29547335): Rename "setUuid" method to "setId". int32_t id = nativeSensor.getId(); int64_t id = nativeSensor.getId(); env->CallVoidMethod(sensor, sensorOffsets.setId, id); env->CallVoidMethod(sensor, sensorOffsets.setUuid, id, 0); Sensor::uuid_t uuid = nativeSensor.getUuid(); env->CallVoidMethod(sensor, sensorOffsets.setUuid, id, uuid.i64[0], uuid.i64[1]); } } return sensor; return sensor; } } Loading