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

Commit 692870bd authored by Andy Hung's avatar Andy Hung
Browse files

MediaMetrics: Add Elem getter to Item

And minor edits.

Test: atest mediametrics_tests
Bug: 138583596
Change-Id: I9161f98f4c17516ea04fc143eb1ccbd656f17796
parent 565cc485
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -798,14 +798,14 @@ public:
    Item& operator=(Item&& other) = default;

    bool operator==(const Item& other) const {
        if (mPid != other.mPid
            || mUid != other.mUid
            || mPkgName != other.mPkgName
            || mPkgVersionCode != other.mPkgVersionCode
            || mKey != other.mKey
            || mTimestamp != other.mTimestamp
            || mProps != other.mProps) return false;
         return true;
        return mPid == other.mPid
            && mUid == other.mUid
            && mPkgName == other.mPkgName
            && mPkgVersionCode == other.mPkgVersionCode
            && mKey == other.mKey
            && mTimestamp == other.mTimestamp
            && mProps == other.mProps
            ;
    }
    bool operator!=(const Item& other) const {
        return !(*this == other);
@@ -935,6 +935,11 @@ public:
        return get(key, value);
    }

    const Prop::Elem* get(const char *key) const {
        const Prop *prop = findProp(key);
        return prop == nullptr ? nullptr : &prop->get();
    }

        // Deliver the item to MediaMetrics
        bool selfrecord();

+5 −0
Original line number Diff line number Diff line
@@ -262,27 +262,32 @@ TEST(mediametrics_tests, item_iteration) {
          int32_t i32;
          ASSERT_TRUE(prop.get(&i32));
          ASSERT_EQ(1, i32);
          ASSERT_EQ(1, std::get<int32_t>(prop.get()));
          mask |= 1;
      } else if (!strcmp(name, "i64")) {
          int64_t i64;
          ASSERT_TRUE(prop.get(&i64));
          ASSERT_EQ(2, i64);
          ASSERT_EQ(2, std::get<int64_t>(prop.get()));
          mask |= 2;
      } else if (!strcmp(name, "double")) {
          double d;
          ASSERT_TRUE(prop.get(&d));
          ASSERT_EQ(3.125, d);
          ASSERT_EQ(3.125, std::get<double>(prop.get()));
          mask |= 4;
      } else if (!strcmp(name, "string")) {
          std::string s;
          ASSERT_TRUE(prop.get(&s));
          ASSERT_EQ("abc", s);
          ASSERT_EQ(s, std::get<std::string>(prop.get()));
          mask |= 8;
      } else if (!strcmp(name, "rate")) {
          std::pair<int64_t, int64_t> r;
          ASSERT_TRUE(prop.get(&r));
          ASSERT_EQ(11, r.first);
          ASSERT_EQ(12, r.second);
          ASSERT_EQ(r, std::get<decltype(r)>(prop.get()));
          mask |= 16;
      } else {
          FAIL();