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

Commit 740167f1 authored by Robert Carr's avatar Robert Carr
Browse files

Rework InputApplicationInfo

First we move it inside of InputWindowInfo instead of InputWindowHandle
so it is part of the data sent across binder. Second we give it a persistent
identity of an IBinder token and use this for comparisons.

Bug: 80101428
Bug: 113136004
Bug: 111440400
Test: EndToEndNativeInputTest. Existing tests pass.
Change-Id: Id89a40e66887d834020f8e645fd1fb48adb7ee2e
parent 5c8a0261
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@

#include <string>

#include <binder/IBinder.h>
#include <binder/Parcel.h>

#include <input/Input.h>
#include <utils/RefBase.h>
#include <utils/Timers.h>
@@ -29,8 +32,12 @@ namespace android {
 * Describes the properties of an application that can receive input.
 */
struct InputApplicationInfo {
    sp<IBinder> token;
    std::string name;
    nsecs_t dispatchingTimeout;

    status_t write(Parcel& output) const;
    static InputApplicationInfo read(const Parcel& from);
};


@@ -54,6 +61,10 @@ public:
        return mInfo ? mInfo->dispatchingTimeout : defaultValue;
    }

    inline sp<IBinder> getApplicationToken() const {
        return mInfo ? mInfo->token : nullptr;
    }

    /**
     * Requests that the state of this object be updated to reflect
     * the most current available information about the application.
+6 −2
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ struct InputWindowInfo {
    int32_t ownerUid;
    int32_t inputFeatures;
    int32_t displayId;
    InputApplicationInfo applicationInfo;

    void addTouchableRegion(const Rect& region);

@@ -168,7 +169,6 @@ struct InputWindowInfo {
 */
class InputWindowHandle : public RefBase {
public:
    const sp<InputApplicationHandle> inputApplicationHandle;

    inline const InputWindowInfo* getInfo() const {
        return &mInfo;
@@ -176,6 +176,10 @@ public:

    sp<IBinder> getToken() const;

    sp<IBinder> getApplicationToken() {
        return mInfo.applicationInfo.token;
    }

    inline std::string getName() const {
        return mInfo.token ? mInfo.name : "<invalid>";
    }
@@ -202,7 +206,7 @@ public:
    void releaseChannel();

protected:
    explicit InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle);
    explicit InputWindowHandle();
    virtual ~InputWindowHandle();

    InputWindowInfo mInfo;
+7 −0
Original line number Diff line number Diff line
@@ -153,6 +153,13 @@ private:
        mInputInfo.ownerUid = 11111;
        mInputInfo.inputFeatures = 0;
        mInputInfo.displayId = 0;

        InputApplicationInfo aInfo;
        aInfo.token = new BBinder();
        aInfo.name = "Test app info";
        aInfo.dispatchingTimeout = 100000;

        mInputInfo.applicationInfo = aInfo;
    }
public:
    sp<SurfaceControl> mSurfaceControl;
+17 −0
Original line number Diff line number Diff line
@@ -39,4 +39,21 @@ void InputApplicationHandle::releaseInfo() {
    }
}

InputApplicationInfo InputApplicationInfo::read(const Parcel& from) {
    InputApplicationInfo ret;
    ret.token = from.readStrongBinder();
    ret.name = from.readString8().c_str();
    ret.dispatchingTimeout = from.readInt64();

    return ret;
}

status_t InputApplicationInfo::write(Parcel& output) const {
    output.writeStrongBinder(token);
    output.writeString8(String8(name.c_str()));
    output.writeInt64(dispatchingTimeout);
    
    return OK;
}

} // namespace android
+3 −2
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ status_t InputWindowInfo::write(Parcel& output) const {
    output.writeInt32(ownerUid);
    output.writeInt32(inputFeatures);
    output.writeInt32(displayId);
    applicationInfo.write(output);
    output.write(touchableRegion);

    return OK;
@@ -129,6 +130,7 @@ InputWindowInfo InputWindowInfo::read(const Parcel& from) {
    ret.ownerUid = from.readInt32();
    ret.inputFeatures = from.readInt32();
    ret.displayId = from.readInt32();
    ret.applicationInfo = InputApplicationInfo::read(from);
    from.read(ret.touchableRegion);

    return ret;
@@ -140,8 +142,7 @@ InputWindowInfo::InputWindowInfo(const Parcel& from) {

// --- InputWindowHandle ---

InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
    inputApplicationHandle(inputApplicationHandle) {
InputWindowHandle::InputWindowHandle() {
}

InputWindowHandle::~InputWindowHandle() {
Loading