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

Commit 1cc78672 authored by Robert Carr's avatar Robert Carr
Browse files

InputFlinger: Receive setInputWindows over IPC

Plumbing to expose the InputManager object as an InputFlinger
service with a single setInputWindows method.

Bug: 80101428
Bug: 113136004
Bug: 111440400
Change-Id: I6e63a7e251711993334d930d2b95352e6cba031e
parent 4e670e5d
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -22,6 +22,9 @@


#include <binder/IInterface.h>
#include <binder/IInterface.h>


#include <utils/Vector.h>
#include <input/InputWindow.h>

namespace android {
namespace android {


/*
/*
@@ -31,6 +34,8 @@ namespace android {
class IInputFlinger : public IInterface {
class IInputFlinger : public IInterface {
public:
public:
    DECLARE_META_INTERFACE(InputFlinger)
    DECLARE_META_INTERFACE(InputFlinger)

    virtual void setInputWindows(const Vector<InputWindowInfo>& inputHandles) = 0;
};
};




@@ -40,7 +45,7 @@ public:
class BnInputFlinger : public BnInterface<IInputFlinger> {
class BnInputFlinger : public BnInterface<IInputFlinger> {
public:
public:
    enum {
    enum {
        DO_SOMETHING_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
        SET_INPUT_WINDOWS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
    };
    };


    virtual status_t onTransact(uint32_t code, const Parcel& data,
    virtual status_t onTransact(uint32_t code, const Parcel& data,
+3 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,9 @@ class Parcel;
 * Describes the properties of a window that can receive input.
 * Describes the properties of a window that can receive input.
 */
 */
struct InputWindowInfo {
struct InputWindowInfo {
    InputWindowInfo() = default;
    InputWindowInfo(const Parcel& from);

    // Window flags from WindowManager.LayoutParams
    // Window flags from WindowManager.LayoutParams
    enum {
    enum {
        FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001,
        FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001,
+2 −2
Original line number Original line Diff line number Diff line
@@ -43,12 +43,12 @@ cc_library {
    target: {
    target: {
        android: {
        android: {
            srcs: [
            srcs: [
                "IInputFlinger.cpp",
                "InputTransport.cpp",
                "InputTransport.cpp",
                "VelocityControl.cpp",
                "VelocityControl.cpp",
                "VelocityTracker.cpp",
                "VelocityTracker.cpp",
                "InputApplication.cpp",
                "InputApplication.cpp",
                "InputWindow.cpp"
                "InputWindow.cpp",
                "IInputFlinger.cpp"
            ],
            ],


            shared_libs: [
            shared_libs: [
+18 −7
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@


#include <input/IInputFlinger.h>
#include <input/IInputFlinger.h>



namespace android {
namespace android {


class BpInputFlinger : public BpInterface<IInputFlinger> {
class BpInputFlinger : public BpInterface<IInputFlinger> {
@@ -31,23 +30,35 @@ public:
    explicit BpInputFlinger(const sp<IBinder>& impl) :
    explicit BpInputFlinger(const sp<IBinder>& impl) :
            BpInterface<IInputFlinger>(impl) { }
            BpInterface<IInputFlinger>(impl) { }


    virtual status_t doSomething() {
    virtual void setInputWindows(const Vector<InputWindowInfo>& inputInfo) {
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(IInputFlinger::getInterfaceDescriptor());
        data.writeInterfaceToken(IInputFlinger::getInterfaceDescriptor());
        remote()->transact(BnInputFlinger::DO_SOMETHING_TRANSACTION, data, &reply);

        return reply.readInt32();
        data.writeUint32(static_cast<uint32_t>(inputInfo.size()));
        for (const auto& info : inputInfo) {
            info.write(data);
        }
        remote()->transact(BnInputFlinger::SET_INPUT_WINDOWS_TRANSACTION, data, &reply);
    }
    }
};
};


IMPLEMENT_META_INTERFACE(InputFlinger, "android.input.IInputFlinger");
IMPLEMENT_META_INTERFACE(InputFlinger, "android.input.IInputFlinger");



status_t BnInputFlinger::onTransact(
status_t BnInputFlinger::onTransact(
        uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
        uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
    switch(code) {
    switch(code) {
    case DO_SOMETHING_TRANSACTION: {
    case SET_INPUT_WINDOWS_TRANSACTION: {
        CHECK_INTERFACE(IInputFlinger, data, reply);
        CHECK_INTERFACE(IInputFlinger, data, reply);
        reply->writeInt32(0);
        size_t count = data.readUint32();
        if (count > data.dataSize()) {
            return BAD_VALUE;
        }
        Vector<InputWindowInfo> handles;
        handles.setCapacity(count);
        for (size_t i = 0; i < count; i++) {
            handles.add(InputWindowInfo(data));
        }
        setInputWindows(handles);
        break;
        break;
    }
    }
    default:
    default:
+4 −0
Original line number Original line Diff line number Diff line
@@ -135,6 +135,10 @@ InputWindowInfo InputWindowInfo::read(const Parcel& from) {
    return ret;
    return ret;
}
}


InputWindowInfo::InputWindowInfo(const Parcel& from) {
    *this = read(from);
}

// --- InputWindowHandle ---
// --- InputWindowHandle ---


InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
Loading