2929#include < thread>
3030
3131#if !defined(VENDORSERVICEMANAGER) && !defined(__ANDROID_RECOVERY__)
32+ #include " perfetto/public/protos/trace/android/android_track_event.pzc.h"
3233#include " perfetto/public/te_category_macros.h"
3334#include " perfetto/public/te_macros.h"
3435#endif // !defined(VENDORSERVICEMANAGER) && !defined(__ANDROID_RECOVERY__)
@@ -57,6 +58,12 @@ PERFETTO_TE_CATEGORIES_DEFINE(PERFETTO_SM_CATEGORIES);
5758#define SM_PERFETTO_TRACE_FUNC (...) \
5859 PERFETTO_TE_SCOPED (servicemanager, PERFETTO_TE_SLICE_BEGIN(__func__) __VA_OPT__(, ) __VA_ARGS__)
5960
61+ constexpr uint32_t kProtoServiceName =
62+ perfetto_protos_AndroidTrackEvent_binder_service_name_field_number;
63+ constexpr uint32_t kProtoInterfaceName =
64+ perfetto_protos_AndroidTrackEvent_binder_interface_name_field_number;
65+ constexpr uint32_t kProtoApexName = perfetto_protos_AndroidTrackEvent_apex_name_field_number;
66+
6067#endif // !(defined(VENDORSERVICEMANAGER) || defined(__ANDROID_RECOVERY__))
6168
6269bool is_multiuser_uid_isolated (uid_t uid) {
@@ -386,15 +393,17 @@ ServiceManager::~ServiceManager() {
386393}
387394
388395Status ServiceManager::getService (const std::string& name, os::Service* outService) {
389- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
396+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
397+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
390398
391399 *outService = tryGetService (name, true );
392400 // returns ok regardless of result for legacy reasons
393401 return Status::ok ();
394402}
395403
396404Status ServiceManager::checkService (const std::string& name, os::Service* outService) {
397- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
405+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
406+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
398407
399408 *outService = tryGetService (name, false );
400409 // returns ok regardless of result for legacy reasons
@@ -419,7 +428,8 @@ os::Service ServiceManager::tryGetService(const std::string& name, bool startIfN
419428}
420429
421430sp<IBinder> ServiceManager::tryGetBinder (const std::string& name, bool startIfNotFound) {
422- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
431+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
432+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
423433
424434 auto ctx = mAccess ->getCallingContext ();
425435
@@ -459,7 +469,8 @@ sp<IBinder> ServiceManager::tryGetBinder(const std::string& name, bool startIfNo
459469}
460470
461471bool isValidServiceName (const std::string& name) {
462- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
472+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
473+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
463474
464475 if (name.size () == 0 ) return false ;
465476 if (name.size () > 127 ) return false ;
@@ -476,7 +487,8 @@ bool isValidServiceName(const std::string& name) {
476487}
477488
478489Status ServiceManager::addService (const std::string& name, const sp<IBinder>& binder, bool allowIsolated, int32_t dumpPriority) {
479- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
490+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
491+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
480492
481493 auto ctx = mAccess ->getCallingContext ();
482494
@@ -599,7 +611,8 @@ Status ServiceManager::listServices(int32_t dumpPriority, std::vector<std::strin
599611
600612Status ServiceManager::registerForNotifications (
601613 const std::string& name, const sp<IServiceCallback>& callback) {
602- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
614+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
615+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
603616
604617 auto ctx = mAccess ->getCallingContext ();
605618
@@ -650,7 +663,8 @@ Status ServiceManager::registerForNotifications(
650663}
651664Status ServiceManager::unregisterForNotifications (
652665 const std::string& name, const sp<IServiceCallback>& callback) {
653- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
666+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
667+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
654668
655669 auto ctx = mAccess ->getCallingContext ();
656670
@@ -676,7 +690,8 @@ Status ServiceManager::unregisterForNotifications(
676690}
677691
678692Status ServiceManager::isDeclared (const std::string& name, bool * outReturn) {
679- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
693+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
694+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
680695
681696 auto ctx = mAccess ->getCallingContext ();
682697
@@ -694,7 +709,8 @@ Status ServiceManager::isDeclared(const std::string& name, bool* outReturn) {
694709}
695710
696711binder::Status ServiceManager::getDeclaredInstances (const std::string& interface, std::vector<std::string>* outReturn) {
697- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" interface" , interface.c_str ()));
712+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
713+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoInterfaceName , interface.c_str ())));
698714
699715 auto ctx = mAccess ->getCallingContext ();
700716
@@ -722,7 +738,8 @@ binder::Status ServiceManager::getDeclaredInstances(const std::string& interface
722738
723739Status ServiceManager::updatableViaApex (const std::string& name,
724740 std::optional<std::string>* outReturn) {
725- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
741+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
742+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
726743
727744 auto ctx = mAccess ->getCallingContext ();
728745
@@ -741,7 +758,8 @@ Status ServiceManager::updatableViaApex(const std::string& name,
741758
742759Status ServiceManager::getUpdatableNames ([[maybe_unused]] const std::string& apexName,
743760 std::vector<std::string>* outReturn) {
744- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" apexName" , apexName.c_str ()));
761+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
762+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoApexName , apexName.c_str ())));
745763
746764 auto ctx = mAccess ->getCallingContext ();
747765
@@ -767,7 +785,8 @@ Status ServiceManager::getUpdatableNames([[maybe_unused]] const std::string& ape
767785
768786Status ServiceManager::getConnectionInfo (const std::string& name,
769787 std::optional<ConnectionInfo>* outReturn) {
770- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
788+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
789+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
771790
772791 auto ctx = mAccess ->getCallingContext ();
773792
@@ -852,7 +871,8 @@ void ServiceManager::tryStartService(const Access::CallingContext& ctx, const st
852871
853872Status ServiceManager::registerClientCallback (const std::string& name, const sp<IBinder>& service,
854873 const sp<IClientCallback>& cb) {
855- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
874+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
875+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
856876
857877 if (cb == nullptr ) {
858878 return Status::fromExceptionCode (Status::EX_NULL_POINTER, " Callback null." );
@@ -1014,7 +1034,8 @@ void ServiceManager::sendClientCallbackNotifications(const std::string& serviceN
10141034}
10151035
10161036Status ServiceManager::tryUnregisterService (const std::string& name, const sp<IBinder>& binder) {
1017- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
1037+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
1038+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
10181039
10191040 if (binder == nullptr ) {
10201041 return Status::fromExceptionCode (Status::EX_NULL_POINTER, " Null service." );
0 commit comments