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

Commit 4ae167e8 authored by Ruchir Rastogi's avatar Ruchir Rastogi
Browse files

Use proper platform version checks (libstats)

Test: bit libstatspush_compat_test
Bug: 146019024
Change-Id: If99a7067944ddfbe30bb0ddfe586a337a94d4c07
parent 67a2bebf
Loading
Loading
Loading
Loading
+1 −10
Original line number Original line Diff line number Diff line
@@ -28,17 +28,8 @@ using android::base::boot_clock;
using android::base::GetProperty;
using android::base::GetProperty;


const static int kStatsEventTag = 1937006964;
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 =
const bool StatsEventCompat::mPlatformAtLeastR =
        GetProperty("ro.build.version.codename", "") == "R" ||
        android_get_device_api_level() >= __ANDROID_API_R__;
        android_get_device_api_level() > __ANDROID_API_Q__;


// initializations of static class variables
// initializations of static class variables
bool StatsEventCompat::mAttemptedLoad = false;
bool StatsEventCompat::mAttemptedLoad = false;
+1 −10
Original line number Original line Diff line number Diff line
@@ -21,16 +21,7 @@


using android::base::GetProperty;
using android::base::GetProperty;


/* Checking ro.build.version.release is fragile, as the release field is
const static bool mPlatformAtLeastR = android_get_device_api_level() >= __ANDROID_API_R__;
 * 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__;


TEST(StatsEventCompatTest, TestDynamicLoading) {
TEST(StatsEventCompatTest, TestDynamicLoading) {
    StatsEventCompat event;
    StatsEventCompat event;