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) {
@@ -384,15 +391,17 @@ ServiceManager::~ServiceManager() {
384391}
385392
386393Status ServiceManager::getService (const std::string& name, os::Service* outService) {
387- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
394+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
395+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
388396
389397 *outService = tryGetService (name, true );
390398 // returns ok regardless of result for legacy reasons
391399 return Status::ok ();
392400}
393401
394402Status ServiceManager::checkService (const std::string& name, os::Service* outService) {
395- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
403+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
404+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
396405
397406 *outService = tryGetService (name, false );
398407 // returns ok regardless of result for legacy reasons
@@ -417,7 +426,8 @@ os::Service ServiceManager::tryGetService(const std::string& name, bool startIfN
417426}
418427
419428sp<IBinder> ServiceManager::tryGetBinder (const std::string& name, bool startIfNotFound) {
420- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
429+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
430+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
421431
422432 auto ctx = mAccess ->getCallingContext ();
423433
@@ -457,7 +467,8 @@ sp<IBinder> ServiceManager::tryGetBinder(const std::string& name, bool startIfNo
457467}
458468
459469bool isValidServiceName (const std::string& name) {
460- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
470+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
471+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
461472
462473 if (name.size () == 0 ) return false ;
463474 if (name.size () > 127 ) return false ;
@@ -474,7 +485,8 @@ bool isValidServiceName(const std::string& name) {
474485}
475486
476487Status ServiceManager::addService (const std::string& name, const sp<IBinder>& binder, bool allowIsolated, int32_t dumpPriority) {
477- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
488+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
489+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
478490
479491 auto ctx = mAccess ->getCallingContext ();
480492
@@ -597,7 +609,8 @@ Status ServiceManager::listServices(int32_t dumpPriority, std::vector<std::strin
597609
598610Status ServiceManager::registerForNotifications (
599611 const std::string& name, const sp<IServiceCallback>& callback) {
600- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
612+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
613+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
601614
602615 auto ctx = mAccess ->getCallingContext ();
603616
@@ -648,7 +661,8 @@ Status ServiceManager::registerForNotifications(
648661}
649662Status ServiceManager::unregisterForNotifications (
650663 const std::string& name, const sp<IServiceCallback>& callback) {
651- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
664+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
665+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
652666
653667 auto ctx = mAccess ->getCallingContext ();
654668
@@ -674,7 +688,8 @@ Status ServiceManager::unregisterForNotifications(
674688}
675689
676690Status ServiceManager::isDeclared (const std::string& name, bool * outReturn) {
677- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
691+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
692+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
678693
679694 auto ctx = mAccess ->getCallingContext ();
680695
@@ -692,7 +707,8 @@ Status ServiceManager::isDeclared(const std::string& name, bool* outReturn) {
692707}
693708
694709binder::Status ServiceManager::getDeclaredInstances (const std::string& interface, std::vector<std::string>* outReturn) {
695- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" interface" , interface.c_str ()));
710+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
711+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoInterfaceName , interface.c_str ())));
696712
697713 auto ctx = mAccess ->getCallingContext ();
698714
@@ -720,7 +736,8 @@ binder::Status ServiceManager::getDeclaredInstances(const std::string& interface
720736
721737Status ServiceManager::updatableViaApex (const std::string& name,
722738 std::optional<std::string>* outReturn) {
723- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
739+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
740+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
724741
725742 auto ctx = mAccess ->getCallingContext ();
726743
@@ -739,7 +756,8 @@ Status ServiceManager::updatableViaApex(const std::string& name,
739756
740757Status ServiceManager::getUpdatableNames ([[maybe_unused]] const std::string& apexName,
741758 std::vector<std::string>* outReturn) {
742- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" apexName" , apexName.c_str ()));
759+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
760+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoApexName , apexName.c_str ())));
743761
744762 auto ctx = mAccess ->getCallingContext ();
745763
@@ -765,7 +783,8 @@ Status ServiceManager::getUpdatableNames([[maybe_unused]] const std::string& ape
765783
766784Status ServiceManager::getConnectionInfo (const std::string& name,
767785 std::optional<ConnectionInfo>* outReturn) {
768- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
786+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
787+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
769788
770789 auto ctx = mAccess ->getCallingContext ();
771790
@@ -850,7 +869,8 @@ void ServiceManager::tryStartService(const Access::CallingContext& ctx, const st
850869
851870Status ServiceManager::registerClientCallback (const std::string& name, const sp<IBinder>& service,
852871 const sp<IClientCallback>& cb) {
853- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
872+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
873+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
854874
855875 if (cb == nullptr ) {
856876 return Status::fromExceptionCode (Status::EX_NULL_POINTER, " Callback null." );
@@ -1012,7 +1032,8 @@ void ServiceManager::sendClientCallbackNotifications(const std::string& serviceN
10121032}
10131033
10141034Status ServiceManager::tryUnregisterService (const std::string& name, const sp<IBinder>& binder) {
1015- SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_ARG_STRING (" name" , name.c_str ()));
1035+ SM_PERFETTO_TRACE_FUNC (PERFETTO_TE_PROTO_FIELDS (
1036+ PERFETTO_TE_PROTO_FIELD_CSTR (kProtoServiceName , name.c_str ())));
10161037
10171038 if (binder == nullptr ) {
10181039 return Status::fromExceptionCode (Status::EX_NULL_POINTER, " Null service." );
0 commit comments