From 4ae167e82900682900844ba302208483483f9a41 Mon Sep 17 00:00:00 2001 From: Ruchir Rastogi Date: Thu, 7 May 2020 12:29:01 -0700 Subject: [PATCH] Use proper platform version checks (libstats) Test: bit libstatspush_compat_test Bug: 146019024 Change-Id: If99a7067944ddfbe30bb0ddfe586a337a94d4c07 --- libstats/push_compat/StatsEventCompat.cpp | 11 +---------- libstats/push_compat/tests/StatsEventCompat_test.cpp | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/libstats/push_compat/StatsEventCompat.cpp b/libstats/push_compat/StatsEventCompat.cpp index e1a86ae1a..c17ca61f1 100644 --- a/libstats/push_compat/StatsEventCompat.cpp +++ b/libstats/push_compat/StatsEventCompat.cpp @@ -28,17 +28,8 @@ using android::base::boot_clock; using android::base::GetProperty; const static int kStatsEventTag = 1937006964; - -/* Checking ro.build.version.release is fragile, as the release field is - * an opaque string without structural guarantees. However, testing confirms - * that on Q devices, the property is "10," and on R, it is "R." Until - * android_get_device_api_level() is updated, this is the only solution. - * - * TODO(b/146019024): migrate to android_get_device_api_level() - */ const bool StatsEventCompat::mPlatformAtLeastR = - GetProperty("ro.build.version.codename", "") == "R" || - android_get_device_api_level() > __ANDROID_API_Q__; + android_get_device_api_level() >= __ANDROID_API_R__; // initializations of static class variables bool StatsEventCompat::mAttemptedLoad = false; diff --git a/libstats/push_compat/tests/StatsEventCompat_test.cpp b/libstats/push_compat/tests/StatsEventCompat_test.cpp index dcb37973e..2a70db503 100644 --- a/libstats/push_compat/tests/StatsEventCompat_test.cpp +++ b/libstats/push_compat/tests/StatsEventCompat_test.cpp @@ -21,16 +21,7 @@ using android::base::GetProperty; -/* Checking ro.build.version.release is fragile, as the release field is - * an opaque string without structural guarantees. However, testing confirms - * that on Q devices, the property is "10," and on R, it is "R." Until - * android_get_device_api_level() is updated, this is the only solution. - * - * - * TODO(b/146019024): migrate to android_get_device_api_level() - */ -const static bool mPlatformAtLeastR = GetProperty("ro.build.version.codename", "") == "R" || - android_get_device_api_level() > __ANDROID_API_Q__; +const static bool mPlatformAtLeastR = android_get_device_api_level() >= __ANDROID_API_R__; TEST(StatsEventCompatTest, TestDynamicLoading) { StatsEventCompat event;