MediaMetrics: Add Elem getter to Item
And minor edits.
Test: atest mediametrics_tests
Bug: 138583596
Change-Id: I9161f98f4c17516ea04fc143eb1ccbd656f17796
diff --git a/media/libmediametrics/include/MediaMetricsItem.h b/media/libmediametrics/include/MediaMetricsItem.h
index 001a8cf..5765dc5 100644
--- a/media/libmediametrics/include/MediaMetricsItem.h
+++ b/media/libmediametrics/include/MediaMetricsItem.h
@@ -128,7 +128,7 @@
template<size_t N>
static inline bool startsWith(const std::string &s, const char (&comp)[N]) {
- return !strncmp(s.c_str(), comp, N-1);
+ return !strncmp(s.c_str(), comp, N - 1);
}
/**
@@ -798,14 +798,14 @@
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 @@
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();