Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe6cd807 authored by Daniel Zheng's avatar Daniel Zheng
Browse files

add NDK support for moisture sensor

Bug: 371291781
Flag: com.android.tradeinmode.flags.trade_in_mode_2025q4
Test: th
Change-Id: If7d26f91ae34534ac599653b33a8f144318ac87e
parent 78d45e8f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -321,6 +321,13 @@ enum {
     * relative to true north in degrees.
     */
    ASENSOR_TYPE_HEADING = 42,
    /**
     * {@link ASENSOR_TYPE_MOISTURE_INTRUSION}
     * reporting-mode: on-change
     *
     * A moisture sensor that detects water intrusion within the chassis of a device
     */
    ASENSOR_TYPE_MOISTURE_INTRUSION = 43,
};

/**
+10 −0
Original line number Diff line number Diff line
@@ -30,6 +30,11 @@
 */
#define SENSOR_PERMISSION_ACTIVITY_RECOGNITION "android.permission.ACTIVITY_RECOGNITION"

/*
* The permission to detect moisture intrusion within chassis of a devices
*/
#define SENSOR_PERMISSION_MOISTURE_INTRUSION "android.permission.MOISTURE_INTRUSION"

// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
@@ -299,6 +304,11 @@ Sensor::Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersi
        mStringType = SENSOR_STRING_TYPE_HEADING;
        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
        break;
    case SENSOR_TYPE_MOISTURE_INTRUSION:
        mStringType = SENSOR_STRING_TYPE_MOISTURE_INTRUSION;
        mRequiredPermission = SENSOR_PERMISSION_MOISTURE_INTRUSION;
        mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
        break;
    default:
        // Only pipe the stringType, requiredPermission and flags for custom sensors.
        if (halVersion > SENSORS_DEVICE_API_VERSION_1_0 && hwSensor.stringType) {
+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ size_t eventSizeBySensorType(int type) {
        case SENSOR_TYPE_HEART_BEAT:
        case SENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT:
        case SENSOR_TYPE_HINGE_ANGLE:
        case SENSOR_TYPE_MOISTURE_INTRUSION:
            return 1;

        case SENSOR_TYPE_HEAD_TRACKER: