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

Commit 7dca8d75 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix package name reporting in MediaDrm metrics." into oc-mr1-dev

parents 87201120 21c72125
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -44,6 +44,13 @@ status_t reportMetricsGroup(const MetricsGroup& metricsGroup,
        analyticsItem.setInt64(kParentAttribute, *parentId);
    }

    // Report the package name.
    if (metricsGroup.has_app_package_name()) {
      AString app_package_name(metricsGroup.app_package_name().c_str(),
                               metricsGroup.app_package_name().size());
      analyticsItem.setPkgName(app_package_name);
    }

    for (int i = 0; i < metricsGroup.metric_size(); ++i) {
        const MetricsGroup_Metric& metric = metricsGroup.metric(i);
        if (!metric.has_name()) {
@@ -73,7 +80,12 @@ status_t reportMetricsGroup(const MetricsGroup& metricsGroup,
    }

    analyticsItem.setFinalized(true);
    analyticsItem.selfrecord();
    if (!analyticsItem.selfrecord()) {
      // Note the cast to int is because we build on 32 and 64 bit.
      // The cast prevents a peculiar printf problem where one format cannot
      // satisfy both.
      ALOGE("selfrecord() returned false. sessioId %d", (int) sessionId);
    }

    for (int i = 0; i < metricsGroup.metric_sub_group_size(); ++i) {
        const MetricsGroup& subGroup = metricsGroup.metric_sub_group(i);
+3 −0
Original line number Diff line number Diff line
@@ -44,4 +44,7 @@ message MetricsGroup {

  // Allow multiple sub groups of metrics.
  repeated MetricsGroup metric_sub_group = 2;

  // Name of the application package associated with the metrics.
  optional string app_package_name = 3;
}
+15 −8
Original line number Diff line number Diff line
@@ -257,9 +257,21 @@ MediaAnalyticsItem::SessionID_t MediaAnalyticsService::submit(MediaAnalyticsItem
            break;
    }

    // Overwrite package name and version if the caller was untrusted.
    if (!isTrusted) {
      item->setPkgName(getPkgName(item->getUid(), true));
      item->setPkgVersionCode(0);
    ALOGV("info is from uid %d pkg '%s', version %d", item->getUid(), item->getPkgName().c_str(), item->getPkgVersionCode());
    } else if (item->getPkgName().empty()) {
      // Only overwrite the package name if it was empty. Trust whatever
      // version code was provided by the trusted caller.
      item->setPkgName(getPkgName(uid, true));
    }

    ALOGV("given uid %d; sanitized uid: %d sanitized pkg: %s "
          "sanitized pkg version: %d",
          uid_given, item->getUid(),
          item->getPkgName().c_str(),
          item->getPkgVersionCode());

    mItemsSubmitted++;

@@ -638,11 +650,6 @@ void MediaAnalyticsService::saveItem(List<MediaAnalyticsItem *> *l, MediaAnalyti
// are they alike enough that nitem can be folded into oitem?
static bool compatibleItems(MediaAnalyticsItem * oitem, MediaAnalyticsItem * nitem) {

    if (0) {
        ALOGD("Compare: o %s n %s",
              oitem->toString().c_str(), nitem->toString().c_str());
    }

    // general safety
    if (nitem->getUid() != oitem->getUid()) {
        return false;