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

Commit 39fe4697 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Use android::os::InputChannelCore for parceling InputChannel" into main

parents 5ed53c5f fe289013
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -203,8 +203,10 @@ static jlong android_view_InputChannel_nativeReadFromParcel(JNIEnv* env, jobject
    if (parcel) {
        bool isInitialized = parcel->readInt32();
        if (isInitialized) {
            std::unique_ptr<InputChannel> inputChannel = std::make_unique<InputChannel>();
            inputChannel->readFromParcel(parcel);
            android::os::InputChannelCore parcelableChannel;
            parcelableChannel.readFromParcel(parcel);
            std::unique_ptr<InputChannel> inputChannel =
                    InputChannel::create(std::move(parcelableChannel));
            NativeInputChannel* nativeInputChannel =
                    new NativeInputChannel(std::move(inputChannel));
            return reinterpret_cast<jlong>(nativeInputChannel);
@@ -228,7 +230,9 @@ static void android_view_InputChannel_nativeWriteToParcel(JNIEnv* env, jobject o
        return;
    }
    parcel->writeInt32(1); // initialized
    nativeInputChannel->getInputChannel()->writeToParcel(parcel);
    android::os::InputChannelCore parcelableChannel;
    nativeInputChannel->getInputChannel()->copyTo(parcelableChannel);
    parcelableChannel.writeToParcel(parcel);
}

static jstring android_view_InputChannel_nativeGetName(JNIEnv* env, jobject obj, jlong channel) {
+3 −3
Original line number Diff line number Diff line
@@ -189,11 +189,11 @@ status_t NativeInputEventReceiver::reportTimeline(int32_t inputEventId, nsecs_t
void NativeInputEventReceiver::setFdEvents(int events) {
    if (mFdEvents != events) {
        mFdEvents = events;
        auto&& fd = mInputConsumer.getChannel()->getFd();
        const int fd = mInputConsumer.getChannel()->getFd();
        if (events) {
            mMessageQueue->getLooper()->addFd(fd.get(), 0, events, this, nullptr);
            mMessageQueue->getLooper()->addFd(fd, 0, events, this, nullptr);
        } else {
            mMessageQueue->getLooper()->removeFd(fd.get());
            mMessageQueue->getLooper()->removeFd(fd);
        }
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -102,8 +102,8 @@ NativeInputEventSender::~NativeInputEventSender() {
}

status_t NativeInputEventSender::initialize() {
    auto&& receiveFd = mInputPublisher.getChannel()->getFd();
    mMessageQueue->getLooper()->addFd(receiveFd.get(), 0, ALOOPER_EVENT_INPUT, this, NULL);
    const int receiveFd = mInputPublisher.getChannel()->getFd();
    mMessageQueue->getLooper()->addFd(receiveFd, 0, ALOOPER_EVENT_INPUT, this, NULL);
    return OK;
}

@@ -112,7 +112,7 @@ void NativeInputEventSender::dispose() {
        LOG(DEBUG) << "channel '" << getInputChannelName() << "' ~ Disposing input event sender.";
    }

    mMessageQueue->getLooper()->removeFd(mInputPublisher.getChannel()->getFd().get());
    mMessageQueue->getLooper()->removeFd(mInputPublisher.getChannel()->getFd());
}

status_t NativeInputEventSender::sendKeyEvent(uint32_t seq, const KeyEvent* event) {