MediaMetrics: Make submit one-way
Remove the unused session id to improve speed and clarity.
Test: dumpsys media.metrics sanity, mediametrics_tests
Change-Id: Ide5e9218811e110997fed19f43eb6a5fdc5812ec
diff --git a/services/mediaanalytics/MediaAnalyticsService.h b/services/mediaanalytics/MediaAnalyticsService.h
index ed7b7b1..eb7d725 100644
--- a/services/mediaanalytics/MediaAnalyticsService.h
+++ b/services/mediaanalytics/MediaAnalyticsService.h
@@ -35,31 +35,28 @@
~MediaAnalyticsService() override;
/**
- * Submits the indicated record to the mediaanalytics service, where
- * it will be merged (if appropriate) with incomplete records that
- * share the same key and sessionid.
+ * Submits the indicated record to the mediaanalytics service.
*
* \param item the item to submit.
- * \param forcenew marks any matching incomplete record as complete before
- * inserting this new record.
- *
- * \return the sessionID associated with that item or
- * MediaAnalyticsItem::SessionIDInvalid on failure.
- *
- * BEWARE: When called directly on the service (not from the binder interface),
- * the caller surrenders ownership of item, MediaAnalyticsService will delete
- * even on error. The binder interface does not take ownership.
- * TODO: fix this inconsistency with the binder RPC interface.
+ * \return status failure, which is negative on binder transaction failure.
+ * As the transaction is one-way, remote failures will not be reported.
*/
- MediaAnalyticsItem::SessionID_t submit(MediaAnalyticsItem *item, bool forcenew) override;
+ status_t submit(MediaAnalyticsItem *item) override {
+ return submitInternal(item, false /* release */);
+ }
status_t dump(int fd, const Vector<String16>& args) override;
static constexpr const char * const kServiceName = "media.metrics";
+protected:
+
+ // Internal call where release is true if ownership of item is transferred
+ // to the service (that is, the service will eventually delete the item).
+ status_t submitInternal(MediaAnalyticsItem *item, bool release) override;
+
private:
void processExpirations();
- MediaAnalyticsItem::SessionID_t generateUniqueSessionID();
// input validation after arrival from client
static bool isContentValid(const MediaAnalyticsItem *item, bool isTrusted);
bool isRateLimited(MediaAnalyticsItem *) const;
@@ -86,8 +83,6 @@
const size_t mMaxRecordsExpiredAtOnce;
const int mDumpProtoDefault;
- std::atomic<MediaAnalyticsItem::SessionID_t> mLastSessionID{};
-
class UidInfo {
public:
void setPkgInfo(MediaAnalyticsItem *item, uid_t uid, bool setName, bool setVersion);