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

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

Add moisture sensor to sensor framework

The moisture sensor detects (either 1 or 0) if water intrusion was ever
detected in the history of the device's usage (within it's chassis).

Bug: 371291781
Flag: com.android.tradeinmode.flags.trade_in_mode_2025q4
Test: th
Change-Id: Ia6797458dace6dcc1c37b69e7245a88fe2660f69
parent 13ad8d98
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@

package android.hardware;

import com.android.tradeinmode.flags.Flags;


import android.annotation.FlaggedApi;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -812,6 +816,27 @@ public final class Sensor {
     */
    public static final String STRING_TYPE_HEADING = "android.sensor.heading";

    /**
     * A constant describing a moisture intrusion sensor.
     *
     * See {@link android.hardware.SensorEvent#values SensorEvent.values} for more details.
     *
     * This sensor requires permission {@code android.permission.READ_MOISTURE_INTRUSION}.
     * It will not be returned by {@code SensorManager.getSensorsList} nor
     * {@code SensorManager.getDefaultSensor} if the application doesn't have this permission.
     * @hide This sensor is only expected to be used by platform services
     */
    @FlaggedApi(Flags.FLAG_TRADE_IN_MODE_2025Q4)
    public static final int TYPE_MOISTURE_INTRUSION = 43;

    /**
     * A constant string describing a moisture intrusion sensor.
     *
     * @see #TYPE_MOISTURE_INTRUSION
     * @hide This sensor is only expected to be used by platform services
     */
    @FlaggedApi(Flags.FLAG_TRADE_IN_MODE_2025Q4)
    public static final String STRING_TYPE_MOISTURE_INTRUSION = "android.sensor.moisture_intrusion";
    /**
     * A constant describing all sensor types.
     */
@@ -938,6 +963,7 @@ public final class Sensor {
            9, // SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED
            9, // SENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED
            2, // SENSOR_TYPE_HEADING
            1, // SENSOR_TYPE_MOISTURE_INTRUSION
    };

    /**
@@ -1410,6 +1436,9 @@ public final class Sensor {
            case TYPE_HEADING:
                mStringType = STRING_TYPE_HEADING;
                return true;
            case TYPE_MOISTURE_INTRUSION:
                mStringType = STRING_TYPE_MOISTURE_INTRUSION;
                return true;
            default:
                return false;
        }