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

Commit 15cbf453 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4418112 from 179aa67c to pi-release

Change-Id: I8c13a094cc2324afa291b98dc0423d375b8c0c9b
parents 5791d2b5 179aa67c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ cc_binary {
    proprietary: true,
    init_rc: ["android.hardware.contexthub@1.0-service.rc"],
    srcs: ["service.cpp"],
    cflags: ["-Wall", "-Werror"],

    shared_libs: [
        "libbase",
+11 −3
Original line number Diff line number Diff line
@@ -35,10 +35,8 @@ namespace composer {
namespace V2_1 {
namespace implementation {


HwcHal::HwcHal(const hw_module_t* module)
    : mDevice(nullptr), mDispatch(), mAdapter()
{
    : mDevice(nullptr), mDispatch(), mMustValidateDisplay(true), mAdapter() {
    // Determine what kind of module is available (HWC2 vs HWC1.X).
    hw_device_t* device = nullptr;
    int error = module->methods->open(module, HWC_HARDWARE_COMPOSER, &device);
@@ -283,6 +281,8 @@ void HwcHal::refreshHook(hwc2_callback_data_t callbackData,
        hwc2_display_t display)
{
    auto hal = reinterpret_cast<HwcHal*>(callbackData);
    hal->mMustValidateDisplay = true;

    auto client = hal->getClient();
    if (client != nullptr) {
        client->onRefresh(display);
@@ -302,6 +302,8 @@ void HwcHal::vsyncHook(hwc2_callback_data_t callbackData,
void HwcHal::enableCallback(bool enable)
{
    if (enable) {
        mMustValidateDisplay = true;

        mDispatch.registerCallback(mDevice, HWC2_CALLBACK_HOTPLUG, this,
                reinterpret_cast<hwc2_function_pointer_t>(hotplugHook));
        mDispatch.registerCallback(mDevice, HWC2_CALLBACK_REFRESH, this,
@@ -549,6 +551,8 @@ Error HwcHal::validateDisplay(Display display,
    uint32_t reqs_count = 0;
    int32_t err = mDispatch.validateDisplay(mDevice, display,
            &types_count, &reqs_count);
    mMustValidateDisplay = false;

    if (err != HWC2_ERROR_NONE && err != HWC2_ERROR_HAS_CHANGES) {
        return static_cast<Error>(err);
    }
@@ -609,6 +613,10 @@ Error HwcHal::acceptDisplayChanges(Display display)
Error HwcHal::presentDisplay(Display display, int32_t* outPresentFence,
        std::vector<Layer>* outLayers, std::vector<int32_t>* outReleaseFences)
{
    if (mMustValidateDisplay) {
        return Error::NOT_VALIDATED;
    }

    *outPresentFence = -1;
    int32_t err = mDispatch.presentDisplay(mDevice, display, outPresentFence);
    if (err != HWC2_ERROR_NONE) {
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_H
#define ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_H

#include <atomic>
#include <condition_variable>
#include <memory>
#include <mutex>
@@ -215,6 +216,8 @@ private:
    std::condition_variable mClientDestroyedWait;
    wp<ComposerClient> mClient;

    std::atomic<bool> mMustValidateDisplay;

    // If the HWC implementation version is < 2.0, use an adapter to interface
    // between HWC 2.0 <-> HWC 1.X.
    std::unique_ptr<HWC2On1Adapter> mAdapter;
+43 −25
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/netfilter/nfnetlink.h>
#include <linux/netlink.h>
#include <log/log.h>
#include <net/if.h>
#include <sys/socket.h>
#include <unistd.h>
#include <set>
@@ -52,6 +53,8 @@ enum class ExpectBoolean {
    True = 1,
};

constexpr const char* TEST_IFACE = "rmnet_data0";

// We use #defines here so as to get local lamba captures and error message line numbers
#define ASSERT_TRUE_CALLBACK                            \
    [&](bool success, std::string errMsg) {             \
@@ -240,6 +243,18 @@ TEST_F(OffloadControlHidlTestBase, MultipleStopsWithoutInitReturnFalse) {
    stopOffload(ExpectBoolean::False);
}

// Check whether the specified interface is up.
bool interfaceIsUp(const char* name) {
    if (name == nullptr) return false;
    struct ifreq ifr = {};
    strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
    int sock = socket(AF_INET6, SOCK_DGRAM, 0);
    if (sock == -1) return false;
    int ret = ioctl(sock, SIOCGIFFLAGS, &ifr, sizeof(ifr));
    close(sock);
    return (ret == 0) && (ifr.ifr_flags & IFF_UP);
}

// Check that calling stopOffload() after a complete init/stop cycle returns false.
TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) {
    initOffload(true);
@@ -249,8 +264,11 @@ TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) {
    const hidl_string v4Gw("192.0.0.1");
    const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")};
    const Return<void> upstream =
        control->setUpstreamParameters("rmnet_data0", v4Addr, v4Gw, v6Gws, ASSERT_TRUE_CALLBACK);
        control->setUpstreamParameters(TEST_IFACE, v4Addr, v4Gw, v6Gws, ASSERT_TRUE_CALLBACK);
    EXPECT_TRUE(upstream.isOk());
    if (!interfaceIsUp(TEST_IFACE)) {
        return;
    }
    stopOffload(ExpectBoolean::True);  // balance out initOffload(true)
    stopOffload(ExpectBoolean::False);
    stopOffload(ExpectBoolean::False);
@@ -266,14 +284,14 @@ TEST_F(OffloadControlHidlTestBase, SetLocalPrefixesWithoutInitReturnsFalse) {
// Check that calling getForwardedStats() without first having called initOffload()
// returns zero bytes statistics.
TEST_F(OffloadControlHidlTestBase, GetForwardedStatsWithoutInitReturnsZeroValues) {
    const hidl_string upstream("rmnet_data0");
    const hidl_string upstream(TEST_IFACE);
    const Return<void> ret = control->getForwardedStats(upstream, ASSERT_ZERO_BYTES_CALLBACK);
    EXPECT_TRUE(ret.isOk());
}

// Check that calling setDataLimit() without first having called initOffload() returns false.
TEST_F(OffloadControlHidlTestBase, SetDataLimitWithoutInitReturnsFalse) {
    const hidl_string upstream("rmnet_data0");
    const hidl_string upstream(TEST_IFACE);
    const uint64_t limit = 5000ULL;
    const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_FALSE_CALLBACK);
    EXPECT_TRUE(ret.isOk());
@@ -282,7 +300,7 @@ TEST_F(OffloadControlHidlTestBase, SetDataLimitWithoutInitReturnsFalse) {
// Check that calling setUpstreamParameters() without first having called initOffload()
// returns false.
TEST_F(OffloadControlHidlTestBase, SetUpstreamParametersWithoutInitReturnsFalse) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string v4Addr("192.0.2.0/24");
    const hidl_string v4Gw("192.0.2.1");
    const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")};
@@ -294,7 +312,7 @@ TEST_F(OffloadControlHidlTestBase, SetUpstreamParametersWithoutInitReturnsFalse)
// Check that calling addDownstream() with an IPv4 prefix without first having called
// initOffload() returns false.
TEST_F(OffloadControlHidlTestBase, AddIPv4DownstreamWithoutInitReturnsFalse) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string prefix("192.0.2.0/24");
    const Return<void> ret = control->addDownstream(iface, prefix, ASSERT_FALSE_CALLBACK);
    EXPECT_TRUE(ret.isOk());
@@ -303,7 +321,7 @@ TEST_F(OffloadControlHidlTestBase, AddIPv4DownstreamWithoutInitReturnsFalse) {
// Check that calling addDownstream() with an IPv6 prefix without first having called
// initOffload() returns false.
TEST_F(OffloadControlHidlTestBase, AddIPv6DownstreamWithoutInitReturnsFalse) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string prefix("2001:db8::/64");
    const Return<void> ret = control->addDownstream(iface, prefix, ASSERT_FALSE_CALLBACK);
    EXPECT_TRUE(ret.isOk());
@@ -312,7 +330,7 @@ TEST_F(OffloadControlHidlTestBase, AddIPv6DownstreamWithoutInitReturnsFalse) {
// Check that calling removeDownstream() with an IPv4 prefix without first having called
// initOffload() returns false.
TEST_F(OffloadControlHidlTestBase, RemoveIPv4DownstreamWithoutInitReturnsFalse) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string prefix("192.0.2.0/24");
    const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_FALSE_CALLBACK);
    EXPECT_TRUE(ret.isOk());
@@ -321,7 +339,7 @@ TEST_F(OffloadControlHidlTestBase, RemoveIPv4DownstreamWithoutInitReturnsFalse)
// Check that calling removeDownstream() with an IPv6 prefix without first having called
// initOffload() returns false.
TEST_F(OffloadControlHidlTestBase, RemoveIPv6DownstreamWithoutInitReturnsFalse) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string prefix("2001:db8::/64");
    const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_FALSE_CALLBACK);
    EXPECT_TRUE(ret.isOk());
@@ -394,10 +412,10 @@ TEST_F(OffloadControlHidlTest, GetForwardedStatsInvalidUpstreamIface) {
    EXPECT_TRUE(ret.isOk());
}

// The "rmnet_data0" is presumed to exist on the device and be up. No packets
// TEST_IFACE is presumed to exist on the device and be up. No packets
// are ever actually caused to be forwarded.
TEST_F(OffloadControlHidlTest, GetForwardedStatsDummyIface) {
    const hidl_string upstream("rmnet_data0");
    const hidl_string upstream(TEST_IFACE);
    const Return<void> ret = control->getForwardedStats(upstream, ASSERT_ZERO_BYTES_CALLBACK);
    EXPECT_TRUE(ret.isOk());
}
@@ -414,19 +432,19 @@ TEST_F(OffloadControlHidlTest, SetDataLimitEmptyUpstreamIfaceFails) {
    EXPECT_TRUE(ret.isOk());
}

// The "rmnet_data0" is presumed to exist on the device and be up. No packets
// TEST_IFACE is presumed to exist on the device and be up. No packets
// are ever actually caused to be forwarded.
TEST_F(OffloadControlHidlTest, SetDataLimitNonZeroOk) {
    const hidl_string upstream("rmnet_data0");
    const hidl_string upstream(TEST_IFACE);
    const uint64_t limit = 5000ULL;
    const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_TRUE_CALLBACK);
    EXPECT_TRUE(ret.isOk());
}

// The "rmnet_data0" is presumed to exist on the device and be up. No packets
// TEST_IFACE is presumed to exist on the device and be up. No packets
// are ever actually caused to be forwarded.
TEST_F(OffloadControlHidlTest, SetDataLimitZeroOk) {
    const hidl_string upstream("rmnet_data0");
    const hidl_string upstream(TEST_IFACE);
    const uint64_t limit = 0ULL;
    const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_TRUE_CALLBACK);
    EXPECT_TRUE(ret.isOk());
@@ -436,10 +454,10 @@ TEST_F(OffloadControlHidlTest, SetDataLimitZeroOk) {
 * Tests for IOffloadControl::setUpstreamParameters().
 */

// The "rmnet_data0" is presumed to exist on the device and be up. No packets
// TEST_IFACE is presumed to exist on the device and be up. No packets
// are ever actually caused to be forwarded.
TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv6OnlyOk) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string v4Addr("");
    const hidl_string v4Gw("");
    const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")};
@@ -448,10 +466,10 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv6OnlyOk) {
    EXPECT_TRUE(ret.isOk());
}

// The "rmnet_data0" is presumed to exist on the device and be up. No packets
// TEST_IFACE is presumed to exist on the device and be up. No packets
// are ever actually caused to be forwarded.
TEST_F(OffloadControlHidlTest, SetUpstreamParametersAlternateIPv6OnlyOk) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string v4Addr;
    const hidl_string v4Gw;
    const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:3")};
@@ -460,10 +478,10 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersAlternateIPv6OnlyOk) {
    EXPECT_TRUE(ret.isOk());
}

// The "rmnet_data0" is presumed to exist on the device and be up. No packets
// TEST_IFACE is presumed to exist on the device and be up. No packets
// are ever actually caused to be forwarded.
TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv4OnlyOk) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string v4Addr("192.0.2.2");
    const hidl_string v4Gw("192.0.2.1");
    const vector<hidl_string> v6Gws{};
@@ -472,10 +490,10 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv4OnlyOk) {
    EXPECT_TRUE(ret.isOk());
}

// The "rmnet_data0" is presumed to exist on the device and be up. No packets
// TEST_IFACE is presumed to exist on the device and be up. No packets
// are ever actually caused to be forwarded.
TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv4v6Ok) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string v4Addr("192.0.2.2");
    const hidl_string v4Gw("192.0.2.1");
    const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")};
@@ -511,7 +529,7 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersBogusIfaceFails) {

// Test that setUpstreamParameters() fails when given unparseable IPv4 addresses.
TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4AddrFails) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string v4Gw("192.0.2.1");
    const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")};
    for (const auto& bogus : {"invalid", "192.0.2"}) {
@@ -525,7 +543,7 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4AddrFails) {

// Test that setUpstreamParameters() fails when given unparseable IPv4 gateways.
TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4GatewayFails) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string v4Addr("192.0.2.2");
    const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")};
    for (const auto& bogus : {"invalid", "192.0.2"}) {
@@ -539,7 +557,7 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4GatewayFails) {

// Test that setUpstreamParameters() fails when given unparseable IPv6 gateways.
TEST_F(OffloadControlHidlTest, SetUpstreamParametersBadIPv6GatewaysFail) {
    const hidl_string iface("rmnet_data0");
    const hidl_string iface(TEST_IFACE);
    const hidl_string v4Addr("192.0.2.2");
    const hidl_string v4Gw("192.0.2.1");
    for (const auto& bogus : {"", "invalid", "fe80::bogus", "192.0.2.66"}) {