Merge "[Lut] Dup the pfd instead of releasing it in parseSetDisplayLuts." into main
diff --git a/automotive/can/1.0/default/libnetdevice/can.cpp b/automotive/can/1.0/default/libnetdevice/can.cpp
index 9cf0253..32d899b 100644
--- a/automotive/can/1.0/default/libnetdevice/can.cpp
+++ b/automotive/can/1.0/default/libnetdevice/can.cpp
@@ -80,7 +80,7 @@
 
     {
         auto linkinfo = req.addNested(IFLA_LINKINFO);
-        req.addBuffer(IFLA_INFO_KIND, "can");
+        req.add(IFLA_INFO_KIND, "can");
         {
             auto infodata = req.addNested(IFLA_INFO_DATA);
             /* For CAN FD, it would require to add IFLA_CAN_DATA_BITTIMING
diff --git a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/libnetdevice.h b/automotive/can/1.0/default/libnetdevice/include/libnetdevice/libnetdevice.h
index 15ff491..04d1e0a 100644
--- a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/libnetdevice.h
+++ b/automotive/can/1.0/default/libnetdevice/include/libnetdevice/libnetdevice.h
@@ -161,6 +161,15 @@
 bool del(std::string_view dev);
 
 /**
+ * Rename interface.
+ *
+ * \param from the name of the interface to rename from
+ * \param to the name of the interface to rename to
+ * \return true in case of success, false otherwise
+ */
+bool rename(std::string_view from, std::string_view to);
+
+/**
  * Fetches interface's hardware address.
  *
  * \param ifname Interface name
diff --git a/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp b/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
index 9bb1a57..f149c45 100644
--- a/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
+++ b/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
@@ -126,6 +126,10 @@
     req->ifa_prefixlen = prefixlen;
     req->ifa_flags = IFA_F_SECONDARY;
     req->ifa_index = nametoindex(ifname);
+    if (req->ifa_index == 0) {
+        LOG(ERROR) << "Interface " << ifname << " doesn't exist";
+        return false;
+    }
 
     auto addrn = inetAddr(addr);
     req.add(IFLA_ADDRESS, addrn);
@@ -141,7 +145,7 @@
 
     {
         auto linkinfo = req.addNested(IFLA_LINKINFO);
-        req.addBuffer(IFLA_INFO_KIND, type);
+        req.add(IFLA_INFO_KIND, type);
     }
 
     nl::Socket sock(NETLINK_ROUTE);
@@ -156,6 +160,20 @@
     return sock.send(req) && sock.receiveAck(req);
 }
 
+bool rename(std::string_view from, std::string_view to) {
+    nl::MessageFactory<ifinfomsg> req(RTM_SETLINK);
+    req.add(IFLA_IFNAME, to);
+
+    req->ifi_index = nametoindex(from);
+    if (req->ifi_index == 0) {
+        LOG(ERROR) << "Interface " << from << " doesn't exist";
+        return false;
+    }
+
+    nl::Socket sock(NETLINK_ROUTE);
+    return sock.send(req) && sock.receiveAck(req);
+}
+
 std::optional<hwaddr_t> getHwAddr(std::string_view ifname) {
     auto ifr = ifreqs::fromName(ifname);
     if (!ifreqs::send(SIOCGIFHWADDR, ifr)) return std::nullopt;
diff --git a/automotive/can/1.0/default/libnetdevice/vlan.cpp b/automotive/can/1.0/default/libnetdevice/vlan.cpp
index e5b5a61..570545e 100644
--- a/automotive/can/1.0/default/libnetdevice/vlan.cpp
+++ b/automotive/can/1.0/default/libnetdevice/vlan.cpp
@@ -39,7 +39,7 @@
 
     {
         auto linkinfo = req.addNested(IFLA_LINKINFO);
-        req.addBuffer(IFLA_INFO_KIND, "vlan");
+        req.add(IFLA_INFO_KIND, "vlan");
 
         {
             auto linkinfo = req.addNested(IFLA_INFO_DATA);
diff --git a/automotive/can/1.0/default/libnl++/include/libnl++/MessageFactory.h b/automotive/can/1.0/default/libnl++/include/libnl++/MessageFactory.h
index f65f055..058b2cb 100644
--- a/automotive/can/1.0/default/libnl++/include/libnl++/MessageFactory.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/MessageFactory.h
@@ -23,6 +23,7 @@
 #include <linux/netlink.h>
 
 #include <string>
+#include <type_traits>
 
 namespace android::nl {
 
@@ -109,25 +110,21 @@
      */
     template <class A>
     void add(nlattrtype_t type, const A& attr) {
-        addInternal(type, &attr, sizeof(attr));
+        static_assert(std::is_pod_v<A>, "POD type required");
+        add(type, &attr, sizeof(attr));
     }
 
-    // It will always send the last null character, otherwise use addBuffer
-    // variant instead
     template <>
     void add(nlattrtype_t type, const std::string& s) {
-        addInternal(type, s.c_str(), s.size() + 1);
+        add(type, s.c_str(), s.size());
     }
 
-    void addBuffer(nlattrtype_t type, const std::string_view& s) {
-        addInternal(type, s.data(), s.size());
-    }
+    void add(nlattrtype_t type, std::string_view s) { add(type, s.data(), s.size()); }
 
     /** Guard class to frame nested attributes. \see addNested(nlattrtype_t). */
     class [[nodiscard]] NestedGuard {
       public:
-        NestedGuard(MessageFactory& req, nlattrtype_t type)
-            : mReq(req), mAttr(req.addInternal(type)) {}
+        NestedGuard(MessageFactory& req, nlattrtype_t type) : mReq(req), mAttr(req.add(type)) {}
         ~NestedGuard() { closeNested(&mReq.mMessage.header, mAttr); }
 
       private:
@@ -148,7 +145,7 @@
      *    MessageFactory<ifinfomsg> req(RTM_NEWLINK, NLM_F_REQUEST);
      *    {
      *        auto linkinfo = req.addNested(IFLA_LINKINFO);
-     *        req.addBuffer(IFLA_INFO_KIND, "can");
+     *        req.add(IFLA_INFO_KIND, "can");
      *        {
      *            auto infodata = req.addNested(IFLA_INFO_DATA);
      *            req.add(IFLA_CAN_BITTIMING, bitTimingStruct);
@@ -164,7 +161,7 @@
     Message mMessage = {};
     bool mIsGood = true;
 
-    nlattr* addInternal(nlattrtype_t type, const void* data = nullptr, size_t len = 0) {
+    nlattr* add(nlattrtype_t type, const void* data = nullptr, size_t len = 0) {
         if (!mIsGood) return nullptr;
         auto attr = MessageFactoryBase::add(&mMessage.header, sizeof(mMessage), type, data, len);
         if (attr == nullptr) mIsGood = false;
diff --git a/biometrics/common/util/CancellationSignal.cpp b/biometrics/common/util/CancellationSignal.cpp
index 7888838..2bfc39e 100644
--- a/biometrics/common/util/CancellationSignal.cpp
+++ b/biometrics/common/util/CancellationSignal.cpp
@@ -22,10 +22,13 @@
 namespace aidl::android::hardware::biometrics {
 
 CancellationSignal::CancellationSignal(std::promise<void>&& cancellationPromise)
-    : mCancellationPromise(std::move(cancellationPromise)) {}
+    : mCancellationPromise(std::move(cancellationPromise)), isSet(false) {}
 
 ndk::ScopedAStatus CancellationSignal::cancel() {
-    mCancellationPromise.set_value();
+    if (!isSet) {
+        mCancellationPromise.set_value();
+        isSet = true;
+    }
     return ndk::ScopedAStatus::ok();
 }
 
diff --git a/biometrics/common/util/include/util/CancellationSignal.h b/biometrics/common/util/include/util/CancellationSignal.h
index be77e29..d5a9a1d 100644
--- a/biometrics/common/util/include/util/CancellationSignal.h
+++ b/biometrics/common/util/include/util/CancellationSignal.h
@@ -30,6 +30,7 @@
 
   private:
     std::promise<void> mCancellationPromise;
+    bool isSet;
 };
 
 // Returns whether the given cancellation future is ready, i.e. whether the operation corresponding
diff --git a/graphics/allocator/aidl/vts/VtsHalGraphicsAllocatorAidl_TargetTest.cpp b/graphics/allocator/aidl/vts/VtsHalGraphicsAllocatorAidl_TargetTest.cpp
index 0430ea7..22ad5f0 100644
--- a/graphics/allocator/aidl/vts/VtsHalGraphicsAllocatorAidl_TargetTest.cpp
+++ b/graphics/allocator/aidl/vts/VtsHalGraphicsAllocatorAidl_TargetTest.cpp
@@ -162,11 +162,19 @@
     }
 
   private:
-    BufferDescriptor createDescriptor(const BufferDescriptorInfo& descriptorInfo) {
-        BufferDescriptor descriptor;
+    std::optional<BufferDescriptor> createDescriptor(const BufferDescriptorInfo& descriptorInfo,
+                                                     bool raise_failure) {
+        std::optional<BufferDescriptor> descriptor;
         mMapper4->createDescriptor(
                 convert(descriptorInfo), [&](const auto& tmpError, const auto& tmpDescriptor) {
-                    ASSERT_EQ(Error::NONE, tmpError) << "failed to create descriptor";
+                    if (raise_failure) {
+                        ASSERT_EQ(Error::NONE, tmpError) << "failed to create descriptor";
+                    }
+
+                    if (tmpError != Error::NONE) {
+                        return;
+                    }
+
                     descriptor = tmpDescriptor;
                 });
 
@@ -174,19 +182,24 @@
     }
 
   public:
-    std::unique_ptr<BufferHandle> allocate(const BufferDescriptorInfo& descriptorInfo) {
+    std::unique_ptr<BufferHandle> allocate(const BufferDescriptorInfo& descriptorInfo,
+                                           bool raise_failure = true) {
         AllocationResult result;
         ::ndk::ScopedAStatus status;
         if (mIAllocatorVersion >= 2) {
             status = mAllocator->allocate2(descriptorInfo, 1, &result);
         } else {
-            auto descriptor = createDescriptor(descriptorInfo);
+            auto descriptor = createDescriptor(descriptorInfo, raise_failure);
+            if (!descriptor.has_value()) {
+                return nullptr;
+            }
+
             if (::testing::Test::HasFatalFailure()) {
                 return nullptr;
             }
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-            status = mAllocator->allocate(descriptor, 1, &result);
+            status = mAllocator->allocate(descriptor.value(), 1, &result);
 #pragma clang diagnostic pop  // deprecation
         }
         if (!status.isOk()) {
@@ -380,7 +393,7 @@
             .reservedSize = 0,
     };
     const bool supported = isSupported(info);
-    auto buffer = allocate(info);
+    auto buffer = allocate(info, /*raise_failure=*/supported);
     if (!supported) {
         ASSERT_EQ(nullptr, buffer.get())
                 << "Allocation succeeded, but IMapper::isSupported was false";
@@ -422,7 +435,7 @@
             .reservedSize = 0,
     };
     const bool supported = isSupported(info);
-    auto buffer = allocate(info);
+    auto buffer = allocate(info, /*raise_failure=*/supported);
     if (!supported) {
         ASSERT_EQ(nullptr, buffer.get())
                 << "Allocation succeeded, but IMapper::isSupported was false";
@@ -480,4 +493,4 @@
         [](auto info) -> std::string {
             std::string name = std::to_string(info.index) + "/" + std::get<1>(info.param).name;
             return Sanitize(name);
-        });
\ No newline at end of file
+        });
diff --git a/sensors/OWNERS b/sensors/OWNERS
index 5017a9a..b647f3b 100644
--- a/sensors/OWNERS
+++ b/sensors/OWNERS
@@ -1,3 +1,2 @@
 # Bug component: 62965
-
-bduddie@google.com
+include platform/frameworks/native:/services/sensorservice/OWNERS
\ No newline at end of file
diff --git a/usb/OWNERS b/usb/OWNERS
index 647d626..0c73782 100644
--- a/usb/OWNERS
+++ b/usb/OWNERS
@@ -1,8 +1,8 @@
 # Bug component: 175220
 
-anothermark@google.com
+vmartensson@google.com
+nkapron@google.com
 febinthattil@google.com
-aprasath@google.com
+shubhankarm@google.com
 albertccwang@google.com
-badhri@google.com
-kumarashishg@google.com
\ No newline at end of file
+badhri@google.com
\ No newline at end of file