libfmq: Make dupeDesc const

Allows the Rust `dupe_desc` to take a regular, non-mut ref which keeps
mutable refs out of downstream getters.

Test: atest --host fmq_unit_tests
Change-Id: I2b60ca8844528a67cda58c281bfaa8fde134b60e
diff --git a/ErasedMessageQueue.cpp b/ErasedMessageQueue.cpp
index c84b554..a0637fb 100644
--- a/ErasedMessageQueue.cpp
+++ b/ErasedMessageQueue.cpp
@@ -112,6 +112,6 @@
     return inner->commitRead(nMessages);
 }
 
-ErasedMessageQueueDesc* ErasedMessageQueue::dupeDesc() {
+ErasedMessageQueueDesc* ErasedMessageQueue::dupeDesc() const {
     return new ErasedMessageQueueDesc(inner->dupeDesc());
 }
diff --git a/ErasedMessageQueue.hpp b/ErasedMessageQueue.hpp
index b3c4357..b4b5931 100644
--- a/ErasedMessageQueue.hpp
+++ b/ErasedMessageQueue.hpp
@@ -161,5 +161,5 @@
      * @return ErasedMessageQueueDesc The copied descriptor, which must be freed
      * by passing it to freeDesc.
      */
-    ErasedMessageQueueDesc* dupeDesc();
+    ErasedMessageQueueDesc* dupeDesc() const;
 };
diff --git a/include/fmq/AidlMessageQueue.h b/include/fmq/AidlMessageQueue.h
index 138760f..e4c3d84 100644
--- a/include/fmq/AidlMessageQueue.h
+++ b/include/fmq/AidlMessageQueue.h
@@ -115,7 +115,7 @@
                      android::base::unique_fd bufferFd, size_t bufferSize,
                      std::enable_if_t<std::is_same_v<V, MQErased>, size_t> quantum);
 
-    MQDescriptor<T, U> dupeDesc();
+    MQDescriptor<T, U> dupeDesc() const;
 
   private:
     AidlMessageQueue(const AidlMessageQueue& other) = delete;
@@ -144,7 +144,7 @@
               quantum) {}
 
 template <typename T, typename U>
-MQDescriptor<T, U> AidlMessageQueue<T, U>::dupeDesc() {
+MQDescriptor<T, U> AidlMessageQueue<T, U>::dupeDesc() const {
     auto* shim = MessageQueueBase<AidlMQDescriptorShim, T, FlavorTypeToValue<U>::value>::getDesc();
     if (shim) {
         std::vector<aidl::android::hardware::common::fmq::GrantorDescriptor> grantors;
diff --git a/libfmq.rs b/libfmq.rs
index a215a02..b743df1 100644
--- a/libfmq.rs
+++ b/libfmq.rs
@@ -202,7 +202,7 @@
 
     /// Obtain a copy of the MessageQueue's descriptor, which may be used to
     /// access it remotely.
-    pub fn dupe_desc(&mut self) -> MQDescriptor<T, SynchronizedReadWrite> {
+    pub fn dupe_desc(&self) -> MQDescriptor<T, SynchronizedReadWrite> {
         // SAFETY: dupeDesc may be called on any valid ErasedMessageQueue; it
         // simply forwards to dupeDesc on the inner AidlMessageQueue and wraps
         // in a heap allocation.
diff --git a/tests/msgq_rust_test_client.rs b/tests/msgq_rust_test_client.rs
index bad57a7..a78000a 100644
--- a/tests/msgq_rust_test_client.rs
+++ b/tests/msgq_rust_test_client.rs
@@ -33,7 +33,7 @@
     let num_elements_in_sync_queue: usize = (page_size - 16) / std::mem::size_of::<i32>();
 
     /* Create a queue on the client side. */
-    let mut mq = MessageQueue::<i32>::new(
+    let mq = MessageQueue::<i32>::new(
         num_elements_in_sync_queue,
         true, /* configure event flag word */
     );