Loading system/audio_a2dp_hw/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ cc_library { "com.android.btservices", ], shared_libs: [ "libbase", "libcutils", "liblog", ], Loading system/gd/os/android/metrics.cc +108 −93 Original line number Diff line number Diff line Loading @@ -20,17 +20,35 @@ #include "os/metrics.h" #include <bluetooth/log.h> #include <statslog_bt.h> #include "common/audit_log.h" #include "metrics/metrics_state.h" #include "common/metric_id_manager.h" #include "common/strings.h" #include "hci/hci_packets.h" #include "metrics/metrics_state.h" #include "os/log.h" namespace bluetooth { namespace fmt { template <> struct formatter<android::bluetooth::DirectionEnum> : enum_formatter<android::bluetooth::DirectionEnum> {}; template <> struct formatter<android::bluetooth::SocketConnectionstateEnum> : enum_formatter<android::bluetooth::SocketConnectionstateEnum> {}; template <> struct formatter<android::bluetooth::SocketRoleEnum> : enum_formatter<android::bluetooth::SocketRoleEnum> {}; template <> struct formatter<android::bluetooth::DeviceInfoSrcEnum> : enum_formatter<android::bluetooth::DeviceInfoSrcEnum> {}; template <> struct formatter<android::bluetooth::AddressTypeEnum> : enum_formatter<android::bluetooth::AddressTypeEnum> {}; } // namespace fmt namespace bluetooth { namespace os { using bluetooth::common::MetricIdManager; Loading Loading @@ -70,17 +88,17 @@ void LogMetricLinkLayerConnectionEvent( reason_code, metric_id); if (ret < 0) { LOG_WARN( "Failed to log status %s , reason %s, from cmd %s, event %s, ble_event %s, for %s, handle %d, type %s, " "error %d", common::ToHexString(cmd_status).c_str(), common::ToHexString(reason_code).c_str(), common::ToHexString(hci_cmd).c_str(), common::ToHexString(hci_event).c_str(), common::ToHexString(hci_ble_event).c_str(), log::warn( "Failed to log status {} , reason {}, from cmd {}, event {}, ble_event {}, for {}, handle " "{}, type {}, error {}", common::ToHexString(cmd_status), common::ToHexString(reason_code), common::ToHexString(hci_cmd), common::ToHexString(hci_event), common::ToHexString(hci_ble_event), address ? ADDRESS_TO_LOGGABLE_CSTR(*address) : "(NULL)", connection_handle, common::ToHexString(link_type).c_str(), common::ToHexString(link_type), ret); } } Loading @@ -88,7 +106,7 @@ void LogMetricLinkLayerConnectionEvent( void LogMetricHciTimeoutEvent(uint32_t hci_cmd) { int ret = stats_write(BLUETOOTH_HCI_TIMEOUT_REPORTED, static_cast<int64_t>(hci_cmd)); if (ret < 0) { LOG_WARN("Failed for opcode %s, error %d", common::ToHexString(hci_cmd).c_str(), ret); log::warn("Failed for opcode {}, error {}", common::ToHexString(hci_cmd), ret); } } Loading @@ -96,13 +114,14 @@ void LogMetricRemoteVersionInfo( uint16_t handle, uint8_t status, uint8_t version, uint16_t manufacturer_name, uint16_t subversion) { int ret = stats_write(BLUETOOTH_REMOTE_VERSION_INFO_REPORTED, handle, status, version, manufacturer_name, subversion); if (ret < 0) { LOG_WARN( "Failed for handle %d, status %s, version %s, manufacturer_name %s, subversion %s, error %d", log::warn( "Failed for handle {}, status {}, version {}, manufacturer_name {}, subversion {}, error " "{}", handle, common::ToHexString(status).c_str(), common::ToHexString(version).c_str(), common::ToHexString(manufacturer_name).c_str(), common::ToHexString(subversion).c_str(), common::ToHexString(status), common::ToHexString(version), common::ToHexString(manufacturer_name), common::ToHexString(subversion), ret); } } Loading @@ -117,10 +136,10 @@ void LogMetricA2dpAudioUnderrunEvent( int ret = stats_write( BLUETOOTH_A2DP_AUDIO_UNDERRUN_REPORTED, byteField, encoding_interval_nanos, num_missing_pcm_bytes, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, encoding_interval_nanos %s, num_missing_pcm_bytes %d, error %d", log::warn( "Failed for {}, encoding_interval_nanos {}, num_missing_pcm_bytes {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), std::to_string(encoding_interval_nanos).c_str(), std::to_string(encoding_interval_nanos), num_missing_pcm_bytes, ret); } Loading @@ -147,11 +166,11 @@ void LogMetricA2dpAudioOverrunEvent( num_dropped_encoded_bytes, metric_id); if (ret < 0) { LOG_WARN( "Failed to log for %s, encoding_interval_nanos %s, num_dropped_buffers %d, " "num_dropped_encoded_frames %d, num_dropped_encoded_bytes %d, error %d", log::warn( "Failed to log for {}, encoding_interval_nanos {}, num_dropped_buffers {}, " "num_dropped_encoded_frames {}, num_dropped_encoded_bytes {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), std::to_string(encoding_interval_nanos).c_str(), std::to_string(encoding_interval_nanos), num_dropped_buffers, num_dropped_encoded_frames, num_dropped_encoded_bytes, Loading @@ -167,8 +186,8 @@ void LogMetricA2dpPlaybackEvent(const Address& address, int playback_state, int int ret = stats_write(BLUETOOTH_A2DP_PLAYBACK_STATE_CHANGED, byteField, playback_state, audio_coding_mode, metric_id); if (ret < 0) { LOG_WARN( "Failed to log for %s, playback_state %d, audio_coding_mode %d,error %d", log::warn( "Failed to log for {}, playback_state {}, audio_coding_mode {},error {}", ADDRESS_TO_LOGGABLE_CSTR(address), playback_state, audio_coding_mode, Loading Loading @@ -203,11 +222,11 @@ void LogMetricReadRssiResult(const Address& address, uint16_t handle, uint32_t c } int ret = stats_write(BLUETOOTH_DEVICE_RSSI_REPORTED, byteField, handle, cmd_status, rssi, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, handle %d, status %s, rssi %d dBm, error %d", log::warn( "Failed for {}, handle {}, status {}, rssi {} dBm, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), handle, common::ToHexString(cmd_status).c_str(), common::ToHexString(cmd_status), rssi, ret); } Loading @@ -227,11 +246,11 @@ void LogMetricReadFailedContactCounterResult( failed_contact_counter, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, handle %d, status %s, failed_contact_counter %d packets, error %d", log::warn( "Failed for {}, handle {}, status {}, failed_contact_counter {} packets, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), handle, common::ToHexString(cmd_status).c_str(), common::ToHexString(cmd_status), failed_contact_counter, ret); } Loading @@ -246,11 +265,11 @@ void LogMetricReadTxPowerLevelResult( int ret = stats_write( BLUETOOTH_DEVICE_TX_POWER_LEVEL_REPORTED, byteField, handle, cmd_status, transmit_power_level, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, handle %d, status %s, transmit_power_level %d packets, error %d", log::warn( "Failed for {}, handle {}, status {}, transmit_power_level {} packets, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), handle, common::ToHexString(cmd_status).c_str(), common::ToHexString(cmd_status), transmit_power_level, ret); } Loading @@ -265,12 +284,12 @@ void LogMetricSmpPairingEvent( int ret = stats_write(BLUETOOTH_SMP_PAIRING_EVENT_REPORTED, byteField, smp_cmd, direction, smp_fail_reason, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, smp_cmd %s, direction %d, smp_fail_reason %s, error %d", log::warn( "Failed for {}, smp_cmd {}, direction {}, smp_fail_reason {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), common::ToHexString(smp_cmd).c_str(), common::ToHexString(smp_cmd), direction, common::ToHexString(smp_fail_reason).c_str(), common::ToHexString(smp_fail_reason), ret); } } Loading Loading @@ -298,16 +317,16 @@ void LogMetricClassicPairingEvent( event_value, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, handle %d, hci_cmd %s, hci_event %s, cmd_status %s, " "reason %s, event_value %s, error %d", log::warn( "Failed for {}, handle {}, hci_cmd {}, hci_event {}, cmd_status {}, reason {}, event_value " "{}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), handle, common::ToHexString(hci_cmd).c_str(), common::ToHexString(hci_event).c_str(), common::ToHexString(cmd_status).c_str(), common::ToHexString(reason_code).c_str(), std::to_string(event_value).c_str(), common::ToHexString(hci_cmd), common::ToHexString(hci_event), common::ToHexString(cmd_status), common::ToHexString(reason_code), std::to_string(event_value), ret); } Loading @@ -330,11 +349,11 @@ void LogMetricSdpAttribute( int ret = stats_write(BLUETOOTH_SDP_ATTRIBUTE_REPORTED, byteField, protocol_uuid, attribute_id, attribute_field, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, protocol_uuid %s, attribute_id %s, error %d", log::warn( "Failed for {}, protocol_uuid {}, attribute_id {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), common::ToHexString(protocol_uuid).c_str(), common::ToHexString(attribute_id).c_str(), common::ToHexString(protocol_uuid), common::ToHexString(attribute_id), ret); } } Loading Loading @@ -366,15 +385,15 @@ void LogMetricSocketConnectionState( socket_role, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, port %d, type %d, state %d, tx_bytes %s, rx_bytes %s, uid %d, server_port %d, " "socket_role %d, error %d", log::warn( "Failed for {}, port {}, type {}, state {}, tx_bytes {}, rx_bytes {}, uid {}, server_port " "{}, socket_role {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), port, type, connection_state, std::to_string(tx_bytes).c_str(), std::to_string(rx_bytes).c_str(), std::to_string(tx_bytes), std::to_string(rx_bytes), uid, server_port, socket_role, Loading Loading @@ -410,17 +429,17 @@ void LogMetricManufacturerInfo( address.address[4], address.address[3]); if (ret < 0) { LOG_WARN( "Failed for %s, source_type %d, source_name %s, manufacturer %s, model %s, " "hardware_version %s, " "software_version %s, MAC address type %d MAC address prefix %d %d %d, error %d", log::warn( "Failed for {}, source_type {}, source_name {}, manufacturer {}, model {}, " "hardware_version {}, software_version {}, MAC address type {} MAC address prefix {} {} " "{}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), source_type, source_name.c_str(), manufacturer.c_str(), model.c_str(), hardware_version.c_str(), software_version.c_str(), source_name, manufacturer, model, hardware_version, software_version, address_type, address.address[5], address.address[4], Loading @@ -436,11 +455,11 @@ void LogMetricBluetoothHalCrashReason( int ret = stats_write(BLUETOOTH_HAL_CRASH_REASON_REPORTED, 0 /* metric_id */, byteField, error_code, vendor_error_code); if (ret < 0) { LOG_WARN( "Failed for %s, error_code %s, vendor_error_code %s, error %d", log::warn( "Failed for {}, error_code {}, vendor_error_code {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), common::ToHexString(error_code).c_str(), common::ToHexString(vendor_error_code).c_str(), common::ToHexString(error_code), common::ToHexString(vendor_error_code), ret); } } Loading @@ -449,11 +468,10 @@ void LogMetricBluetoothLocalSupportedFeatures(uint32_t page_num, uint64_t featur int ret = stats_write( BLUETOOTH_LOCAL_SUPPORTED_FEATURES_REPORTED, page_num, static_cast<int64_t>(features)); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothLocalSupportedFeatures, " "page_num %d, features %s, error %d", log::warn( "Failed for LogMetricBluetoothLocalSupportedFeatures, page_num {}, features {}, error {}", page_num, std::to_string(features).c_str(), std::to_string(features), ret); } } Loading @@ -472,9 +490,9 @@ void LogMetricBluetoothLocalVersions( static_cast<int32_t>(hci_version), static_cast<int32_t>(hci_revision)); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothLocalVersions, " "lmp_manufacturer_name %d, lmp_version %hhu, lmp_subversion %d, hci_version %hhu, hci_revision %d, error %d", log::warn( "Failed for LogMetricBluetoothLocalVersions, lmp_manufacturer_name {}, lmp_version {}, " "lmp_subversion {}, hci_version {}, hci_revision {}, error {}", lmp_manufacturer_name, lmp_version, lmp_subversion, Loading @@ -492,9 +510,9 @@ void LogMetricBluetoothDisconnectionReasonReported( } int ret = stats_write(BLUETOOTH_DISCONNECTION_REASON_REPORTED, reason, metric_id, connection_handle); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothDisconnectionReasonReported, " "reason %d, metric_id %d, connection_handle %d, error %d", log::warn( "Failed for LogMetricBluetoothDisconnectionReasonReported, reason {}, metric_id {}, " "connection_handle {}, error {}", reason, metric_id, connection_handle, Loading @@ -515,12 +533,12 @@ void LogMetricBluetoothRemoteSupportedFeatures( static_cast<int64_t>(features), connection_handle); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothRemoteSupportedFeatures, " "metric_id %d, page %d, features %s, connection_handle %d, error %d", log::warn( "Failed for LogMetricBluetoothRemoteSupportedFeatures, metric_id {}, page {}, features {}, " "connection_handle {}, error {}", metric_id, page, std::to_string(features).c_str(), std::to_string(features), connection_handle, ret); } Loading @@ -529,9 +547,7 @@ void LogMetricBluetoothRemoteSupportedFeatures( void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count) { int ret = stats_write(BLUETOOTH_CODE_PATH_COUNTER, key, count); if (ret < 0) { LOG_WARN( "Failed counter metrics for %d, count %s, error %d", key, std::to_string(count).c_str(), ret); log::warn("Failed counter metrics for {}, count {}, error {}", key, std::to_string(count), ret); } } Loading Loading @@ -564,15 +580,14 @@ void LogMetricBluetoothLEConnection(os::LEConnectionSessionOptions session_optio session_options.is_cancelled); if (ret < 0) { LOG_WARN( "Failed BluetoothLeSessionConnected - Address: %s, ACL Connection State: %s, Origin Type: " "%s", log::warn( "Failed BluetoothLeSessionConnected - Address: {}, ACL Connection State: {}, Origin Type: " "{}", ADDRESS_TO_LOGGABLE_CSTR(session_options.remote_address), common::ToHexString(session_options.acl_connection_state).c_str(), common::ToHexString(session_options.origin_type).c_str()); common::ToHexString(session_options.acl_connection_state), common::ToHexString(session_options.origin_type)); } } } // namespace os } // namespace bluetooth system/gd/os/android/system_properties.cc +18 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include "os/system_properties.h" #include <bluetooth/log.h> #include <cutils/properties.h> #include <array> Loading @@ -38,12 +39,15 @@ std::optional<std::string> GetSystemProperty(const std::string& property) { bool SetSystemProperty(const std::string& property, const std::string& value) { if (value.size() >= PROPERTY_VALUE_MAX) { LOG_ERROR("Property value's maximum size is %d, but %zu chars were given", PROPERTY_VALUE_MAX - 1, value.size()); log::error( "Property value's maximum size is {}, but {} chars were given", PROPERTY_VALUE_MAX - 1, value.size()); return false; } auto ret = property_set(property.c_str(), value.c_str()); if (ret != 0) { LOG_ERROR("Set property %s failed with error code %d", property.c_str(), ret); log::error("Set property {} failed with error code {}", property, ret); return false; } return true; Loading @@ -52,14 +56,14 @@ bool SetSystemProperty(const std::string& property, const std::string& value) { bool IsRootCanalEnabled() { auto value = GetSystemProperty("ro.vendor.build.fingerprint"); if (value.has_value()) { LOG_INFO("ro.vendor.build.fingerprint='%s', length=%zu", value->c_str(), value->length()); log::info("ro.vendor.build.fingerprint='{}', length={}", value->c_str(), value->length()); } else { LOG_INFO("ro.vendor.build.fingerprint is not found"); log::info("ro.vendor.build.fingerprint is not found"); } // aosp_cf_x86_64_phone is just one platform that currently runs root canal // When other platforms appears, or there is a better signal, add them here if (value->find("generic/aosp_cf_x86_64_phone") == std::string::npos) { LOG_INFO("Not on generic/aosp_cf_x86_64_phone and hence not root canal"); log::info("Not on generic/aosp_cf_x86_64_phone and hence not root canal"); return false; } return true; Loading @@ -68,21 +72,24 @@ bool IsRootCanalEnabled() { int GetAndroidVendorReleaseVersion() { auto value = GetSystemProperty("ro.vendor.build.version.release_or_codename"); if (!value) { LOG_INFO("ro.vendor.build.version.release_or_codename does not exist"); log::info("ro.vendor.build.version.release_or_codename does not exist"); return 0; } LOG_INFO("ro.vendor.build.version.release_or_codename='%s', length=%zu", value->c_str(), value->length()); log::info( "ro.vendor.build.version.release_or_codename='{}', length={}", value->c_str(), value->length()); auto int_value = common::Int64FromString(*value); if (int_value) { return static_cast<int>(*int_value); } LOG_INFO("value '%s' cannot be parsed to int", value->c_str()); log::info("value '{}' cannot be parsed to int", value->c_str()); if (value->empty()) { LOG_INFO("value '%s' is empty", value->c_str()); log::info("value '{}' is empty", value->c_str()); return 0; } if (value->length() > 1) { LOG_INFO("value '%s' length is %zu, which is > 1", value->c_str(), value->length()); log::info("value '{}' length is {}, which is > 1", value->c_str(), value->length()); } char release_code = toupper(value->at(0)); switch (release_code) { Loading system/gd/os/android/wakelock_native.cc +10 −9 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <aidl/android/system/suspend/IWakeLock.h> #include <android/binder_ibinder.h> #include <android/binder_manager.h> #include <bluetooth/log.h> #include <fcntl.h> #include <unistd.h> Loading Loading @@ -66,7 +67,7 @@ struct WakelockNative::Impl { Impl() : suspend_death_recipient(AIBinder_DeathRecipient_new(onSuspendDeath)) {} std::function<void(void)> onDeath = [this] { LOG_ERROR("ISystemSuspend HAL service died!"); log::error("ISystemSuspend HAL service died!"); this->suspend_service = nullptr; }; Loading @@ -76,7 +77,7 @@ struct WakelockNative::Impl { }; void WakelockNative::Initialize() { LOG_INFO("Initializing native wake locks"); log::info("Initializing native wake locks"); const std::string suspendInstance = std::string() + ISystemSuspend::descriptor + "/default"; pimpl_->suspend_service = ISystemSuspend::fromBinder( ndk::SpAIBinder(AServiceManager_waitForService(suspendInstance.c_str()))); Loading @@ -89,19 +90,19 @@ void WakelockNative::Initialize() { WakelockNative::StatusCode WakelockNative::Acquire(const std::string& lock_name) { if (!pimpl_->suspend_service) { LOG_ERROR("lock not acquired, ISystemService is not available"); log::error("lock not acquired, ISystemService is not available"); return StatusCode::NATIVE_SERVICE_NOT_AVAILABLE; } if (pimpl_->current_wakelock) { LOG_INFO("wakelock is already acquired"); log::info("wakelock is already acquired"); return StatusCode::SUCCESS; } auto status = pimpl_->suspend_service->acquireWakeLock( WakeLockType::PARTIAL, lock_name, &pimpl_->current_wakelock); if (!pimpl_->current_wakelock) { LOG_ERROR("wake lock not acquired: %s", status.getDescription().c_str()); log::error("wake lock not acquired: {}", status.getDescription()); return StatusCode::NATIVE_API_ERROR; } Loading @@ -110,7 +111,7 @@ WakelockNative::StatusCode WakelockNative::Acquire(const std::string& lock_name) WakelockNative::StatusCode WakelockNative::Release(const std::string& /* lock_name */) { if (!pimpl_->current_wakelock) { LOG_WARN("no lock is currently acquired"); log::warn("no lock is currently acquired"); return StatusCode::SUCCESS; } pimpl_->current_wakelock->release(); Loading @@ -119,14 +120,14 @@ WakelockNative::StatusCode WakelockNative::Release(const std::string& /* lock_na } void WakelockNative::CleanUp() { LOG_INFO("Cleaning up native wake locks"); log::info("Cleaning up native wake locks"); if (pimpl_->current_wakelock) { LOG_INFO("releasing current wakelock during clean up"); log::info("releasing current wakelock during clean up"); pimpl_->current_wakelock->release(); pimpl_->current_wakelock = nullptr; } if (pimpl_->suspend_service) { LOG_INFO("Unlink death recipient"); log::info("Unlink death recipient"); AIBinder_unlinkToDeath( pimpl_->suspend_service->asBinder().get(), pimpl_->suspend_death_recipient.get(), Loading system/gd/os/chromeos/metrics.cc +16 −15 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "os/metrics.h" #include <bluetooth/log.h> #include <metrics/structured_events.h> #include "metrics/utils.h" Loading Loading @@ -66,10 +67,10 @@ void LogMetricA2dpAudioOverrunEvent( addr_string = address.ToString(); LOG_DEBUG( "A2dpAudioOverrun: %s, %s, %llu, %d, %d, %d", boot_id.c_str(), addr_string.c_str(), log::debug( "A2dpAudioOverrun: {}, {}, {}, {}, {}, {}", boot_id, addr_string, (long long unsigned)encoding_interval_millis, num_dropped_buffers, num_dropped_encoded_bytes, Loading @@ -94,10 +95,10 @@ void LogMetricHfpPacketLossStats( addr_string = address.ToString(); LOG_DEBUG( "HfpPacketLoss: %s, %s, %d, %f, %u", boot_id.c_str(), addr_string.c_str(), log::debug( "HfpPacketLoss: {}, {}, {}, {:f}, {}", boot_id, addr_string, num_decoded_frames, packet_loss_ratio, codec_type); Loading @@ -117,9 +118,9 @@ void LogMetricMmcTranscodeRttStats( if (!metrics::GetBootId(&boot_id)) return; LOG_DEBUG( "MmcTranscodeRttStats: %s, %d, %f, %d, %d", boot_id.c_str(), log::debug( "MmcTranscodeRttStats: {}, {}, {:f}, {}, {}", boot_id, maximum_rtt, mean_rtt, num_requests, Loading Loading @@ -207,10 +208,10 @@ void LogMetricA2dpSessionMetricsEvent( addr_string = address.ToString(); LOG_DEBUG( "A2dpSessionMetrics: %s, %s, %lld, %d, %d, %d, %d, %d, %d, %f, %d, %lld, %d", boot_id.c_str(), addr_string.c_str(), log::debug( "A2dpSessionMetrics: {}, {}, {}, {}, {}, {}, {}, {}, {}, {:f}, {}, {}, {}", boot_id, addr_string, (long long int)audio_duration_ms, media_timer_min_ms, media_timer_max_ms, Loading Loading
system/audio_a2dp_hw/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ cc_library { "com.android.btservices", ], shared_libs: [ "libbase", "libcutils", "liblog", ], Loading
system/gd/os/android/metrics.cc +108 −93 Original line number Diff line number Diff line Loading @@ -20,17 +20,35 @@ #include "os/metrics.h" #include <bluetooth/log.h> #include <statslog_bt.h> #include "common/audit_log.h" #include "metrics/metrics_state.h" #include "common/metric_id_manager.h" #include "common/strings.h" #include "hci/hci_packets.h" #include "metrics/metrics_state.h" #include "os/log.h" namespace bluetooth { namespace fmt { template <> struct formatter<android::bluetooth::DirectionEnum> : enum_formatter<android::bluetooth::DirectionEnum> {}; template <> struct formatter<android::bluetooth::SocketConnectionstateEnum> : enum_formatter<android::bluetooth::SocketConnectionstateEnum> {}; template <> struct formatter<android::bluetooth::SocketRoleEnum> : enum_formatter<android::bluetooth::SocketRoleEnum> {}; template <> struct formatter<android::bluetooth::DeviceInfoSrcEnum> : enum_formatter<android::bluetooth::DeviceInfoSrcEnum> {}; template <> struct formatter<android::bluetooth::AddressTypeEnum> : enum_formatter<android::bluetooth::AddressTypeEnum> {}; } // namespace fmt namespace bluetooth { namespace os { using bluetooth::common::MetricIdManager; Loading Loading @@ -70,17 +88,17 @@ void LogMetricLinkLayerConnectionEvent( reason_code, metric_id); if (ret < 0) { LOG_WARN( "Failed to log status %s , reason %s, from cmd %s, event %s, ble_event %s, for %s, handle %d, type %s, " "error %d", common::ToHexString(cmd_status).c_str(), common::ToHexString(reason_code).c_str(), common::ToHexString(hci_cmd).c_str(), common::ToHexString(hci_event).c_str(), common::ToHexString(hci_ble_event).c_str(), log::warn( "Failed to log status {} , reason {}, from cmd {}, event {}, ble_event {}, for {}, handle " "{}, type {}, error {}", common::ToHexString(cmd_status), common::ToHexString(reason_code), common::ToHexString(hci_cmd), common::ToHexString(hci_event), common::ToHexString(hci_ble_event), address ? ADDRESS_TO_LOGGABLE_CSTR(*address) : "(NULL)", connection_handle, common::ToHexString(link_type).c_str(), common::ToHexString(link_type), ret); } } Loading @@ -88,7 +106,7 @@ void LogMetricLinkLayerConnectionEvent( void LogMetricHciTimeoutEvent(uint32_t hci_cmd) { int ret = stats_write(BLUETOOTH_HCI_TIMEOUT_REPORTED, static_cast<int64_t>(hci_cmd)); if (ret < 0) { LOG_WARN("Failed for opcode %s, error %d", common::ToHexString(hci_cmd).c_str(), ret); log::warn("Failed for opcode {}, error {}", common::ToHexString(hci_cmd), ret); } } Loading @@ -96,13 +114,14 @@ void LogMetricRemoteVersionInfo( uint16_t handle, uint8_t status, uint8_t version, uint16_t manufacturer_name, uint16_t subversion) { int ret = stats_write(BLUETOOTH_REMOTE_VERSION_INFO_REPORTED, handle, status, version, manufacturer_name, subversion); if (ret < 0) { LOG_WARN( "Failed for handle %d, status %s, version %s, manufacturer_name %s, subversion %s, error %d", log::warn( "Failed for handle {}, status {}, version {}, manufacturer_name {}, subversion {}, error " "{}", handle, common::ToHexString(status).c_str(), common::ToHexString(version).c_str(), common::ToHexString(manufacturer_name).c_str(), common::ToHexString(subversion).c_str(), common::ToHexString(status), common::ToHexString(version), common::ToHexString(manufacturer_name), common::ToHexString(subversion), ret); } } Loading @@ -117,10 +136,10 @@ void LogMetricA2dpAudioUnderrunEvent( int ret = stats_write( BLUETOOTH_A2DP_AUDIO_UNDERRUN_REPORTED, byteField, encoding_interval_nanos, num_missing_pcm_bytes, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, encoding_interval_nanos %s, num_missing_pcm_bytes %d, error %d", log::warn( "Failed for {}, encoding_interval_nanos {}, num_missing_pcm_bytes {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), std::to_string(encoding_interval_nanos).c_str(), std::to_string(encoding_interval_nanos), num_missing_pcm_bytes, ret); } Loading @@ -147,11 +166,11 @@ void LogMetricA2dpAudioOverrunEvent( num_dropped_encoded_bytes, metric_id); if (ret < 0) { LOG_WARN( "Failed to log for %s, encoding_interval_nanos %s, num_dropped_buffers %d, " "num_dropped_encoded_frames %d, num_dropped_encoded_bytes %d, error %d", log::warn( "Failed to log for {}, encoding_interval_nanos {}, num_dropped_buffers {}, " "num_dropped_encoded_frames {}, num_dropped_encoded_bytes {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), std::to_string(encoding_interval_nanos).c_str(), std::to_string(encoding_interval_nanos), num_dropped_buffers, num_dropped_encoded_frames, num_dropped_encoded_bytes, Loading @@ -167,8 +186,8 @@ void LogMetricA2dpPlaybackEvent(const Address& address, int playback_state, int int ret = stats_write(BLUETOOTH_A2DP_PLAYBACK_STATE_CHANGED, byteField, playback_state, audio_coding_mode, metric_id); if (ret < 0) { LOG_WARN( "Failed to log for %s, playback_state %d, audio_coding_mode %d,error %d", log::warn( "Failed to log for {}, playback_state {}, audio_coding_mode {},error {}", ADDRESS_TO_LOGGABLE_CSTR(address), playback_state, audio_coding_mode, Loading Loading @@ -203,11 +222,11 @@ void LogMetricReadRssiResult(const Address& address, uint16_t handle, uint32_t c } int ret = stats_write(BLUETOOTH_DEVICE_RSSI_REPORTED, byteField, handle, cmd_status, rssi, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, handle %d, status %s, rssi %d dBm, error %d", log::warn( "Failed for {}, handle {}, status {}, rssi {} dBm, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), handle, common::ToHexString(cmd_status).c_str(), common::ToHexString(cmd_status), rssi, ret); } Loading @@ -227,11 +246,11 @@ void LogMetricReadFailedContactCounterResult( failed_contact_counter, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, handle %d, status %s, failed_contact_counter %d packets, error %d", log::warn( "Failed for {}, handle {}, status {}, failed_contact_counter {} packets, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), handle, common::ToHexString(cmd_status).c_str(), common::ToHexString(cmd_status), failed_contact_counter, ret); } Loading @@ -246,11 +265,11 @@ void LogMetricReadTxPowerLevelResult( int ret = stats_write( BLUETOOTH_DEVICE_TX_POWER_LEVEL_REPORTED, byteField, handle, cmd_status, transmit_power_level, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, handle %d, status %s, transmit_power_level %d packets, error %d", log::warn( "Failed for {}, handle {}, status {}, transmit_power_level {} packets, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), handle, common::ToHexString(cmd_status).c_str(), common::ToHexString(cmd_status), transmit_power_level, ret); } Loading @@ -265,12 +284,12 @@ void LogMetricSmpPairingEvent( int ret = stats_write(BLUETOOTH_SMP_PAIRING_EVENT_REPORTED, byteField, smp_cmd, direction, smp_fail_reason, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, smp_cmd %s, direction %d, smp_fail_reason %s, error %d", log::warn( "Failed for {}, smp_cmd {}, direction {}, smp_fail_reason {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), common::ToHexString(smp_cmd).c_str(), common::ToHexString(smp_cmd), direction, common::ToHexString(smp_fail_reason).c_str(), common::ToHexString(smp_fail_reason), ret); } } Loading Loading @@ -298,16 +317,16 @@ void LogMetricClassicPairingEvent( event_value, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, handle %d, hci_cmd %s, hci_event %s, cmd_status %s, " "reason %s, event_value %s, error %d", log::warn( "Failed for {}, handle {}, hci_cmd {}, hci_event {}, cmd_status {}, reason {}, event_value " "{}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), handle, common::ToHexString(hci_cmd).c_str(), common::ToHexString(hci_event).c_str(), common::ToHexString(cmd_status).c_str(), common::ToHexString(reason_code).c_str(), std::to_string(event_value).c_str(), common::ToHexString(hci_cmd), common::ToHexString(hci_event), common::ToHexString(cmd_status), common::ToHexString(reason_code), std::to_string(event_value), ret); } Loading @@ -330,11 +349,11 @@ void LogMetricSdpAttribute( int ret = stats_write(BLUETOOTH_SDP_ATTRIBUTE_REPORTED, byteField, protocol_uuid, attribute_id, attribute_field, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, protocol_uuid %s, attribute_id %s, error %d", log::warn( "Failed for {}, protocol_uuid {}, attribute_id {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), common::ToHexString(protocol_uuid).c_str(), common::ToHexString(attribute_id).c_str(), common::ToHexString(protocol_uuid), common::ToHexString(attribute_id), ret); } } Loading Loading @@ -366,15 +385,15 @@ void LogMetricSocketConnectionState( socket_role, metric_id); if (ret < 0) { LOG_WARN( "Failed for %s, port %d, type %d, state %d, tx_bytes %s, rx_bytes %s, uid %d, server_port %d, " "socket_role %d, error %d", log::warn( "Failed for {}, port {}, type {}, state {}, tx_bytes {}, rx_bytes {}, uid {}, server_port " "{}, socket_role {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), port, type, connection_state, std::to_string(tx_bytes).c_str(), std::to_string(rx_bytes).c_str(), std::to_string(tx_bytes), std::to_string(rx_bytes), uid, server_port, socket_role, Loading Loading @@ -410,17 +429,17 @@ void LogMetricManufacturerInfo( address.address[4], address.address[3]); if (ret < 0) { LOG_WARN( "Failed for %s, source_type %d, source_name %s, manufacturer %s, model %s, " "hardware_version %s, " "software_version %s, MAC address type %d MAC address prefix %d %d %d, error %d", log::warn( "Failed for {}, source_type {}, source_name {}, manufacturer {}, model {}, " "hardware_version {}, software_version {}, MAC address type {} MAC address prefix {} {} " "{}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), source_type, source_name.c_str(), manufacturer.c_str(), model.c_str(), hardware_version.c_str(), software_version.c_str(), source_name, manufacturer, model, hardware_version, software_version, address_type, address.address[5], address.address[4], Loading @@ -436,11 +455,11 @@ void LogMetricBluetoothHalCrashReason( int ret = stats_write(BLUETOOTH_HAL_CRASH_REASON_REPORTED, 0 /* metric_id */, byteField, error_code, vendor_error_code); if (ret < 0) { LOG_WARN( "Failed for %s, error_code %s, vendor_error_code %s, error %d", log::warn( "Failed for {}, error_code {}, vendor_error_code {}, error {}", ADDRESS_TO_LOGGABLE_CSTR(address), common::ToHexString(error_code).c_str(), common::ToHexString(vendor_error_code).c_str(), common::ToHexString(error_code), common::ToHexString(vendor_error_code), ret); } } Loading @@ -449,11 +468,10 @@ void LogMetricBluetoothLocalSupportedFeatures(uint32_t page_num, uint64_t featur int ret = stats_write( BLUETOOTH_LOCAL_SUPPORTED_FEATURES_REPORTED, page_num, static_cast<int64_t>(features)); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothLocalSupportedFeatures, " "page_num %d, features %s, error %d", log::warn( "Failed for LogMetricBluetoothLocalSupportedFeatures, page_num {}, features {}, error {}", page_num, std::to_string(features).c_str(), std::to_string(features), ret); } } Loading @@ -472,9 +490,9 @@ void LogMetricBluetoothLocalVersions( static_cast<int32_t>(hci_version), static_cast<int32_t>(hci_revision)); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothLocalVersions, " "lmp_manufacturer_name %d, lmp_version %hhu, lmp_subversion %d, hci_version %hhu, hci_revision %d, error %d", log::warn( "Failed for LogMetricBluetoothLocalVersions, lmp_manufacturer_name {}, lmp_version {}, " "lmp_subversion {}, hci_version {}, hci_revision {}, error {}", lmp_manufacturer_name, lmp_version, lmp_subversion, Loading @@ -492,9 +510,9 @@ void LogMetricBluetoothDisconnectionReasonReported( } int ret = stats_write(BLUETOOTH_DISCONNECTION_REASON_REPORTED, reason, metric_id, connection_handle); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothDisconnectionReasonReported, " "reason %d, metric_id %d, connection_handle %d, error %d", log::warn( "Failed for LogMetricBluetoothDisconnectionReasonReported, reason {}, metric_id {}, " "connection_handle {}, error {}", reason, metric_id, connection_handle, Loading @@ -515,12 +533,12 @@ void LogMetricBluetoothRemoteSupportedFeatures( static_cast<int64_t>(features), connection_handle); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothRemoteSupportedFeatures, " "metric_id %d, page %d, features %s, connection_handle %d, error %d", log::warn( "Failed for LogMetricBluetoothRemoteSupportedFeatures, metric_id {}, page {}, features {}, " "connection_handle {}, error {}", metric_id, page, std::to_string(features).c_str(), std::to_string(features), connection_handle, ret); } Loading @@ -529,9 +547,7 @@ void LogMetricBluetoothRemoteSupportedFeatures( void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count) { int ret = stats_write(BLUETOOTH_CODE_PATH_COUNTER, key, count); if (ret < 0) { LOG_WARN( "Failed counter metrics for %d, count %s, error %d", key, std::to_string(count).c_str(), ret); log::warn("Failed counter metrics for {}, count {}, error {}", key, std::to_string(count), ret); } } Loading Loading @@ -564,15 +580,14 @@ void LogMetricBluetoothLEConnection(os::LEConnectionSessionOptions session_optio session_options.is_cancelled); if (ret < 0) { LOG_WARN( "Failed BluetoothLeSessionConnected - Address: %s, ACL Connection State: %s, Origin Type: " "%s", log::warn( "Failed BluetoothLeSessionConnected - Address: {}, ACL Connection State: {}, Origin Type: " "{}", ADDRESS_TO_LOGGABLE_CSTR(session_options.remote_address), common::ToHexString(session_options.acl_connection_state).c_str(), common::ToHexString(session_options.origin_type).c_str()); common::ToHexString(session_options.acl_connection_state), common::ToHexString(session_options.origin_type)); } } } // namespace os } // namespace bluetooth
system/gd/os/android/system_properties.cc +18 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include "os/system_properties.h" #include <bluetooth/log.h> #include <cutils/properties.h> #include <array> Loading @@ -38,12 +39,15 @@ std::optional<std::string> GetSystemProperty(const std::string& property) { bool SetSystemProperty(const std::string& property, const std::string& value) { if (value.size() >= PROPERTY_VALUE_MAX) { LOG_ERROR("Property value's maximum size is %d, but %zu chars were given", PROPERTY_VALUE_MAX - 1, value.size()); log::error( "Property value's maximum size is {}, but {} chars were given", PROPERTY_VALUE_MAX - 1, value.size()); return false; } auto ret = property_set(property.c_str(), value.c_str()); if (ret != 0) { LOG_ERROR("Set property %s failed with error code %d", property.c_str(), ret); log::error("Set property {} failed with error code {}", property, ret); return false; } return true; Loading @@ -52,14 +56,14 @@ bool SetSystemProperty(const std::string& property, const std::string& value) { bool IsRootCanalEnabled() { auto value = GetSystemProperty("ro.vendor.build.fingerprint"); if (value.has_value()) { LOG_INFO("ro.vendor.build.fingerprint='%s', length=%zu", value->c_str(), value->length()); log::info("ro.vendor.build.fingerprint='{}', length={}", value->c_str(), value->length()); } else { LOG_INFO("ro.vendor.build.fingerprint is not found"); log::info("ro.vendor.build.fingerprint is not found"); } // aosp_cf_x86_64_phone is just one platform that currently runs root canal // When other platforms appears, or there is a better signal, add them here if (value->find("generic/aosp_cf_x86_64_phone") == std::string::npos) { LOG_INFO("Not on generic/aosp_cf_x86_64_phone and hence not root canal"); log::info("Not on generic/aosp_cf_x86_64_phone and hence not root canal"); return false; } return true; Loading @@ -68,21 +72,24 @@ bool IsRootCanalEnabled() { int GetAndroidVendorReleaseVersion() { auto value = GetSystemProperty("ro.vendor.build.version.release_or_codename"); if (!value) { LOG_INFO("ro.vendor.build.version.release_or_codename does not exist"); log::info("ro.vendor.build.version.release_or_codename does not exist"); return 0; } LOG_INFO("ro.vendor.build.version.release_or_codename='%s', length=%zu", value->c_str(), value->length()); log::info( "ro.vendor.build.version.release_or_codename='{}', length={}", value->c_str(), value->length()); auto int_value = common::Int64FromString(*value); if (int_value) { return static_cast<int>(*int_value); } LOG_INFO("value '%s' cannot be parsed to int", value->c_str()); log::info("value '{}' cannot be parsed to int", value->c_str()); if (value->empty()) { LOG_INFO("value '%s' is empty", value->c_str()); log::info("value '{}' is empty", value->c_str()); return 0; } if (value->length() > 1) { LOG_INFO("value '%s' length is %zu, which is > 1", value->c_str(), value->length()); log::info("value '{}' length is {}, which is > 1", value->c_str(), value->length()); } char release_code = toupper(value->at(0)); switch (release_code) { Loading
system/gd/os/android/wakelock_native.cc +10 −9 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <aidl/android/system/suspend/IWakeLock.h> #include <android/binder_ibinder.h> #include <android/binder_manager.h> #include <bluetooth/log.h> #include <fcntl.h> #include <unistd.h> Loading Loading @@ -66,7 +67,7 @@ struct WakelockNative::Impl { Impl() : suspend_death_recipient(AIBinder_DeathRecipient_new(onSuspendDeath)) {} std::function<void(void)> onDeath = [this] { LOG_ERROR("ISystemSuspend HAL service died!"); log::error("ISystemSuspend HAL service died!"); this->suspend_service = nullptr; }; Loading @@ -76,7 +77,7 @@ struct WakelockNative::Impl { }; void WakelockNative::Initialize() { LOG_INFO("Initializing native wake locks"); log::info("Initializing native wake locks"); const std::string suspendInstance = std::string() + ISystemSuspend::descriptor + "/default"; pimpl_->suspend_service = ISystemSuspend::fromBinder( ndk::SpAIBinder(AServiceManager_waitForService(suspendInstance.c_str()))); Loading @@ -89,19 +90,19 @@ void WakelockNative::Initialize() { WakelockNative::StatusCode WakelockNative::Acquire(const std::string& lock_name) { if (!pimpl_->suspend_service) { LOG_ERROR("lock not acquired, ISystemService is not available"); log::error("lock not acquired, ISystemService is not available"); return StatusCode::NATIVE_SERVICE_NOT_AVAILABLE; } if (pimpl_->current_wakelock) { LOG_INFO("wakelock is already acquired"); log::info("wakelock is already acquired"); return StatusCode::SUCCESS; } auto status = pimpl_->suspend_service->acquireWakeLock( WakeLockType::PARTIAL, lock_name, &pimpl_->current_wakelock); if (!pimpl_->current_wakelock) { LOG_ERROR("wake lock not acquired: %s", status.getDescription().c_str()); log::error("wake lock not acquired: {}", status.getDescription()); return StatusCode::NATIVE_API_ERROR; } Loading @@ -110,7 +111,7 @@ WakelockNative::StatusCode WakelockNative::Acquire(const std::string& lock_name) WakelockNative::StatusCode WakelockNative::Release(const std::string& /* lock_name */) { if (!pimpl_->current_wakelock) { LOG_WARN("no lock is currently acquired"); log::warn("no lock is currently acquired"); return StatusCode::SUCCESS; } pimpl_->current_wakelock->release(); Loading @@ -119,14 +120,14 @@ WakelockNative::StatusCode WakelockNative::Release(const std::string& /* lock_na } void WakelockNative::CleanUp() { LOG_INFO("Cleaning up native wake locks"); log::info("Cleaning up native wake locks"); if (pimpl_->current_wakelock) { LOG_INFO("releasing current wakelock during clean up"); log::info("releasing current wakelock during clean up"); pimpl_->current_wakelock->release(); pimpl_->current_wakelock = nullptr; } if (pimpl_->suspend_service) { LOG_INFO("Unlink death recipient"); log::info("Unlink death recipient"); AIBinder_unlinkToDeath( pimpl_->suspend_service->asBinder().get(), pimpl_->suspend_death_recipient.get(), Loading
system/gd/os/chromeos/metrics.cc +16 −15 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "os/metrics.h" #include <bluetooth/log.h> #include <metrics/structured_events.h> #include "metrics/utils.h" Loading Loading @@ -66,10 +67,10 @@ void LogMetricA2dpAudioOverrunEvent( addr_string = address.ToString(); LOG_DEBUG( "A2dpAudioOverrun: %s, %s, %llu, %d, %d, %d", boot_id.c_str(), addr_string.c_str(), log::debug( "A2dpAudioOverrun: {}, {}, {}, {}, {}, {}", boot_id, addr_string, (long long unsigned)encoding_interval_millis, num_dropped_buffers, num_dropped_encoded_bytes, Loading @@ -94,10 +95,10 @@ void LogMetricHfpPacketLossStats( addr_string = address.ToString(); LOG_DEBUG( "HfpPacketLoss: %s, %s, %d, %f, %u", boot_id.c_str(), addr_string.c_str(), log::debug( "HfpPacketLoss: {}, {}, {}, {:f}, {}", boot_id, addr_string, num_decoded_frames, packet_loss_ratio, codec_type); Loading @@ -117,9 +118,9 @@ void LogMetricMmcTranscodeRttStats( if (!metrics::GetBootId(&boot_id)) return; LOG_DEBUG( "MmcTranscodeRttStats: %s, %d, %f, %d, %d", boot_id.c_str(), log::debug( "MmcTranscodeRttStats: {}, {}, {:f}, {}, {}", boot_id, maximum_rtt, mean_rtt, num_requests, Loading Loading @@ -207,10 +208,10 @@ void LogMetricA2dpSessionMetricsEvent( addr_string = address.ToString(); LOG_DEBUG( "A2dpSessionMetrics: %s, %s, %lld, %d, %d, %d, %d, %d, %d, %f, %d, %lld, %d", boot_id.c_str(), addr_string.c_str(), log::debug( "A2dpSessionMetrics: {}, {}, {}, {}, {}, {}, {}, {}, {}, {:f}, {}, {}, {}", boot_id, addr_string, (long long int)audio_duration_ms, media_timer_min_ms, media_timer_max_ms, Loading