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

Commit 42649635 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Report gui::DisplayInfo to clients with window info changes"

parents 4eeba11b 48f8cb99
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -65,11 +65,13 @@ cc_library_static {
    host_supported: true,
    srcs: [
        ":guiconstants_aidl",
        "android/gui/DisplayInfo.aidl",
        "android/gui/FocusRequest.aidl",
        "android/gui/InputApplicationInfo.aidl",
        "android/gui/IWindowInfosListener.aidl",
        "android/gui/IWindowInfosReportedListener.aidl",
        "android/gui/WindowInfo.aidl",
        "DisplayInfo.cpp",
        "WindowInfo.cpp",
    ],

@@ -90,7 +92,7 @@ cc_library_static {
    ],

    aidl: {
        export_aidl_headers: true
        export_aidl_headers: true,
    },

    include_dirs: [
@@ -135,8 +137,8 @@ cc_library_static {
    ],

    aidl: {
        export_aidl_headers: true
    }
        export_aidl_headers: true,
    },
}

cc_library_shared {
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 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.
 */

#define LOG_TAG "DisplayInfo"

#include <binder/Parcel.h>
#include <gui/DisplayInfo.h>
#include <private/gui/ParcelUtils.h>

#include <log/log.h>

namespace android::gui {

// --- DisplayInfo ---

status_t DisplayInfo::readFromParcel(const android::Parcel* parcel) {
    if (parcel == nullptr) {
        ALOGE("%s: Null parcel", __func__);
        return BAD_VALUE;
    }

    float dsdx, dtdx, tx, dtdy, dsdy, ty;
    SAFE_PARCEL(parcel->readInt32, &displayId);
    SAFE_PARCEL(parcel->readInt32, &logicalWidth);
    SAFE_PARCEL(parcel->readInt32, &logicalHeight);
    SAFE_PARCEL(parcel->readFloat, &dsdx);
    SAFE_PARCEL(parcel->readFloat, &dtdx);
    SAFE_PARCEL(parcel->readFloat, &tx);
    SAFE_PARCEL(parcel->readFloat, &dtdy);
    SAFE_PARCEL(parcel->readFloat, &dsdy);
    SAFE_PARCEL(parcel->readFloat, &ty);

    transform.set({dsdx, dtdx, tx, dtdy, dsdy, ty, 0, 0, 1});

    return OK;
}

status_t DisplayInfo::writeToParcel(android::Parcel* parcel) const {
    if (parcel == nullptr) {
        ALOGE("%s: Null parcel", __func__);
        return BAD_VALUE;
    }

    SAFE_PARCEL(parcel->writeInt32, displayId);
    SAFE_PARCEL(parcel->writeInt32, logicalWidth);
    SAFE_PARCEL(parcel->writeInt32, logicalHeight);
    SAFE_PARCEL(parcel->writeFloat, transform.dsdx());
    SAFE_PARCEL(parcel->writeFloat, transform.dtdx());
    SAFE_PARCEL(parcel->writeFloat, transform.tx());
    SAFE_PARCEL(parcel->writeFloat, transform.dtdy());
    SAFE_PARCEL(parcel->writeFloat, transform.dsdy());
    SAFE_PARCEL(parcel->writeFloat, transform.ty());

    return OK;
}

} // namespace android::gui
+5 −12
Original line number Diff line number Diff line
@@ -54,12 +54,11 @@ bool WindowInfo::operator==(const WindowInfo& info) const {
            info.frameLeft == frameLeft && info.frameTop == frameTop &&
            info.frameRight == frameRight && info.frameBottom == frameBottom &&
            info.surfaceInset == surfaceInset && info.globalScaleFactor == globalScaleFactor &&
            info.transform == transform && info.displayOrientation == displayOrientation &&
            info.displayWidth == displayWidth && info.displayHeight == displayHeight &&
            info.touchableRegion.hasSameRects(touchableRegion) && info.visible == visible &&
            info.trustedOverlay == trustedOverlay && info.focusable == focusable &&
            info.touchOcclusionMode == touchOcclusionMode && info.hasWallpaper == hasWallpaper &&
            info.paused == paused && info.ownerPid == ownerPid && info.ownerUid == ownerUid &&
            info.transform == transform && info.touchableRegion.hasSameRects(touchableRegion) &&
            info.visible == visible && info.trustedOverlay == trustedOverlay &&
            info.focusable == focusable && info.touchOcclusionMode == touchOcclusionMode &&
            info.hasWallpaper == hasWallpaper && info.paused == paused &&
            info.ownerPid == ownerPid && info.ownerUid == ownerUid &&
            info.packageName == packageName && info.inputFeatures == inputFeatures &&
            info.displayId == displayId && info.portalToDisplayId == portalToDisplayId &&
            info.replaceTouchableRegionWithCrop == replaceTouchableRegionWithCrop &&
@@ -97,9 +96,6 @@ status_t WindowInfo::writeToParcel(android::Parcel* parcel) const {
        parcel->writeFloat(transform.dtdy()) ?:
        parcel->writeFloat(transform.dsdy()) ?:
        parcel->writeFloat(transform.ty()) ?:
        parcel->writeUint32(displayOrientation) ?:
        parcel->writeInt32(displayWidth) ?:
        parcel->writeInt32(displayHeight) ?:
        parcel->writeBool(visible) ?:
        parcel->writeBool(focusable) ?:
        parcel->writeBool(hasWallpaper) ?:
@@ -155,9 +151,6 @@ status_t WindowInfo::readFromParcel(const android::Parcel* parcel) {
        parcel->readFloat(&dtdy) ?:
        parcel->readFloat(&dsdy) ?:
        parcel->readFloat(&ty) ?:
        parcel->readUint32(&displayOrientation) ?:
        parcel->readInt32(&displayWidth) ?:
        parcel->readInt32(&displayHeight) ?:
        parcel->readBool(&visible) ?:
        parcel->readBool(&focusable) ?:
        parcel->readBool(&hasWallpaper) ?:
+3 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

namespace android {

using gui::DisplayInfo;
using gui::IWindowInfosReportedListener;
using gui::WindowInfo;
using gui::WindowInfosListener;
@@ -65,7 +66,7 @@ status_t WindowInfosListenerReporter::removeWindowInfosListener(
}

binder::Status WindowInfosListenerReporter::onWindowInfosChanged(
        const std::vector<WindowInfo>& windowInfos,
        const std::vector<WindowInfo>& windowInfos, const std::vector<DisplayInfo>& displayInfos,
        const sp<IWindowInfosReportedListener>& windowInfosReportedListener) {
    std::unordered_set<sp<WindowInfosListener>, ISurfaceComposer::SpHash<WindowInfosListener>>
            windowInfosListeners;
@@ -78,7 +79,7 @@ binder::Status WindowInfosListenerReporter::onWindowInfosChanged(
    }

    for (auto listener : windowInfosListeners) {
        listener->onWindowInfosChanged(windowInfos);
        listener->onWindowInfosChanged(windowInfos, displayInfos);
    }

    if (windowInfosReportedListener) {
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021, 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 android.gui;

parcelable DisplayInfo cpp_header "gui/DisplayInfo.h";
Loading