diff options
Diffstat (limited to 'cmds')
11 files changed, 85 insertions, 21 deletions
diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp index ab4e764d92a4..5065a56078d0 100644 --- a/cmds/incidentd/src/Section.cpp +++ b/cmds/incidentd/src/Section.cpp @@ -731,25 +731,25 @@ status_t LogSection::BlockingCall(int pipeWriteFd) const { android_logger_list_free); if (android_logger_open(loggers.get(), mLogID) == NULL) { - ALOGW("LogSection %s: Can't get logger.", this->name.string()); - return NO_ERROR; + ALOGE("LogSection %s: Can't get logger.", this->name.string()); + return -1; } log_msg msg; log_time lastTimestamp(0); - status_t err = NO_ERROR; ProtoOutputStream proto; while (true) { // keeps reading until logd buffer is fully read. - err = android_logger_list_read(loggers.get(), &msg); + status_t err = android_logger_list_read(loggers.get(), &msg); // err = 0 - no content, unexpected connection drop or EOF. // err = +ive number - size of retrieved data from logger // err = -ive number, OS supplied error _except_ for -EAGAIN // err = -EAGAIN, graceful indication for ANDRODI_LOG_NONBLOCK that this is the end of data. if (err <= 0) { if (err != -EAGAIN) { - ALOGE("LogSection %s: fails to read a log_msg.\n", this->name.string()); + ALOGW("LogSection %s: fails to read a log_msg.\n", this->name.string()); } + // dump previous logs and don't consider this error a failure. break; } if (mBinary) { @@ -818,7 +818,7 @@ status_t LogSection::BlockingCall(int pipeWriteFd) const { AndroidLogEntry entry; err = android_log_processLogBuffer(&msg.entry_v1, &entry); if (err != NO_ERROR) { - ALOGE("LogSection %s: fails to process to an entry.\n", this->name.string()); + ALOGW("LogSection %s: fails to process to an entry.\n", this->name.string()); break; } lastTimestamp.tv_sec = entry.tv_sec; @@ -840,7 +840,7 @@ status_t LogSection::BlockingCall(int pipeWriteFd) const { } gLastLogsRetrieved[mLogID] = lastTimestamp; proto.flush(pipeWriteFd); - return err; + return NO_ERROR; } // ================================================================================ diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 31ca13a1585c..f74188f5e69f 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -115,6 +115,8 @@ message Atom { HardwareFailed hardware_failed = 72; PhysicalDropDetected physical_drop_detected = 73; ChargeCyclesReported charge_cycles_reported = 74; + MobileConnectionStateChanged mobile_connection_state_changed = 75; + MobileRadioTechnologyChanged mobile_radio_technology_changed = 76; } // Pulled events will start at field 10000. @@ -911,6 +913,56 @@ message ResourceConfigurationChanged { optional int32 uiMode = 17; } + +/** + * Logs changes in the connection state of the mobile radio. + * + * Logged from: + * frameworks/opt/telephony/src/java/com/android/internal/telephony/dataconnection/DataConnection.java + */ +message MobileConnectionStateChanged { + // States are from the state machine DataConnection.java. + enum State { + UNKNOWN = 0; + // The connection is inactive, or disconnected. + INACTIVE = 1; + // The connection is being activated, or connecting. + ACTIVATING = 2; + // The connection is active, or connected. + ACTIVE = 3; + // The connection is disconnecting. + DISCONNECTING = 4; + // The connection is disconnecting after creating a connection. + DISCONNECTION_ERROR_CREATING_CONNECTION = 5; + } + optional State state = 1; + // For multi-sim phones, this distinguishes between the sim cards. + optional int32 sim_slot_index = 2; + // Used to identify the connection. Starts at 0 and increments by 1 for + // every new network created. Resets whenever the device reboots. + optional int32 data_connection_id = 3; + // A bitmask for the capabilities of this connection. + // Eg. DEFAULT (internet), MMS, SUPL, DUN, IMS. + // Default value (if we have no information): 0 + optional int64 capabilities = 4; + // If this connection has internet. + // This just checks if the DEFAULT bit of capabilities is set. + optional bool has_internet = 5; +} + +/** + * Logs changes in mobile radio technology. eg: LTE, EDGE, CDMA. + * + * Logged from: + * frameworks/opt/telephony/src/java/com/android/internal/telephony/ServiceStateTracker.java + */ +message MobileRadioTechnologyChanged { + optional android.telephony.NetworkTypeEnum state = 1; + // For multi-sim phones, this distinguishes between the sim cards. + optional int32 sim_slot_index = 2; +} + + /** * Logs when Bluetooth is enabled and disabled. * diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp index 6209bbe75812..c773d4f1387e 100644 --- a/cmds/statsd/src/metrics/MetricsManager.cpp +++ b/cmds/statsd/src/metrics/MetricsManager.cpp @@ -64,15 +64,9 @@ MetricsManager::MetricsManager(const ConfigKey& key, const StatsdConfig& config, mTrackerToConditionMap, mNoReportMetricIds); if (config.allowed_log_source_size() == 0) { - // TODO(b/70794411): uncomment the following line and remove the hard coded log source - // after all configs have the log source added. - // mConfigValid = false; - // ALOGE("Log source white list is empty! This config won't get any data."); - - mAllowedUid.push_back(AID_ROOT); - mAllowedUid.push_back(AID_STATSD); - mAllowedUid.push_back(AID_SYSTEM); - mAllowedLogSources.insert(mAllowedUid.begin(), mAllowedUid.end()); + mConfigValid = false; + ALOGE("Log source whitelist is empty! This config won't get any data. Suggest adding at " + "least AID_SYSTEM and AID_STATSD to the allowed_log_source field."); } else { for (const auto& source : config.allowed_log_source()) { auto it = UidMap::sAidToUidMapping.find(source); diff --git a/cmds/statsd/src/packages/UidMap.cpp b/cmds/statsd/src/packages/UidMap.cpp index efbe96eebb25..e97d8b2af1ae 100644 --- a/cmds/statsd/src/packages/UidMap.cpp +++ b/cmds/statsd/src/packages/UidMap.cpp @@ -377,17 +377,20 @@ void UidMap::getOutput(const int64_t& timestamp, const ConfigKey& key, vector<ui if (newMin > prevMin) { // Delete anything possible now that the minimum has // moved forward. int64_t cutoff_nanos = newMin; - for (auto it_snapshots = mSnapshots.begin(); it_snapshots != mSnapshots.end(); - ++it_snapshots) { + for (auto it_snapshots = mSnapshots.begin(); it_snapshots != mSnapshots.end();) { if (it_snapshots->timestampNs < cutoff_nanos) { mBytesUsed -= it_snapshots->bytes.size() + kBytesTimestampField; - mSnapshots.erase(it_snapshots); + it_snapshots = mSnapshots.erase(it_snapshots); + } else { + ++it_snapshots; } } - for (auto it_changes = mChanges.begin(); it_changes != mChanges.end(); ++it_changes) { + for (auto it_changes = mChanges.begin(); it_changes != mChanges.end();) { if (it_changes->timestampNs < cutoff_nanos) { mBytesUsed -= kBytesChangeRecord; - mChanges.erase(it_changes); + it_changes = mChanges.erase(it_changes); + } else { + ++it_changes; } } diff --git a/cmds/statsd/tests/e2e/Attribution_e2e_test.cpp b/cmds/statsd/tests/e2e/Attribution_e2e_test.cpp index 2574ba79f9d3..a04a6f914633 100644 --- a/cmds/statsd/tests/e2e/Attribution_e2e_test.cpp +++ b/cmds/statsd/tests/e2e/Attribution_e2e_test.cpp @@ -30,6 +30,7 @@ namespace { StatsdConfig CreateStatsdConfig(const Position position) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. auto wakelockAcquireMatcher = CreateAcquireWakelockAtomMatcher(); auto attributionNodeMatcher = wakelockAcquireMatcher.mutable_simple_atom_matcher()->add_field_value_matcher(); diff --git a/cmds/statsd/tests/e2e/DimensionInCondition_e2e_combination_AND_cond_test.cpp b/cmds/statsd/tests/e2e/DimensionInCondition_e2e_combination_AND_cond_test.cpp index a08f6067c96c..63e23ce3a941 100644 --- a/cmds/statsd/tests/e2e/DimensionInCondition_e2e_combination_AND_cond_test.cpp +++ b/cmds/statsd/tests/e2e/DimensionInCondition_e2e_combination_AND_cond_test.cpp @@ -31,6 +31,7 @@ namespace { StatsdConfig CreateDurationMetricConfig_NoLink_AND_CombinationCondition( DurationMetric::AggregationType aggregationType, bool addExtraDimensionInCondition) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateStartScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateFinishScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateSyncStartAtomMatcher(); @@ -337,6 +338,7 @@ namespace { StatsdConfig CreateDurationMetricConfig_Link_AND_CombinationCondition( DurationMetric::AggregationType aggregationType, bool addExtraDimensionInCondition) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateStartScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateFinishScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateSyncStartAtomMatcher(); @@ -580,6 +582,7 @@ namespace { StatsdConfig CreateDurationMetricConfig_PartialLink_AND_CombinationCondition( DurationMetric::AggregationType aggregationType) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateStartScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateFinishScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateSyncStartAtomMatcher(); diff --git a/cmds/statsd/tests/e2e/DimensionInCondition_e2e_combination_OR_cond_test.cpp b/cmds/statsd/tests/e2e/DimensionInCondition_e2e_combination_OR_cond_test.cpp index 435e1991b9e3..2287c2bfc890 100644 --- a/cmds/statsd/tests/e2e/DimensionInCondition_e2e_combination_OR_cond_test.cpp +++ b/cmds/statsd/tests/e2e/DimensionInCondition_e2e_combination_OR_cond_test.cpp @@ -30,6 +30,7 @@ namespace { StatsdConfig CreateCountMetric_NoLink_CombinationCondition_Config() { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. auto screenBrightnessChangeAtomMatcher = CreateScreenBrightnessChangedAtomMatcher(); *config.add_atom_matcher() = screenBrightnessChangeAtomMatcher; *config.add_atom_matcher() = CreateScreenTurnedOnAtomMatcher(); @@ -229,6 +230,7 @@ namespace { StatsdConfig CreateCountMetric_Link_CombinationCondition() { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. auto appCrashMatcher = CreateProcessCrashAtomMatcher(); *config.add_atom_matcher() = appCrashMatcher; *config.add_atom_matcher() = CreateScreenTurnedOnAtomMatcher(); @@ -416,6 +418,7 @@ namespace { StatsdConfig CreateDurationMetricConfig_NoLink_CombinationCondition( DurationMetric::AggregationType aggregationType) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateBatterySaverModeStartAtomMatcher(); *config.add_atom_matcher() = CreateBatterySaverModeStopAtomMatcher(); *config.add_atom_matcher() = CreateScreenTurnedOnAtomMatcher(); @@ -603,6 +606,7 @@ namespace { StatsdConfig CreateDurationMetricConfig_Link_CombinationCondition( DurationMetric::AggregationType aggregationType) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateMoveToBackgroundAtomMatcher(); *config.add_atom_matcher() = CreateMoveToForegroundAtomMatcher(); *config.add_atom_matcher() = CreateScreenTurnedOnAtomMatcher(); diff --git a/cmds/statsd/tests/e2e/DimensionInCondition_e2e_simple_cond_test.cpp b/cmds/statsd/tests/e2e/DimensionInCondition_e2e_simple_cond_test.cpp index 75ceafb489b3..ab37140577af 100644 --- a/cmds/statsd/tests/e2e/DimensionInCondition_e2e_simple_cond_test.cpp +++ b/cmds/statsd/tests/e2e/DimensionInCondition_e2e_simple_cond_test.cpp @@ -31,6 +31,7 @@ namespace { StatsdConfig CreateDurationMetricConfig_NoLink_SimpleCondition( DurationMetric::AggregationType aggregationType, bool addExtraDimensionInCondition) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateStartScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateFinishScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateSyncStartAtomMatcher(); @@ -306,6 +307,7 @@ namespace { StatsdConfig createDurationMetric_Link_SimpleConditionConfig( DurationMetric::AggregationType aggregationType, bool addExtraDimensionInCondition) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateStartScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateFinishScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateSyncStartAtomMatcher(); @@ -525,6 +527,7 @@ namespace { StatsdConfig createDurationMetric_PartialLink_SimpleConditionConfig( DurationMetric::AggregationType aggregationType) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateStartScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateFinishScheduledJobAtomMatcher(); *config.add_atom_matcher() = CreateSyncStartAtomMatcher(); diff --git a/cmds/statsd/tests/e2e/GaugeMetric_e2e_push_test.cpp b/cmds/statsd/tests/e2e/GaugeMetric_e2e_push_test.cpp index 9ceffc816e68..2e6a0f05a341 100644 --- a/cmds/statsd/tests/e2e/GaugeMetric_e2e_push_test.cpp +++ b/cmds/statsd/tests/e2e/GaugeMetric_e2e_push_test.cpp @@ -30,6 +30,7 @@ namespace { StatsdConfig CreateStatsdConfigForPushedEvent(const GaugeMetric::SamplingType sampling_type) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateMoveToBackgroundAtomMatcher(); *config.add_atom_matcher() = CreateMoveToForegroundAtomMatcher(); diff --git a/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp b/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp index c874d92a1b01..1440f2941c05 100644 --- a/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp +++ b/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp @@ -29,6 +29,8 @@ namespace { StatsdConfig CreateStatsdConfig() { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. + *config.add_atom_matcher() = CreateScreenTurnedOnAtomMatcher(); *config.add_atom_matcher() = CreateScreenTurnedOffAtomMatcher(); diff --git a/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp b/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp index 9153795365a2..bfae8bca697f 100644 --- a/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp +++ b/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp @@ -30,6 +30,7 @@ namespace { StatsdConfig CreateStatsdConfig(DurationMetric::AggregationType aggregationType) { StatsdConfig config; + config.add_allowed_log_source("AID_ROOT"); // LogEvent defaults to UID of root. *config.add_atom_matcher() = CreateScreenTurnedOnAtomMatcher(); *config.add_atom_matcher() = CreateScreenTurnedOffAtomMatcher(); *config.add_atom_matcher() = CreateAcquireWakelockAtomMatcher(); |