diff options
-rw-r--r-- | statsd/src/StatsLogProcessor.cpp | 16 | ||||
-rw-r--r-- | statsd/src/StatsService.cpp | 6 | ||||
-rw-r--r-- | statsd/src/flags/FlagProvider.cpp | 3 | ||||
-rw-r--r-- | statsd/src/flags/FlagProvider.h | 19 | ||||
-rw-r--r-- | statsd/src/logd/LogEvent.cpp | 6 | ||||
-rw-r--r-- | statsd/src/metrics/MetricsManager.cpp | 7 | ||||
-rw-r--r-- | statsd/src/stats_util.h | 14 | ||||
-rw-r--r-- | statsd/src/storage/StorageManager.cpp | 4 | ||||
-rw-r--r-- | statsd/tests/LogEvent_test.cpp | 16 | ||||
-rw-r--r-- | statsd/tests/MetricsManager_test.cpp | 8 | ||||
-rw-r--r-- | statsd/tests/StatsLogProcessor_test.cpp | 6 | ||||
-rw-r--r-- | statsd/tests/StatsService_test.cpp | 1 | ||||
-rw-r--r-- | statsd/tests/e2e/RestrictedConfig_e2e_test.cpp | 9 | ||||
-rw-r--r-- | statsd/tests/e2e/RestrictedEventMetric_e2e_test.cpp | 4 | ||||
-rw-r--r-- | statsd/tests/flags/FlagProvider_test.cpp | 4 | ||||
-rw-r--r-- | statsd/tests/metrics/RestrictedEventMetricProducer_test.cpp | 9 | ||||
-rw-r--r-- | statsd/tests/storage/StorageManager_test.cpp | 7 | ||||
-rw-r--r-- | statsd/tests/utils/DbUtils_test.cpp | 6 |
18 files changed, 62 insertions, 83 deletions
diff --git a/statsd/src/StatsLogProcessor.cpp b/statsd/src/StatsLogProcessor.cpp index f076ce53..7ca2b09e 100644 --- a/statsd/src/StatsLogProcessor.cpp +++ b/statsd/src/StatsLogProcessor.cpp @@ -20,7 +20,6 @@ #include "StatsLogProcessor.h" #include <android-base/file.h> -#include <android-modules-utils/sdk_level.h> #include <cutils/multiuser.h> #include <src/active_config_list.pb.h> #include <src/experiment_ids.pb.h> @@ -40,7 +39,6 @@ using namespace android; using android::base::StringPrintf; -using android::modules::sdklevel::IsAtLeastU; using android::util::FIELD_COUNT_REPEATED; using android::util::FIELD_TYPE_BOOL; using android::util::FIELD_TYPE_FLOAT; @@ -555,7 +553,7 @@ void StatsLogProcessor::OnConfigUpdatedLocked(const int64_t timestampNs, const C VLOG("Updated configuration for key %s", key.ToString().c_str()); const auto& it = mMetricsManagers.find(key); bool configValid = false; - if (IsAtLeastU() && it != mMetricsManagers.end()) { + if (isAtLeastU() && it != mMetricsManagers.end()) { if (it->second->hasRestrictedMetricsDelegate() != config.has_restricted_metrics_delegate_package_name()) { // Not a modular update if has_restricted_metrics_delegate changes @@ -618,7 +616,7 @@ void StatsLogProcessor::OnConfigUpdatedLocked(const int64_t timestampNs, const C // Remove any existing config with the same key. ALOGE("StatsdConfig NOT valid"); // Send an empty restricted metrics broadcast if the previous config was restricted. - if (IsAtLeastU() && it != mMetricsManagers.end() && + if (isAtLeastU() && it != mMetricsManagers.end() && it->second->hasRestrictedMetricsDelegate()) { mSendRestrictedMetricsBroadcast(key, it->second->getRestrictedMetricsDelegate(), {}); StatsdStats::getInstance().noteDbConfigInvalid(key); @@ -852,7 +850,7 @@ void StatsLogProcessor::OnConfigRemoved(const ConfigKey& key) { if (it != mMetricsManagers.end()) { WriteDataToDiskLocked(key, getElapsedRealtimeNs(), getWallClockNs(), CONFIG_REMOVED, NO_TIME_CONSTRAINTS); - if (IsAtLeastU() && it->second->hasRestrictedMetricsDelegate()) { + if (isAtLeastU() && it->second->hasRestrictedMetricsDelegate()) { StatsdStats::getInstance().noteDbDeletionConfigRemoved(key); dbutils::deleteDb(key); mSendRestrictedMetricsBroadcast(key, it->second->getRestrictedMetricsDelegate(), {}); @@ -888,7 +886,7 @@ void StatsLogProcessor::OnConfigRemoved(const ConfigKey& key) { // TODO(b/267501143): Add unit tests when metric producer is ready void StatsLogProcessor::enforceDataTtlsIfNecessaryLocked(const int64_t wallClockNs, const int64_t elapsedRealtimeNs) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { return; } if (elapsedRealtimeNs - mLastTtlTime < StatsdStats::kMinTtlCheckPeriodNs) { @@ -898,7 +896,7 @@ void StatsLogProcessor::enforceDataTtlsIfNecessaryLocked(const int64_t wallClock } void StatsLogProcessor::flushRestrictedDataIfNecessaryLocked(const int64_t elapsedRealtimeNs) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { return; } if (elapsedRealtimeNs - mLastFlushRestrictedTime < StatsdStats::kMinFlushRestrictedPeriodNs) { @@ -915,7 +913,7 @@ void StatsLogProcessor::querySql(const string& sqlQuery, const int32_t minSqlCli std::lock_guard<std::mutex> lock(mMetricsMutex); string err = ""; - if (!IsAtLeastU()) { + if (!isAtLeastU()) { ALOGW("Restricted metrics query invoked on U- device"); StatsdStats::getInstance().noteQueryRestrictedMetricFailed( configId, configPackage, std::nullopt, callingUid, @@ -1041,7 +1039,7 @@ set<ConfigKey> StatsLogProcessor::getRestrictedConfigKeysToQueryLocked( void StatsLogProcessor::EnforceDataTtls(const int64_t wallClockNs, const int64_t elapsedRealtimeNs) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { return; } std::lock_guard<std::mutex> lock(mMetricsMutex); diff --git a/statsd/src/StatsService.cpp b/statsd/src/StatsService.cpp index ebbc634d..6b8154d8 100644 --- a/statsd/src/StatsService.cpp +++ b/statsd/src/StatsService.cpp @@ -21,7 +21,6 @@ #include <android-base/file.h> #include <android-base/strings.h> -#include <android-modules-utils/sdk_level.h> #include <android/binder_ibinder_platform.h> #include <cutils/multiuser.h> #include <private/android_filesystem_config.h> @@ -48,7 +47,6 @@ using namespace android; using android::base::StringPrintf; -using android::modules::sdklevel::IsAtLeastU; using android::util::FIELD_COUNT_REPEATED; using android::util::FIELD_TYPE_MESSAGE; @@ -1433,7 +1431,7 @@ Status StatsService::setRestrictedMetricsChangedOperation(const int64_t configId const int32_t callingUid, vector<int64_t>* output) { ENFORCE_UID(AID_SYSTEM); - if (!IsAtLeastU()) { + if (!isAtLeastU()) { ALOGW("setRestrictedMetricsChangedOperation invoked on U- device"); return Status::ok(); } @@ -1450,7 +1448,7 @@ Status StatsService::removeRestrictedMetricsChangedOperation(const int64_t confi const string& configPackage, const int32_t callingUid) { ENFORCE_UID(AID_SYSTEM); - if (!IsAtLeastU()) { + if (!isAtLeastU()) { ALOGW("removeRestrictedMetricsChangedOperation invoked on U- device"); return Status::ok(); } diff --git a/statsd/src/flags/FlagProvider.cpp b/statsd/src/flags/FlagProvider.cpp index 7edcf628..795ac3af 100644 --- a/statsd/src/flags/FlagProvider.cpp +++ b/statsd/src/flags/FlagProvider.cpp @@ -16,7 +16,6 @@ #include "FlagProvider.h" -using android::modules::sdklevel::IsAtLeastS; using server_configurable_flags::GetServerConfigurableFlag; using std::string; using std::vector; @@ -26,7 +25,7 @@ namespace os { namespace statsd { FlagProvider::FlagProvider() - : mIsAtLeastSFunc(IsAtLeastS), mGetServerFlagFunc(GetServerConfigurableFlag) { + : mIsAtLeastSFunc(isAtLeastS), mGetServerFlagFunc(GetServerConfigurableFlag) { } FlagProvider& FlagProvider::getInstance() { diff --git a/statsd/src/flags/FlagProvider.h b/statsd/src/flags/FlagProvider.h index 902966be..6fb6c444 100644 --- a/statsd/src/flags/FlagProvider.h +++ b/statsd/src/flags/FlagProvider.h @@ -16,7 +16,6 @@ #pragma once -#include <android-modules-utils/sdk_level.h> #include <gtest/gtest_prod.h> #include <server_configurable_flags/get_flags.h> @@ -26,6 +25,8 @@ #include <unordered_map> #include <vector> +#include "stats_util.h" + namespace android { namespace os { namespace statsd { @@ -66,15 +67,13 @@ private: FlagProvider(); // TODO(b/194347008): Remove the GetServerConfigurableFlag override. - void overrideFuncs( - const IsAtLeastSFunc& isAtLeastSFunc = &android::modules::sdklevel::IsAtLeastS, - const GetServerFlagFunc& getServerFlagFunc = - &server_configurable_flags::GetServerConfigurableFlag); - - void overrideFuncsLocked( - const IsAtLeastSFunc& isAtLeastSFunc = &android::modules::sdklevel::IsAtLeastS, - const GetServerFlagFunc& getServerFlagFunc = - &server_configurable_flags::GetServerConfigurableFlag); + void overrideFuncs(const IsAtLeastSFunc& isAtLeastSFunc = &isAtLeastS, + const GetServerFlagFunc& getServerFlagFunc = + &server_configurable_flags::GetServerConfigurableFlag); + + void overrideFuncsLocked(const IsAtLeastSFunc& isAtLeastSFunc = &isAtLeastS, + const GetServerFlagFunc& getServerFlagFunc = + &server_configurable_flags::GetServerConfigurableFlag); inline void resetOverrides() { std::lock_guard<std::mutex> lock(mFlagsMutex); diff --git a/statsd/src/logd/LogEvent.cpp b/statsd/src/logd/LogEvent.cpp index 4cb76afb..d3251860 100644 --- a/statsd/src/logd/LogEvent.cpp +++ b/statsd/src/logd/LogEvent.cpp @@ -20,7 +20,6 @@ #include "logd/LogEvent.h" #include <android-base/stringprintf.h> -#include <android-modules-utils/sdk_level.h> #include <android/binder_ibinder.h> #include <private/android_filesystem_config.h> @@ -38,7 +37,6 @@ const int FIELD_ID_EXPERIMENT_ID = 1; using namespace android::util; using android::base::StringPrintf; -using android::modules::sdklevel::IsAtLeastU; using android::util::ProtoOutputStream; using std::string; using std::vector; @@ -452,7 +450,7 @@ void LogEvent::parseAnnotations(uint8_t numAnnotations, std::optional<uint8_t> n parseStateNestedAnnotation(annotationType, numElements); break; case ASTATSLOG_ANNOTATION_ID_RESTRICTION_CATEGORY: - if (IsAtLeastU()) { + if (isAtLeastU()) { parseRestrictionCategoryAnnotation(annotationType); } else { mValid = false; @@ -468,7 +466,7 @@ void LogEvent::parseAnnotations(uint8_t numAnnotations, std::optional<uint8_t> n case ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_USER_ENGAGEMENT: case ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_AMBIENT_SENSING: case ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_DEMOGRAPHIC_CLASSIFICATION: - if (IsAtLeastU()) { + if (isAtLeastU()) { parseFieldRestrictionAnnotation(annotationType); } else { mValid = false; diff --git a/statsd/src/metrics/MetricsManager.cpp b/statsd/src/metrics/MetricsManager.cpp index 528257ae..c8ee3eed 100644 --- a/statsd/src/metrics/MetricsManager.cpp +++ b/statsd/src/metrics/MetricsManager.cpp @@ -18,7 +18,6 @@ #include "MetricsManager.h" -#include <android-modules-utils/sdk_level.h> #include <private/android_filesystem_config.h> #include "CountMetricProducer.h" @@ -36,8 +35,6 @@ #include "statslog_statsd.h" #include "utils/DbUtils.h" -using android::modules::sdklevel::IsAtLeastU; - using android::util::FIELD_COUNT_REPEATED; using android::util::FIELD_TYPE_INT32; using android::util::FIELD_TYPE_INT64; @@ -81,7 +78,7 @@ MetricsManager::MetricsManager(const ConfigKey& key, const StatsdConfig& config, mWhitelistedAtomIds(config.whitelisted_atom_ids().begin(), config.whitelisted_atom_ids().end()), mShouldPersistHistory(config.persist_locally()) { - if (!IsAtLeastU() && config.has_restricted_metrics_delegate_package_name()) { + if (!isAtLeastU() && config.has_restricted_metrics_delegate_package_name()) { mInvalidConfigReason = InvalidConfigReason(INVALID_CONFIG_REASON_RESTRICTED_METRIC_NOT_ENABLED); return; @@ -131,7 +128,7 @@ bool MetricsManager::updateConfig(const StatsdConfig& config, const int64_t time const int64_t currentTimeNs, const sp<AlarmMonitor>& anomalyAlarmMonitor, const sp<AlarmMonitor>& periodicAlarmMonitor) { - if (!IsAtLeastU() && config.has_restricted_metrics_delegate_package_name()) { + if (!isAtLeastU() && config.has_restricted_metrics_delegate_package_name()) { mInvalidConfigReason = InvalidConfigReason(INVALID_CONFIG_REASON_RESTRICTED_METRIC_NOT_ENABLED); return false; diff --git a/statsd/src/stats_util.h b/statsd/src/stats_util.h index bb919d45..fde18254 100644 --- a/statsd/src/stats_util.h +++ b/statsd/src/stats_util.h @@ -16,10 +16,12 @@ #pragma once -#include "HashableDimensionKey.h" +#include <android-modules-utils/sdk_level.h> #include <unordered_map> +#include "HashableDimensionKey.h" + namespace android { namespace os { namespace statsd { @@ -47,6 +49,16 @@ using StateLinks = google::protobuf::RepeatedPtrField<MetricStateLink>; struct Empty {}; +inline bool isAtLeastS() { + const static bool isAtLeastS = android::modules::sdklevel::IsAtLeastS(); + return isAtLeastS; +} + +inline bool isAtLeastU() { + const static bool isAtLeastU = android::modules::sdklevel::IsAtLeastU(); + return isAtLeastU; +} + } // namespace statsd } // namespace os } // namespace android diff --git a/statsd/src/storage/StorageManager.cpp b/statsd/src/storage/StorageManager.cpp index 02c2128a..7ca88fe1 100644 --- a/statsd/src/storage/StorageManager.cpp +++ b/statsd/src/storage/StorageManager.cpp @@ -20,7 +20,6 @@ #include "storage/StorageManager.h" #include <android-base/file.h> -#include <android-modules-utils/sdk_level.h> #include <private/android_filesystem_config.h> #include <sys/stat.h> @@ -35,7 +34,6 @@ namespace android { namespace os { namespace statsd { -using android::modules::sdklevel::IsAtLeastU; using android::util::FIELD_COUNT_REPEATED; using android::util::FIELD_TYPE_MESSAGE; using std::map; @@ -825,7 +823,7 @@ void StorageManager::printDirStats(int outFd, const char* path) { void StorageManager::enforceDbGuardrails(const char* path, const int64_t currWallClockSec, const int64_t maxBytes) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { return; } unique_ptr<DIR, decltype(&closedir)> dir(opendir(path), closedir); diff --git a/statsd/tests/LogEvent_test.cpp b/statsd/tests/LogEvent_test.cpp index 1a9b920b..674b5463 100644 --- a/statsd/tests/LogEvent_test.cpp +++ b/statsd/tests/LogEvent_test.cpp @@ -14,7 +14,6 @@ #include "src/logd/LogEvent.h" -#include <android-modules-utils/sdk_level.h> #include <gtest/gtest.h> #include "flags/FlagProvider.h" @@ -31,7 +30,6 @@ namespace android { namespace os { namespace statsd { -using android::modules::sdklevel::IsAtLeastU; using std::string; using std::vector; using ::util::ProtoOutputStream; @@ -998,7 +996,7 @@ TEST_P(LogEventTest, TestResetStateAnnotation) { } TEST_P(LogEventTest, TestRestrictionCategoryAnnotation) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } int32_t restrictionCategory = ASTATSLOG_RESTRICTION_CATEGORY_DIAGNOSTIC; @@ -1011,7 +1009,7 @@ TEST_P(LogEventTest, TestRestrictionCategoryAnnotation) { } TEST_P(LogEventTest, TestInvalidRestrictionCategoryAnnotation) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } int32_t restrictionCategory = 619; // unknown category @@ -1022,7 +1020,7 @@ TEST_P(LogEventTest, TestInvalidRestrictionCategoryAnnotation) { } TEST_P(LogEventTest, TestRestrictionCategoryAnnotationBelowUDevice) { - if (IsAtLeastU()) { + if (isAtLeastU()) { GTEST_SKIP(); } int32_t restrictionCategory = ASTATSLOG_RESTRICTION_CATEGORY_DIAGNOSTIC; @@ -1150,7 +1148,7 @@ INSTANTIATE_TEST_SUITE_P( LogEvent_FieldRestrictionTest::ToString); TEST_P(LogEvent_FieldRestrictionTest, TestFieldRestrictionAnnotation) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } LogEvent event(/*uid=*/0, /*pid=*/0); @@ -1164,7 +1162,7 @@ TEST_P(LogEvent_FieldRestrictionTest, TestFieldRestrictionAnnotation) { } TEST_P(LogEvent_FieldRestrictionTest, TestInvalidAnnotationIntType) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } LogEvent event(/*uid=*/0, /*pid=*/0); @@ -1174,7 +1172,7 @@ TEST_P(LogEvent_FieldRestrictionTest, TestInvalidAnnotationIntType) { } TEST_P(LogEvent_FieldRestrictionTest, TestInvalidAnnotationAtomLevel) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } LogEvent event(/*uid=*/0, /*pid=*/0); @@ -1184,7 +1182,7 @@ TEST_P(LogEvent_FieldRestrictionTest, TestInvalidAnnotationAtomLevel) { } TEST_P(LogEvent_FieldRestrictionTest, TestRestrictionCategoryAnnotationBelowUDevice) { - if (IsAtLeastU()) { + if (isAtLeastU()) { GTEST_SKIP(); } int32_t restrictionCategory = ASTATSLOG_RESTRICTION_CATEGORY_DIAGNOSTIC; diff --git a/statsd/tests/MetricsManager_test.cpp b/statsd/tests/MetricsManager_test.cpp index e30f7bf0..6d090d14 100644 --- a/statsd/tests/MetricsManager_test.cpp +++ b/statsd/tests/MetricsManager_test.cpp @@ -35,8 +35,6 @@ using namespace testing; using android::sp; -using android::modules::sdklevel::IsAtLeastS; -using android::modules::sdklevel::IsAtLeastU; using android::os::statsd::Predicate; using std::map; using std::set; @@ -298,7 +296,7 @@ protected: } bool shouldSkipTest() const { - return !IsAtLeastS(); + return !isAtLeastS(); } string skipReason() const { @@ -384,7 +382,7 @@ TEST_P(MetricsManagerTest_SPlus, TestRestrictedMetricsConfig) { MetricsManager metricsManager(kConfigKey, config, timeBaseSec, timeBaseSec, uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor); - if (IsAtLeastU()) { + if (isAtLeastU()) { EXPECT_TRUE(metricsManager.isConfigValid()); } else { EXPECT_EQ(metricsManager.mInvalidConfigReason, @@ -410,7 +408,7 @@ TEST_P(MetricsManagerTest_SPlus, TestRestrictedMetricsConfigUpdate) { metricsManager.updateConfig(config, timeBaseSec, timeBaseSec, anomalyAlarmMonitor, periodicAlarmMonitor); - if (IsAtLeastU()) { + if (isAtLeastU()) { EXPECT_TRUE(metricsManager.isConfigValid()); } else { EXPECT_EQ(metricsManager.mInvalidConfigReason, diff --git a/statsd/tests/StatsLogProcessor_test.cpp b/statsd/tests/StatsLogProcessor_test.cpp index 3fbe48b9..02ed8440 100644 --- a/statsd/tests/StatsLogProcessor_test.cpp +++ b/statsd/tests/StatsLogProcessor_test.cpp @@ -15,7 +15,6 @@ #include "StatsLogProcessor.h" #include <android-base/stringprintf.h> -#include <android-modules-utils/sdk_level.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <stdio.h> @@ -43,7 +42,6 @@ namespace os { namespace statsd { using android::base::StringPrintf; -using android::modules::sdklevel::IsAtLeastU; using android::util::ProtoOutputStream; using ::testing::Expectation; @@ -2176,12 +2174,12 @@ class StatsLogProcessorTestRestricted : public Test { protected: const ConfigKey mConfigKey = ConfigKey(1, 12345); void SetUp() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } } void TearDown() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } FlagProvider::getInstance().resetOverrides(); diff --git a/statsd/tests/StatsService_test.cpp b/statsd/tests/StatsService_test.cpp index 4683dede..5bc2f747 100644 --- a/statsd/tests/StatsService_test.cpp +++ b/statsd/tests/StatsService_test.cpp @@ -31,7 +31,6 @@ namespace android { namespace os { namespace statsd { -using android::modules::sdklevel::IsAtLeastU; using android::util::ProtoOutputStream; using ::ndk::SharedRefBase; diff --git a/statsd/tests/e2e/RestrictedConfig_e2e_test.cpp b/statsd/tests/e2e/RestrictedConfig_e2e_test.cpp index 2f47a892..3d4c3f6c 100644 --- a/statsd/tests/e2e/RestrictedConfig_e2e_test.cpp +++ b/statsd/tests/e2e/RestrictedConfig_e2e_test.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include <android-modules-utils/sdk_level.h> #include <gtest/gtest.h> #include "flags/FlagProvider.h" @@ -23,8 +22,6 @@ namespace android { namespace os { namespace statsd { -using android::modules::sdklevel::IsAtLeastU; - #ifdef __ANDROID__ namespace { @@ -83,7 +80,7 @@ protected: string error; void SetUp() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } StatsServiceConfigTest::SetUp(); @@ -119,7 +116,7 @@ protected: service->mUidMap->updateMap(startTimeNs, uidData); } void TearDown() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } Mock::VerifyAndClear(mockStatsQueryCallback.get()); @@ -475,4 +472,4 @@ GTEST_LOG_(INFO) << "This test does nothing.\n"; } // namespace statsd } // namespace os -} // namespace android
\ No newline at end of file +} // namespace android diff --git a/statsd/tests/e2e/RestrictedEventMetric_e2e_test.cpp b/statsd/tests/e2e/RestrictedEventMetric_e2e_test.cpp index 6aed3740..3ea02b26 100644 --- a/statsd/tests/e2e/RestrictedEventMetric_e2e_test.cpp +++ b/statsd/tests/e2e/RestrictedEventMetric_e2e_test.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include <android-modules-utils/sdk_level.h> #include <gtest/gtest.h> #include <vector> @@ -31,7 +30,6 @@ namespace android { namespace os { namespace statsd { -using android::modules::sdklevel::IsAtLeastU; using base::StringPrintf; #ifdef __ANDROID__ @@ -66,7 +64,7 @@ protected: private: void SetUp() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } diff --git a/statsd/tests/flags/FlagProvider_test.cpp b/statsd/tests/flags/FlagProvider_test.cpp index 55463b52..bd790a32 100644 --- a/statsd/tests/flags/FlagProvider_test.cpp +++ b/statsd/tests/flags/FlagProvider_test.cpp @@ -14,7 +14,6 @@ #include "src/flags/FlagProvider.h" -#include <android-modules-utils/sdk_level.h> #include <gtest/gtest.h> #include "tests/statsd_test_util.h" @@ -25,7 +24,6 @@ namespace statsd { #ifdef __ANDROID__ -using android::modules::sdklevel::IsAtLeastS; using namespace std; const string TEST_FLAG = "MyFlagTest"; @@ -77,7 +75,7 @@ TEST_P(FlagProviderTest_SPlus, TestOverrideLocalFlags) { class FlagProviderTest_SPlus_RealValues : public testing::TestWithParam<FlagParam> { void SetUp() override { - if (!IsAtLeastS()) { + if (!isAtLeastS()) { GTEST_SKIP() << "Cannot query flags from system property on R-."; } } diff --git a/statsd/tests/metrics/RestrictedEventMetricProducer_test.cpp b/statsd/tests/metrics/RestrictedEventMetricProducer_test.cpp index b6c45451..44b812f1 100644 --- a/statsd/tests/metrics/RestrictedEventMetricProducer_test.cpp +++ b/statsd/tests/metrics/RestrictedEventMetricProducer_test.cpp @@ -1,6 +1,5 @@ #include "src/metrics/RestrictedEventMetricProducer.h" -#include <android-modules-utils/sdk_level.h> #include <gtest/gtest.h> #include "flags/FlagProvider.h" @@ -20,8 +19,6 @@ namespace android { namespace os { namespace statsd { -using android::modules::sdklevel::IsAtLeastU; - namespace { const ConfigKey configKey(/*uid=*/0, /*id=*/12345); const int64_t metricId1 = 123; @@ -41,12 +38,12 @@ bool metricTableExist(int64_t metricId) { class RestrictedEventMetricProducerTest : public Test { protected: void SetUp() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } } void TearDown() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } dbutils::deleteDb(configKey); @@ -263,4 +260,4 @@ TEST_F(RestrictedEventMetricProducerTest, TestLoadMetricMetadataSetsCategory) { #else GTEST_LOG_(INFO) << "This test does nothing.\n"; -#endif
\ No newline at end of file +#endif diff --git a/statsd/tests/storage/StorageManager_test.cpp b/statsd/tests/storage/StorageManager_test.cpp index db80e778..27b8e987 100644 --- a/statsd/tests/storage/StorageManager_test.cpp +++ b/statsd/tests/storage/StorageManager_test.cpp @@ -15,7 +15,6 @@ #include "src/storage/StorageManager.h" #include <android-base/unique_fd.h> -#include <android-modules-utils/sdk_level.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <stdio.h> @@ -32,7 +31,7 @@ namespace os { namespace statsd { using namespace testing; -using android::modules::sdklevel::IsAtLeastU; + using std::make_shared; using std::shared_ptr; using std::vector; @@ -283,7 +282,7 @@ TEST(StorageManagerTest, TrainInfoReadWrite32To64BitTest) { } TEST(StorageManagerTest, DeleteUnmodifiedOldDbFiles) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } ConfigKey key(123, 12345); @@ -301,7 +300,7 @@ TEST(StorageManagerTest, DeleteUnmodifiedOldDbFiles) { } TEST(StorageManagerTest, DeleteLargeDbFiles) { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } ConfigKey key(123, 12345); diff --git a/statsd/tests/utils/DbUtils_test.cpp b/statsd/tests/utils/DbUtils_test.cpp index 8a9b3377..9bc1d61a 100644 --- a/statsd/tests/utils/DbUtils_test.cpp +++ b/statsd/tests/utils/DbUtils_test.cpp @@ -16,7 +16,6 @@ #include "utils/DbUtils.h" -#include <android-modules-utils/sdk_level.h> #include <gtest/gtest.h> #include "android-base/stringprintf.h" @@ -32,7 +31,6 @@ namespace os { namespace statsd { namespace dbutils { -using android::modules::sdklevel::IsAtLeastU; using base::StringPrintf; namespace { @@ -56,12 +54,12 @@ LogEvent makeLogEvent(AStatsEvent* statsEvent) { class DbUtilsTest : public ::testing::Test { public: void SetUp() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } } void TearDown() override { - if (!IsAtLeastU()) { + if (!isAtLeastU()) { GTEST_SKIP(); } deleteDb(key); |