Commit 3515c572 authored by Zach Trudo's avatar Zach Trudo Committed by Commit Bot

Remove Gaia ID from AndroidAppInstallEvent

Gaia ID was incorrectly reported previously:
1. It was stored as an int when the obfuscated Gaia ID cannot be
   converted to an int.
2. It was then converted to an int64 in the proto.

The proto symbol for Gaia ID will be deprecated and it's identifier will
be reserved for future use.

Removing the Gaia ID prior to deprecation.

Bug: 1045967
Change-Id: I4c3477005788046408e3ae81f8ee37cfc1df17d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2028211
Commit-Queue: Zach Trudo <zatrudo@google.com>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Auto-Submit: Zach Trudo <zatrudo@google.com>
Cr-Commit-Position: refs/heads/master@{#737028}
parent 55d99a69
......@@ -108,8 +108,8 @@ base::Value ConvertEventsToValue(const Events& events, Profile* profile) {
for (const em::AppInstallReportLogEvent& app_install_report_log_event :
(*it).second) {
base::Value wrapper;
wrapper = ConvertEventToValue(package, app_install_report_log_event,
context, profile);
wrapper =
ConvertEventToValue(package, app_install_report_log_event, context);
event_list.Append(std::move(wrapper));
}
}
......
......@@ -100,7 +100,7 @@ void AppInstallEventLogUploader::StartSerialization() {
void AppInstallEventLogUploader::OnSerialized(
const em::AppInstallReportRequest* report) {
base::Value context = reporting::GetContext(profile_);
base::Value event_list = ConvertProtoToValue(report, context, profile_);
base::Value event_list = ConvertProtoToValue(report, context);
base::Value value_report = RealtimeReportingJobConfiguration::BuildReport(
std::move(event_list), std::move(context));
......
......@@ -126,8 +126,7 @@ class AppInstallEventLogUploaderTest : public testing::Test {
ClearReportDict();
base::Value context = reporting::GetContext(/*profile=*/nullptr);
value_report_ = RealtimeReportingJobConfiguration::BuildReport(
ConvertProtoToValue(&log_, context, /*profile=*/nullptr),
std::move(context));
ConvertProtoToValue(&log_, context), std::move(context));
EXPECT_CALL(client_, UploadRealtimeReport_(MatchValue(&value_report_), _))
.WillOnce(WithArgs<1>(
......@@ -140,8 +139,7 @@ class AppInstallEventLogUploaderTest : public testing::Test {
ClearReportDict();
base::Value context = reporting::GetContext(/*profile=*/nullptr);
value_report_ = RealtimeReportingJobConfiguration::BuildReport(
ConvertProtoToValue(&log_, context, /*profile=*/nullptr),
std::move(context));
ConvertProtoToValue(&log_, context), std::move(context));
CloudPolicyClient::StatusCallback status_callback;
EXPECT_CALL(client_, UploadRealtimeReport_(MatchValue(&value_report_), _))
......
......@@ -11,11 +11,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/system/statistics_provider.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/user.h"
namespace em = enterprise_management;
......@@ -33,7 +29,6 @@ constexpr char kCloudDpsResponse[] = "clouddpsResponse";
constexpr char kOnline[] = "online";
constexpr char kSessionStateChangeType[] = "sessionStateChangeType";
constexpr char kSerialNumber[] = "serialNumber";
constexpr char kGaiaId[] = "gaiaId";
constexpr char kAndroidAppInstallEvent[] = "androidAppInstallEvent";
constexpr char kTime[] = "time";
constexpr char kEventId[] = "eventId";
......@@ -68,18 +63,6 @@ bool GetHash(const base::Value& event,
} // namespace
bool GetGaiaId(Profile* profile, int* gaia_id) {
if (!profile)
return false;
const user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (!user)
return false;
if (!base::StringToInt(user->GetAccountId().GetGaiaId(), gaia_id))
return false;
return true;
}
std::string GetSerialNumber() {
return chromeos::system::StatisticsProvider::GetInstance()
->GetEnterpriseMachineID();
......@@ -87,8 +70,7 @@ std::string GetSerialNumber() {
base::Value ConvertProtoToValue(
const em::AppInstallReportRequest* app_install_report_request,
const base::Value& context,
Profile* profile) {
const base::Value& context) {
DCHECK(app_install_report_request);
base::Value event_list(base::Value::Type::LIST);
......@@ -101,7 +83,7 @@ base::Value ConvertProtoToValue(
base::Value wrapper;
wrapper = ConvertEventToValue(
app_install_report.has_package() ? app_install_report.package() : "",
app_install_report_log_event, context, profile);
app_install_report_log_event, context);
auto* id = wrapper.FindStringKey(kEventId);
if (id) {
if (seen_ids.find(*id) != seen_ids.end()) {
......@@ -121,8 +103,7 @@ base::Value ConvertProtoToValue(
base::Value ConvertEventToValue(
const std::string& package,
const em::AppInstallReportLogEvent& app_install_report_log_event,
const base::Value& context,
Profile* profile) {
const base::Value& context) {
base::Value event(base::Value::Type::DICTIONARY);
if (!package.empty())
......@@ -168,10 +149,6 @@ base::Value ConvertEventToValue(
event.SetStringKey(kSerialNumber, GetSerialNumber());
int gaia_id;
if (GetGaiaId(profile, &gaia_id))
event.SetIntKey(kGaiaId, gaia_id);
base::Value wrapper(base::Value::Type::DICTIONARY);
wrapper.SetKey(kAndroidAppInstallEvent, std::move(event));
......
......@@ -11,17 +11,10 @@ namespace base {
class Value;
} // namespace base
class Profile;
namespace em = enterprise_management;
namespace policy {
// Returns true if GAIA ID can be fetched for a given |profile|, and it can be
// converted to a number. If GAIA ID can be fetched, it gets written to
// |gaia_id|, otherwise returns false.
bool GetGaiaId(Profile* profile, int* gaia_id);
// Return serial number of the device.
std::string GetSerialNumber();
......@@ -34,8 +27,7 @@ std::string GetSerialNumber();
// locally.
base::Value ConvertProtoToValue(
const em::AppInstallReportRequest* app_install_report_request,
const base::Value& context,
Profile* profile);
const base::Value& context);
// Converts AppInstallReportLogEvent proto defined in
// components/policy/proto/device_management_backend.proto to a dictionary value
......@@ -46,8 +38,7 @@ base::Value ConvertProtoToValue(
base::Value ConvertEventToValue(
const std::string& package,
const em::AppInstallReportLogEvent& app_install_report_log_event,
const base::Value& context,
Profile* profile);
const base::Value& context);
} // namespace policy
......
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