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

Commit 96bf7205 authored by Ravit Dennis's avatar Ravit Dennis
Browse files

Ultrasound: Add Digital Pen system service

The Ultrasound digital pen system service is responsible
for interacting with the ultrasound native layer, serving
as the entry point for configuring the feature, enabling/disabling
it and receiving pen notifications.

Change-Id: Ic54c2976c7ab1e0a1a3cce3fb27b5d7b6e0ad2b3
parent c6829793
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.hardware.input;

import android.graphics.Bitmap;
import android.hardware.input.KeyboardLayout;
import android.hardware.input.IInputDevicesChangedListener;
import android.os.IBinder;
@@ -56,4 +57,7 @@ interface IInputManager {
    // Input device vibrator control.
    void vibrate(int deviceId, in long[] pattern, int repeat, IBinder token);
    void cancelVibrate(int deviceId, IBinder token);

    // Custom hover icon support.
    void setCustomHoverIcon(in Bitmap icon, int hotSpotX, int hotSpotY);
}
+40 −0
Original line number Diff line number Diff line
@@ -25,8 +25,12 @@ import android.content.res.XmlResourceParser;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.hardware.input.IInputManager;
import android.hardware.input.IInputManager.Stub;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;

/**
@@ -59,6 +63,10 @@ public final class PointerIcon implements Parcelable {
    /** {@hide} Style constant: Spot anchor icon for touchpads. */
    public static final int STYLE_SPOT_ANCHOR = 2002;

    /** {@hide} Style constant: Hovering icon for stylus. */
    public static final int STYLE_STYLUS_HOVER = 2003;


    // OEM private styles should be defined starting at this range to avoid
    // conflicts with any system styles that may be defined in the future.
    private static final int STYLE_OEM_FIRST = 10000;
@@ -68,6 +76,9 @@ public final class PointerIcon implements Parcelable {

    private static final PointerIcon gNullIcon = new PointerIcon(STYLE_NULL);

    private static IInputManager sInputManager;
    private static Object sInputManagerSync = new Object();

    private final int mStyle;
    private int mSystemIconResourceId;
    private Bitmap mBitmap;
@@ -202,6 +213,24 @@ public final class PointerIcon implements Parcelable {
        return icon;
    }

    /**
     * Changes the shape of the hover cursor. If the cursor is
     * visible it will be changed as soon as possible.
     *
     * @param bitmap bitmap for the cursor
     * @param hotSpotX x position of hot-spot for cursor offset
     *                 adjustment
     * @param hotSpotY y position of hot-spot for cursor offset
     *                 adjustment
     *
     * @throws RemoteException if failed to set the cursor
     */
    public static void setCustomHoverIcon(Bitmap bitmap, int hotSpotX, int hotSpotY)
    throws RemoteException
    {
        getInputManager().setCustomHoverIcon(bitmap, hotSpotX, hotSpotY);
    }

    /**
     * Loads the bitmap and hotspot information for a pointer icon, if it is not already loaded.
     * Returns a pointer icon (not necessarily the same instance) with the information filled in.
@@ -428,8 +457,19 @@ public final class PointerIcon implements Parcelable {
                return com.android.internal.R.styleable.Pointer_pointerIconSpotTouch;
            case STYLE_SPOT_ANCHOR:
                return com.android.internal.R.styleable.Pointer_pointerIconSpotAnchor;
            case STYLE_STYLUS_HOVER:
                return com.android.internal.R.styleable.Pointer_pointerIconStylusHover;
            default:
                return 0;
        }
    }

    private static IInputManager getInputManager() {
        synchronized(sInputManagerSync) {
            if(sInputManager == null) {
                sInputManager = IInputManager.Stub.asInterface(ServiceManager.getService("input"));
            }
            return sInputManager;
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ enum {
    POINTER_ICON_STYLE_SPOT_HOVER = 2000,
    POINTER_ICON_STYLE_SPOT_TOUCH = 2001,
    POINTER_ICON_STYLE_SPOT_ANCHOR = 2002,
    POINTER_ICON_STYLE_STYLUS_HOVER = 2003,
};

/*
+1.99 KiB
Loading image diff...
+32 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are
     met:
         * Redistributions of source code must retain the above copyright
           notice, this list of conditions and the following disclaimer.
         * Redistributions in binary form must reproduce the above
           copyright notice, this list of conditions and the following
           disclaimer in the documentation and/or other materials provided
           with the distribution.
         * Neither the name of The Linux Foundation nor the names of its
           contributors may be used to endorse or promote products derived
           from this software without specific prior written permission.

     THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
     WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
     ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
    android:bitmap="@drawable/pointer_stylus_hover"
    android:hotSpotX="15"
    android:hotSpotY="15" />
Loading