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

Commit 6656f0fc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "SensorManager"

* changes:
  Add feature for inputdevice sensor manager.
  Add motion sensor configuration for Sony DS4.
parents ec66eb30 1d29b4c0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46680,6 +46680,7 @@ package android.view {
    method public java.util.List<android.view.InputDevice.MotionRange> getMotionRanges();
    method public String getName();
    method public int getProductId();
    method @NonNull public android.hardware.SensorManager getSensorManager();
    method public int getSources();
    method public int getVendorId();
    method public android.os.Vibrator getVibrator();
+25 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.hardware;

import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.hardware.input.InputSensorInfo;
import android.os.Build;

/**
@@ -922,6 +923,30 @@ public final class Sensor {
    Sensor() {
    }

    /**
     * Construct a sensor object from SensorInfo of an input device.
     * This is only used for constructing an input device sensor object.
     * @hide
     */
    public Sensor(InputSensorInfo sensorInfo) {
        this.mName = sensorInfo.getName();
        this.mVendor = sensorInfo.getVendor();
        this.mVersion = sensorInfo.getVersion();
        this.mHandle = sensorInfo.getHandle();
        this.mType = sensorInfo.getType();
        this.mMaxRange = sensorInfo.getMaxRange();
        this.mResolution = sensorInfo.getResolution();
        this.mPower = sensorInfo.getPower();
        this.mMinDelay = sensorInfo.getMinDelay();
        this.mFifoReservedEventCount = sensorInfo.getFifoReservedEventCount();
        this.mFifoMaxEventCount = sensorInfo.getFifoMaxEventCount();
        this.mStringType = sensorInfo.getStringType();
        this.mRequiredPermission = sensorInfo.getRequiredPermission();
        this.mMaxDelay = sensorInfo.getMaxDelay();
        this.mFlags = sensorInfo.getFlags();
        this.mId = sensorInfo.getId();
    }

    /**
     * @return name string of the sensor.
     */
+13 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.hardware;

import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;

/**
@@ -667,4 +668,16 @@ public class SensorEvent {
    SensorEvent(int valueSize) {
        values = new float[valueSize];
    }

    /**
     * Construct a sensor event object by sensor object, accuracy, timestamp and values.
     * This is only used for constructing an input device sensor event object.
     * @hide
     */
    public SensorEvent(@NonNull Sensor sensor, int accuracy, long timestamp, float[] values) {
        this.sensor = sensor;
        this.accuracy = accuracy;
        this.timestamp = timestamp;
        this.values = values;
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.hardware.input.IInputDevicesChangedListener;
import android.hardware.input.ITabletModeChangedListener;
import android.hardware.input.TouchCalibration;
import android.os.CombinedVibrationEffect;
import android.hardware.input.IInputSensorEventListener;
import android.hardware.input.InputSensorInfo;
import android.os.IBinder;
import android.os.VibrationEffect;
import android.view.InputDevice;
@@ -105,4 +107,17 @@ interface IInputManager {
    // Remove the runtime association between the input port and the display port. Any existing
    // static association for the cleared input port will be restored.
    void removePortAssociation(in String inputPort);

    InputSensorInfo[] getSensorList(int deviceId);

    boolean registerSensorListener(IInputSensorEventListener listener);

    void unregisterSensorListener(IInputSensorEventListener listener);

    boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs,
                int maxBatchReportLatencyUs);

    void disableSensor(int deviceId, int sensorType);

    boolean flushSensor(int deviceId, int sensorType);
}
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.input;

/** @hide */
interface IInputSensorEventListener {
    /* Called when there is a new sensor event. */
    oneway void onInputSensorChanged(int deviceId, int sensorId, int accuracy, long timestamp,
            in float[] values);

    /* Called when the accuracy of the registered sensor has changed. */
    oneway void onInputSensorAccuracyChanged(int deviceId, int sensorId, int accuracy);
}
Loading