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

Commit fa19d374 authored by Abdelrahman Awadalla's avatar Abdelrahman Awadalla Committed by Android (Google) Code Review
Browse files

Merge "Notify TouchpadDebugActivity on finger/hardware state changes" into main

parents d0abd9de db358bc6
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ import android.os.VibrationEffect;
import android.os.vibrator.StepSegment;
import android.os.vibrator.VibrationEffectSegment;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.IndentingPrintWriter;
@@ -2268,6 +2269,18 @@ public class InputManagerService extends IInputManager.Stub
        mWindowManagerCallbacks.notifyConfigurationChanged();
    }

    // Native callback.
    @SuppressWarnings("unused")
    private void notifyTouchpadHardwareState(TouchpadHardwareState hardwareStates, int deviceId) {
        // TODO(b/286551975): sent the touchpad hardware state data here to TouchpadDebugActivity
        Slog.d(TAG, "notifyTouchpadHardwareState: Time: "
                + hardwareStates.getTimestamp() + ", No. Buttons: "
                + hardwareStates.getButtonsDown() + ", No. Fingers: "
                + hardwareStates.getFingerCount() + ", No. Touch: "
                + hardwareStates.getTouchCount() + ", Id: "
                + deviceId);
    }

    // Native callback.
    @SuppressWarnings("unused")
    private void notifySwitch(long whenNanos, int switchValues, int switchMask) {
+261 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 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 com.android.server.input;

import com.android.internal.util.DataClass;
import com.android.tools.r8.keepanno.annotations.KeepItemKind;
import com.android.tools.r8.keepanno.annotations.UsedByNative;

/**
 * This class represents the Touchpad Finger State of a single contact on the touchpad.
 * It is used for the touchpad visualizer project at TouchpadDebugActivity
 */
@DataClass(genToString = true)
@UsedByNative(
        description = "Called from JNI in jni/com_android_server_input_InputManagerService.cpp",
        kind = KeepItemKind.CLASS_AND_MEMBERS)
public final class TouchpadFingerState{
    /**
     * The large radius of the ellipse of the finger touching the pad.
     */
    private final float mTouchMajor;

    /**
     * The small radius of the ellipse of the finger touching the pad.
     */
    private final float mTouchMinor;

    /**
     * The large radius of the ellipse of the finger, including parts
     * that are hovering over the pad but not quite touching.
     */
    private final float mWidthMajor;

    /**
     * The small radius of the ellipse of the finger, including parts
     * that are hovering over the pad but not quite touching.
     */
    private final float mWidthMinor;

    /**
     * Pressure applied by a finger on the touchpad.
     */
    private final float mPressure;

    /**
     * Orientation of a finger on the touchpad. Measured in radians.
     */
    private final float mOrientation;

    /**
     * The X-coordinate of the center of the ellipse that represents a finger.
     */
    private final float mPositionX;

    /**
     * The Y-coordinate of the center of the ellipse that represents a finger.
     */
    private final float mPositionY;

    /**
     * A number that identifies a single physical finger across consecutive frames.
     * If a finger is the same physical finger across two consecutive frames, it
     * must have the same tracking ID; if it's a different finger, it should
     * have a different tracking ID.
     */
    private final int mTrackingId;


    // Code below generated by codegen v1.0.23.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/input/
    // TouchpadFingerState.java
    //
    // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
    //   Settings > Editor > Code Style > Formatter Control
    //@formatter:off

    /**
     * Creates a new TouchpadFingerState.
     *
     * @param touchMajor
     *   The large radius of the ellipse of the finger touching the pad.
     * @param touchMinor
     *   The small radius of the ellipse of the finger touching the pad.
     * @param widthMajor
     *   The large radius of the ellipse of the finger, including parts
     *   that are hovering over the pad but not quite touching.
     * @param widthMinor
     *   The small radius of the ellipse of the finger, including parts
     *   that are hovering over the pad but not quite touching.
     * @param pressure
     *   Pressure applied by a finger on the touchpad.
     * @param orientation
     *   Orientation of a finger on the touchpad. Measured in radians.
     * @param positionX
     *   The X-coordinate of the center of the ellipse that represents a finger.
     * @param positionY
     *   The Y-coordinate of the center of the ellipse that represents a finger.
     * @param trackingId
     *   A number that identifies a single physical finger across consecutive frames.
     *   If a finger is the same physical finger across two consecutive frames, it
     *   must have the same tracking ID; if it's a different finger, it should
     *   have a different tracking ID.
     */
    @DataClass.Generated.Member
    public TouchpadFingerState(
            float touchMajor,
            float touchMinor,
            float widthMajor,
            float widthMinor,
            float pressure,
            float orientation,
            float positionX,
            float positionY,
            int trackingId) {
        this.mTouchMajor = touchMajor;
        this.mTouchMinor = touchMinor;
        this.mWidthMajor = widthMajor;
        this.mWidthMinor = widthMinor;
        this.mPressure = pressure;
        this.mOrientation = orientation;
        this.mPositionX = positionX;
        this.mPositionY = positionY;
        this.mTrackingId = trackingId;

        // onConstructed(); // You can define this method to get a callback
    }

    /**
     * The large radius of the ellipse of the finger touching the pad.
     */
    @DataClass.Generated.Member
    public float getTouchMajor() {
        return mTouchMajor;
    }

    /**
     * The small radius of the ellipse of the finger touching the pad.
     */
    @DataClass.Generated.Member
    public float getTouchMinor() {
        return mTouchMinor;
    }

    /**
     * The large radius of the ellipse of the finger, including parts
     * that are hovering over the pad but not quite touching.
     */
    @DataClass.Generated.Member
    public float getWidthMajor() {
        return mWidthMajor;
    }

    /**
     * The small radius of the ellipse of the finger, including parts
     * that are hovering over the pad but not quite touching.
     */
    @DataClass.Generated.Member
    public float getWidthMinor() {
        return mWidthMinor;
    }

    /**
     * Pressure applied by a finger on the touchpad.
     */
    @DataClass.Generated.Member
    public float getPressure() {
        return mPressure;
    }

    /**
     * Orientation of a finger on the touchpad. Measured in radians.
     */
    @DataClass.Generated.Member
    public float getOrientation() {
        return mOrientation;
    }

    /**
     * The X-coordinate of the center of the ellipse that represents a finger.
     */
    @DataClass.Generated.Member
    public float getPositionX() {
        return mPositionX;
    }

    /**
     * The Y-coordinate of the center of the ellipse that represents a finger.
     */
    @DataClass.Generated.Member
    public float getPositionY() {
        return mPositionY;
    }

    /**
     * A number that identifies a single physical finger across consecutive frames.
     * If a finger is the same physical finger across two consecutive frames, it
     * must have the same tracking ID; if it's a different finger, it should
     * have a different tracking ID.
     */
    @DataClass.Generated.Member
    public int getTrackingId() {
        return mTrackingId;
    }

    @Override
    @DataClass.Generated.Member
    public String toString() {
        // You can override field toString logic by defining methods like:
        // String fieldNameToString() { ... }

        return "TouchpadFingerState { " +
                "touchMajor = " + mTouchMajor + ", " +
                "touchMinor = " + mTouchMinor + ", " +
                "widthMajor = " + mWidthMajor + ", " +
                "widthMinor = " + mWidthMinor + ", " +
                "pressure = " + mPressure + ", " +
                "orientation = " + mOrientation + ", " +
                "positionX = " + mPositionX + ", " +
                "positionY = " + mPositionY + ", " +
                "trackingId = " + mTrackingId +
        " }";
    }

    @DataClass.Generated(
            time = 1724078820706L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/services/core/java/com/android/server/input/"
                    + "TouchpadFingerState.java",
            inputSignatures = "private final  float mTouchMajor\nprivate final  float mTouchMinor\n"
                    + "private final  float mWidthMajor\nprivate final  float mWidthMinor\nprivate"
                    + " final  float mPressure\nprivate final  float mOrientation\nprivate final  "
                    + "float mPositionX\nprivate final  float mPositionY\nprivate final  int "
                    + "mTrackingId\nclass TouchpadFingerState extends java.lang.Object implements"
                    + " []\n@com.android.internal.util.DataClass(genToString=true)")
    @Deprecated
    private void __metadata() {}


    //@formatter:on
    // End of generated code

}
+185 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 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 com.android.server.input;

import android.annotation.NonNull;

import com.android.internal.util.AnnotationValidations;
import com.android.internal.util.DataClass;
import com.android.tools.r8.keepanno.annotations.KeepItemKind;
import com.android.tools.r8.keepanno.annotations.UsedByNative;

/**
 * This class represents a touchpad hardware state at a single moment in time.
 * It is only used by the touchpad visualization which is implemented in TouchpadDebugActivity.
 */
@DataClass(genToString = true)
@UsedByNative(
        description = "Called from JNI in jni/com_android_server_input_InputManagerService.cpp",
        kind = KeepItemKind.CLASS_AND_MEMBERS)
public final class TouchpadHardwareState{
    /**
     * The time at which the event was received by the system.
     * The time is in milliseconds and start counting when the program starts.
      */
    private final float mTimestamp;

    /**
     * Number of buttons pressed. Note that in our case while using
     * a touchpad only one button is available and can be pressed.
     */
    private final int mButtonsDown;

    /**
     * The number of FingerState structs pointed to by the fingers field.
     */
    private final int mFingerCount;

    /**
     * The number of fingers touching the pad, which may be more than fingerCount.
     */
    private final int mTouchCount;

    /**
     * Array of fingerStates that indicates the properties of each finger touching the touchpad.
     */
    private final @NonNull TouchpadFingerState[] mFingerStates;

    // Code below generated by codegen v1.0.23.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/input/
    // TouchpadHardwareState.java
    //
    // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
    //   Settings > Editor > Code Style > Formatter Control
    //@formatter:off


    /**
     * Creates a new TouchpadHardwareState.
     *
     * @param timestamp
     *   The time at which the event was received by the system.
     *   The time is in milliseconds and start counting when the program starts.
     * @param buttonsDown
     *   Number of buttons pressed. Note that in our case while using
     *   a touchpad only one button is available and can be pressed.
     * @param fingerCount
     *   The number of FingerState structs pointed to by the fingers field.
     * @param touchCount
     *   The number of fingers touching the pad, which may be more than fingerCount.
     * @param fingerStates
     *   Array of fingerStates that indicates the properties of each finger touching the touchpad.
     */
    @DataClass.Generated.Member
    public TouchpadHardwareState(
            float timestamp,
            int buttonsDown,
            int fingerCount,
            int touchCount,
            @NonNull TouchpadFingerState[] fingerStates) {
        this.mTimestamp = timestamp;
        this.mButtonsDown = buttonsDown;
        this.mFingerCount = fingerCount;
        this.mTouchCount = touchCount;
        this.mFingerStates = fingerStates;
        AnnotationValidations.validate(
                NonNull.class, null, mFingerStates);

        // onConstructed(); // You can define this method to get a callback
    }

    /**
     * The time at which the event was received by the system.
     * The time is in milliseconds and start counting when the program starts.
     */
    @DataClass.Generated.Member
    public float getTimestamp() {
        return mTimestamp;
    }

    /**
     * Number of buttons pressed. Note that in our case while using
     * a touchpad only one button is available and can be pressed.
     */
    @DataClass.Generated.Member
    public int getButtonsDown() {
        return mButtonsDown;
    }

    /**
     * The number of FingerState structs pointed to by the fingers field.
     */
    @DataClass.Generated.Member
    public int getFingerCount() {
        return mFingerCount;
    }

    /**
     * The number of fingers touching the pad, which may be more than fingerCount.
     */
    @DataClass.Generated.Member
    public int getTouchCount() {
        return mTouchCount;
    }

    /**
     * Array of fingerStates that indicates the properties of each finger touching the touchpad.
     */
    @DataClass.Generated.Member
    public @NonNull TouchpadFingerState[] getFingerStates() {
        return mFingerStates;
    }

    @Override
    @DataClass.Generated.Member
    public String toString() {
        // You can override field toString logic by defining methods like:
        // String fieldNameToString() { ... }

        return "TouchpadHardwareState { " +
                "timestamp = " + mTimestamp + ", " +
                "buttonsDown = " + mButtonsDown + ", " +
                "fingerCount = " + mFingerCount + ", " +
                "touchCount = " + mTouchCount + ", " +
                "fingerStates = " + java.util.Arrays.toString(mFingerStates) +
        " }";
    }

    @DataClass.Generated(
            time = 1724079048292L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/services/core/java/com/android/server/input/"
                    + "TouchpadHardwareState.java",
            inputSignatures = "private final  float mTimestamp\nprivate final  int mButtonsDown\n"
                    + "private final  int mFingerCount\nprivate final  int mTouchCount\nprivate "
                    + "final @android.annotation.NonNull com.android.server.input."
                    + "TouchpadFingerState[] mFingerStates\nclass TouchpadHardwareState extends "
                    + "java.lang.Object implements []\n@com.android.internal.util.DataClass"
                    + "(genToString=true)")
    @Deprecated
    private void __metadata() {}


    //@formatter:on
    // End of generated code

}
+166 −0

File changed.

Preview size limit exceeded, changes collapsed.