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

Commit a79ddf4b authored by Huihong Luo's avatar Huihong Luo
Browse files

Convert StaticDisplayInfo to AIDL parcelable

And migrate related ISurfaceComposer::getStaticDisplayInfo() method to AIDL.
(1) add android::gui::StaticDisplayInfo etc. for serialization
(2) remove serialization code from the orignal StaticDisplayInfo and
DeviceProductInfo classes
(3) convert between ui::StaticDisplayInfo and gui::StaticDisplayInfo

Bug: 220073844
Test: atest libgui_test
Change-Id: I462e5d4d76f768bc17ea5ca3dd54249b3ee489d9
parent 33e8e135
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#include <ui/DisplayState.h>
#include <ui/DynamicDisplayInfo.h>
#include <ui/HdrCapabilities.h>
#include <ui/StaticDisplayInfo.h>
#include <utils/Log.h>

// ---------------------------------------------------------------------------
@@ -226,17 +225,6 @@ public:
        return result;
    }

    status_t getStaticDisplayInfo(const sp<IBinder>& display,
                                  ui::StaticDisplayInfo* info) override {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(display);
        remote()->transact(BnSurfaceComposer::GET_STATIC_DISPLAY_INFO, data, &reply);
        const status_t result = reply.readInt32();
        if (result != NO_ERROR) return result;
        return reply.read(*info);
    }

    status_t getDynamicDisplayInfo(const sp<IBinder>& display,
                                   ui::DynamicDisplayInfo* info) override {
        Parcel data, reply;
@@ -1145,16 +1133,6 @@ status_t BnSurfaceComposer::onTransact(
            reply->writeStrongBinder(IInterface::asBinder(connection));
            return NO_ERROR;
        }
        case GET_STATIC_DISPLAY_INFO: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            ui::StaticDisplayInfo info;
            const sp<IBinder> display = data.readStrongBinder();
            const status_t result = getStaticDisplayInfo(display, &info);
            SAFE_PARCEL(reply->writeInt32, result);
            if (result != NO_ERROR) return result;
            SAFE_PARCEL(reply->write, info);
            return NO_ERROR;
        }
        case GET_DYNAMIC_DISPLAY_INFO: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            ui::DynamicDisplayInfo info;
+42 −2
Original line number Diff line number Diff line
@@ -2128,8 +2128,48 @@ status_t SurfaceComposerClient::getDisplayState(const sp<IBinder>& display,
}

status_t SurfaceComposerClient::getStaticDisplayInfo(const sp<IBinder>& display,
                                                     ui::StaticDisplayInfo* info) {
    return ComposerService::getComposerService()->getStaticDisplayInfo(display, info);
                                                     ui::StaticDisplayInfo* outInfo) {
    using Tag = android::gui::DeviceProductInfo::ManufactureOrModelDate::Tag;
    gui::StaticDisplayInfo ginfo;
    binder::Status status =
            ComposerServiceAIDL::getComposerService()->getStaticDisplayInfo(display, &ginfo);
    if (status.isOk()) {
        // convert gui::StaticDisplayInfo to ui::StaticDisplayInfo
        outInfo->connectionType = static_cast<ui::DisplayConnectionType>(ginfo.connectionType);
        outInfo->density = ginfo.density;
        outInfo->secure = ginfo.secure;
        outInfo->installOrientation = static_cast<ui::Rotation>(ginfo.installOrientation);

        DeviceProductInfo info;
        std::optional<gui::DeviceProductInfo> dpi = ginfo.deviceProductInfo;
        gui::DeviceProductInfo::ManufactureOrModelDate& date = dpi->manufactureOrModelDate;
        info.name = dpi->name;
        if (dpi->manufacturerPnpId.size() > 0) {
            // copid from PnpId = std::array<char, 4> in ui/DeviceProductInfo.h
            constexpr int kMaxPnpIdSize = 4;
            size_t count = std::max<size_t>(kMaxPnpIdSize, dpi->manufacturerPnpId.size());
            std::copy_n(dpi->manufacturerPnpId.begin(), count, info.manufacturerPnpId.begin());
        }
        info.productId = dpi->productId;
        if (date.getTag() == Tag::modelYear) {
            DeviceProductInfo::ModelYear modelYear;
            modelYear.year = static_cast<uint32_t>(date.get<Tag::modelYear>().year);
            info.manufactureOrModelDate = modelYear;
        } else if (date.getTag() == Tag::manufactureYear) {
            DeviceProductInfo::ManufactureYear manufactureYear;
            manufactureYear.year = date.get<Tag::manufactureYear>().modelYear.year;
            info.manufactureOrModelDate = manufactureYear;
        } else if (date.getTag() == Tag::manufactureWeekAndYear) {
            DeviceProductInfo::ManufactureWeekAndYear weekAndYear;
            weekAndYear.year =
                    date.get<Tag::manufactureWeekAndYear>().manufactureYear.modelYear.year;
            weekAndYear.week = date.get<Tag::manufactureWeekAndYear>().week;
            info.manufactureOrModelDate = weekAndYear;
        }

        outInfo->deviceProductInfo = info;
    }
    return status.transactionError();
}

status_t SurfaceComposerClient::getDynamicDisplayInfo(const sp<IBinder>& display,
+58 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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;

// Product-specific information about the display or the directly connected device on the
// display chain. For example, if the display is transitively connected, this field may contain
// product information about the intermediate device.

/** @hide */
parcelable DeviceProductInfo {
    parcelable ModelYear {
        int year;
    }

    parcelable ManufactureYear {
        ModelYear modelYear;
    }

    parcelable ManufactureWeekAndYear {
        ManufactureYear manufactureYear;

        // 1-base week number. Week numbering may not be consistent between manufacturers.
        int week;
    }

    union ManufactureOrModelDate {
        ModelYear modelYear;
        ManufactureYear manufactureYear;
        ManufactureWeekAndYear manufactureWeekAndYear;
    }

    // Display name.
    @utf8InCpp String name;

    // NULL-terminated Manufacturer plug and play ID.
    byte[] manufacturerPnpId;

    // Manufacturer product ID.
    @utf8InCpp String productId;

    ManufactureOrModelDate manufactureOrModelDate;

    byte[] relativeAddress;
}
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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;

/** @hide */
@Backing(type="int")
enum DisplayConnectionType {
   Internal = 0,
   External = 1
}
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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;

// Product-specific information about the display or the directly connected device on the
// display chain. For example, if the display is transitively connected, this field may contain
// product information about the intermediate device.

/** @hide */
parcelable DisplayModelId {
    int id;
}
Loading