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) { ...@@ -108,8 +108,8 @@ base::Value ConvertEventsToValue(const Events& events, Profile* profile) {
for (const em::AppInstallReportLogEvent& app_install_report_log_event : for (const em::AppInstallReportLogEvent& app_install_report_log_event :
(*it).second) { (*it).second) {
base::Value wrapper; base::Value wrapper;
wrapper = ConvertEventToValue(package, app_install_report_log_event, wrapper =
context, profile); ConvertEventToValue(package, app_install_report_log_event, context);
event_list.Append(std::move(wrapper)); event_list.Append(std::move(wrapper));
} }
} }
......
...@@ -100,7 +100,7 @@ void AppInstallEventLogUploader::StartSerialization() { ...@@ -100,7 +100,7 @@ void AppInstallEventLogUploader::StartSerialization() {
void AppInstallEventLogUploader::OnSerialized( void AppInstallEventLogUploader::OnSerialized(
const em::AppInstallReportRequest* report) { const em::AppInstallReportRequest* report) {
base::Value context = reporting::GetContext(profile_); 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( base::Value value_report = RealtimeReportingJobConfiguration::BuildReport(
std::move(event_list), std::move(context)); std::move(event_list), std::move(context));
......
...@@ -126,8 +126,7 @@ class AppInstallEventLogUploaderTest : public testing::Test { ...@@ -126,8 +126,7 @@ class AppInstallEventLogUploaderTest : public testing::Test {
ClearReportDict(); ClearReportDict();
base::Value context = reporting::GetContext(/*profile=*/nullptr); base::Value context = reporting::GetContext(/*profile=*/nullptr);
value_report_ = RealtimeReportingJobConfiguration::BuildReport( value_report_ = RealtimeReportingJobConfiguration::BuildReport(
ConvertProtoToValue(&log_, context, /*profile=*/nullptr), ConvertProtoToValue(&log_, context), std::move(context));
std::move(context));
EXPECT_CALL(client_, UploadRealtimeReport_(MatchValue(&value_report_), _)) EXPECT_CALL(client_, UploadRealtimeReport_(MatchValue(&value_report_), _))
.WillOnce(WithArgs<1>( .WillOnce(WithArgs<1>(
...@@ -140,8 +139,7 @@ class AppInstallEventLogUploaderTest : public testing::Test { ...@@ -140,8 +139,7 @@ class AppInstallEventLogUploaderTest : public testing::Test {
ClearReportDict(); ClearReportDict();
base::Value context = reporting::GetContext(/*profile=*/nullptr); base::Value context = reporting::GetContext(/*profile=*/nullptr);
value_report_ = RealtimeReportingJobConfiguration::BuildReport( value_report_ = RealtimeReportingJobConfiguration::BuildReport(
ConvertProtoToValue(&log_, context, /*profile=*/nullptr), ConvertProtoToValue(&log_, context), std::move(context));
std::move(context));
CloudPolicyClient::StatusCallback status_callback; CloudPolicyClient::StatusCallback status_callback;
EXPECT_CALL(client_, UploadRealtimeReport_(MatchValue(&value_report_), _)) EXPECT_CALL(client_, UploadRealtimeReport_(MatchValue(&value_report_), _))
......
...@@ -11,11 +11,7 @@ ...@@ -11,11 +11,7 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/values.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 "chromeos/system/statistics_provider.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/user.h"
namespace em = enterprise_management; namespace em = enterprise_management;
...@@ -33,7 +29,6 @@ constexpr char kCloudDpsResponse[] = "clouddpsResponse"; ...@@ -33,7 +29,6 @@ constexpr char kCloudDpsResponse[] = "clouddpsResponse";
constexpr char kOnline[] = "online"; constexpr char kOnline[] = "online";
constexpr char kSessionStateChangeType[] = "sessionStateChangeType"; constexpr char kSessionStateChangeType[] = "sessionStateChangeType";
constexpr char kSerialNumber[] = "serialNumber"; constexpr char kSerialNumber[] = "serialNumber";
constexpr char kGaiaId[] = "gaiaId";
constexpr char kAndroidAppInstallEvent[] = "androidAppInstallEvent"; constexpr char kAndroidAppInstallEvent[] = "androidAppInstallEvent";
constexpr char kTime[] = "time"; constexpr char kTime[] = "time";
constexpr char kEventId[] = "eventId"; constexpr char kEventId[] = "eventId";
...@@ -68,18 +63,6 @@ bool GetHash(const base::Value& event, ...@@ -68,18 +63,6 @@ bool GetHash(const base::Value& event,
} // namespace } // 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() { std::string GetSerialNumber() {
return chromeos::system::StatisticsProvider::GetInstance() return chromeos::system::StatisticsProvider::GetInstance()
->GetEnterpriseMachineID(); ->GetEnterpriseMachineID();
...@@ -87,8 +70,7 @@ std::string GetSerialNumber() { ...@@ -87,8 +70,7 @@ std::string GetSerialNumber() {
base::Value ConvertProtoToValue( base::Value ConvertProtoToValue(
const em::AppInstallReportRequest* app_install_report_request, const em::AppInstallReportRequest* app_install_report_request,
const base::Value& context, const base::Value& context) {
Profile* profile) {
DCHECK(app_install_report_request); DCHECK(app_install_report_request);
base::Value event_list(base::Value::Type::LIST); base::Value event_list(base::Value::Type::LIST);
...@@ -101,7 +83,7 @@ base::Value ConvertProtoToValue( ...@@ -101,7 +83,7 @@ base::Value ConvertProtoToValue(
base::Value wrapper; base::Value wrapper;
wrapper = ConvertEventToValue( wrapper = ConvertEventToValue(
app_install_report.has_package() ? app_install_report.package() : "", 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); auto* id = wrapper.FindStringKey(kEventId);
if (id) { if (id) {
if (seen_ids.find(*id) != seen_ids.end()) { if (seen_ids.find(*id) != seen_ids.end()) {
...@@ -121,8 +103,7 @@ base::Value ConvertProtoToValue( ...@@ -121,8 +103,7 @@ base::Value ConvertProtoToValue(
base::Value ConvertEventToValue( base::Value ConvertEventToValue(
const std::string& package, const std::string& package,
const em::AppInstallReportLogEvent& app_install_report_log_event, const em::AppInstallReportLogEvent& app_install_report_log_event,
const base::Value& context, const base::Value& context) {
Profile* profile) {
base::Value event(base::Value::Type::DICTIONARY); base::Value event(base::Value::Type::DICTIONARY);
if (!package.empty()) if (!package.empty())
...@@ -168,10 +149,6 @@ base::Value ConvertEventToValue( ...@@ -168,10 +149,6 @@ base::Value ConvertEventToValue(
event.SetStringKey(kSerialNumber, GetSerialNumber()); event.SetStringKey(kSerialNumber, GetSerialNumber());
int gaia_id;
if (GetGaiaId(profile, &gaia_id))
event.SetIntKey(kGaiaId, gaia_id);
base::Value wrapper(base::Value::Type::DICTIONARY); base::Value wrapper(base::Value::Type::DICTIONARY);
wrapper.SetKey(kAndroidAppInstallEvent, std::move(event)); wrapper.SetKey(kAndroidAppInstallEvent, std::move(event));
......
...@@ -11,17 +11,10 @@ namespace base { ...@@ -11,17 +11,10 @@ namespace base {
class Value; class Value;
} // namespace base } // namespace base
class Profile;
namespace em = enterprise_management; namespace em = enterprise_management;
namespace policy { 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. // Return serial number of the device.
std::string GetSerialNumber(); std::string GetSerialNumber();
...@@ -34,8 +27,7 @@ std::string GetSerialNumber(); ...@@ -34,8 +27,7 @@ std::string GetSerialNumber();
// locally. // locally.
base::Value ConvertProtoToValue( base::Value ConvertProtoToValue(
const em::AppInstallReportRequest* app_install_report_request, const em::AppInstallReportRequest* app_install_report_request,
const base::Value& context, const base::Value& context);
Profile* profile);
// Converts AppInstallReportLogEvent proto defined in // Converts AppInstallReportLogEvent proto defined in
// components/policy/proto/device_management_backend.proto to a dictionary value // components/policy/proto/device_management_backend.proto to a dictionary value
...@@ -46,8 +38,7 @@ base::Value ConvertProtoToValue( ...@@ -46,8 +38,7 @@ base::Value ConvertProtoToValue(
base::Value ConvertEventToValue( base::Value ConvertEventToValue(
const std::string& package, const std::string& package,
const em::AppInstallReportLogEvent& app_install_report_log_event, const em::AppInstallReportLogEvent& app_install_report_log_event,
const base::Value& context, const base::Value& context);
Profile* profile);
} // namespace policy } // 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