Commit 16df2042 authored by Dan Harrington's avatar Dan Harrington Committed by Chromium LUCI CQ

report installer package enum in metrics upload

Bug: b/173610894
Change-Id: I20bb9ebb59a04b6d13b8cc4a1a3fabfbf4c7d6be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2558977
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832021}
parent ca322951
......@@ -77,6 +77,19 @@ static int64_t ToMonotonicSeconds(base::TimeTicks time_ticks) {
} // namespace
namespace internal {
SystemProfileProto::InstallerPackage ToInstallerPackage(
base::StringPiece installer_package_name) {
if (installer_package_name.empty())
return SystemProfileProto::INSTALLER_PACKAGE_NONE;
if (installer_package_name == "com.android.vending")
return SystemProfileProto::INSTALLER_PACKAGE_GOOGLE_PLAY_STORE;
return SystemProfileProto::INSTALLER_PACKAGE_OTHER;
}
} // namespace internal
MetricsLog::IndependentMetricsLoader::IndependentMetricsLoader(
std::unique_ptr<MetricsLog> log)
: log_(std::move(log)),
......@@ -232,10 +245,12 @@ void MetricsLog::RecordCoreSystemProfile(
#endif
#if defined(OS_ANDROID)
os->set_build_fingerprint(
base::android::BuildInfo::GetInstance()->android_build_fp());
const auto* build_info = base::android::BuildInfo::GetInstance();
os->set_build_fingerprint(build_info->android_build_fp());
if (!package_name.empty() && package_name != "com.android.chrome")
system_profile->set_app_package_name(package_name);
system_profile->set_installer_package(
internal::ToInstallerPackage(build_info->installer_package_name()));
#elif defined(OS_IOS)
os->set_build_number(base::SysInfo::GetIOSBuildNumber());
#endif
......
......@@ -17,9 +17,11 @@
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/metrics/histogram_base.h"
#include "base/strings/string_piece_forward.h"
#include "base/time/time.h"
#include "components/metrics/metrics_reporting_default_state.h"
#include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h"
#include "third_party/metrics_proto/system_profile.pb.h"
class PrefService;
......@@ -39,6 +41,9 @@ namespace internal {
// Maximum number of events before truncation.
constexpr int kOmniboxEventLimit = 5000;
constexpr int kUserActionEventLimit = 5000;
SystemProfileProto::InstallerPackage ToInstallerPackage(
base::StringPiece installer_package_name);
} // namespace internal
class MetricsLog {
......
......@@ -214,6 +214,10 @@ TEST_F(MetricsLogTest, BasicRecord) {
// Hard to mock.
system_profile->set_build_timestamp(
parsed.system_profile().build_timestamp());
#if defined(OS_ANDROID)
system_profile->set_installer_package(
parsed.system_profile().installer_package());
#endif
EXPECT_EQ(expected.SerializeAsString(), encoded);
}
......@@ -420,4 +424,13 @@ TEST_F(MetricsLogTest, TruncateEvents) {
EXPECT_EQ(internal::kOmniboxEventLimit, log.uma_proto().omnibox_event_size());
}
TEST_F(MetricsLogTest, ToInstallerPackage) {
using internal::ToInstallerPackage;
EXPECT_EQ(SystemProfileProto::INSTALLER_PACKAGE_NONE, ToInstallerPackage(""));
EXPECT_EQ(SystemProfileProto::INSTALLER_PACKAGE_GOOGLE_PLAY_STORE,
ToInstallerPackage("com.android.vending"));
EXPECT_EQ(SystemProfileProto::INSTALLER_PACKAGE_OTHER,
ToInstallerPackage("foo"));
}
} // namespace metrics
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment