MediaMetrics: Make Item final

Test: atest mediametrics_tests
Bug: 138583596
Change-Id: Ibab0eff8f1d4e9786b366dcc19589b0a8ec2137f
diff --git a/media/libmediametrics/include/MediaMetricsItem.h b/media/libmediametrics/include/MediaMetricsItem.h
index 880a8c9..001a8cf 100644
--- a/media/libmediametrics/include/MediaMetricsItem.h
+++ b/media/libmediametrics/include/MediaMetricsItem.h
@@ -616,7 +616,7 @@
  *
  * The Item is designed for the service as it has getters.
  */
-class Item : public mediametrics::BaseItem {
+class Item final : public mediametrics::BaseItem {
 public:
 
     class Prop {
@@ -790,6 +790,13 @@
         : mKey(key) { }
     Item() = default;
 
+    // We enable default copy and move constructors and make this class final
+    // to prevent a derived class; this avoids possible data slicing.
+    Item(const Item& other) = default;
+    Item(Item&& other) = default;
+    Item& operator=(const Item& other) = default;
+    Item& operator=(Item&& other) = default;
+
     bool operator==(const Item& other) const {
         if (mPid != other.mPid
             || mUid != other.mUid
@@ -991,6 +998,7 @@
         return prop;
     }
 
+    // Changes to member variables below require changes to clear().
     pid_t         mPid = -1;
     uid_t         mUid = -1;
     std::string   mPkgName;