From 2aa510e8b4234fbfeb035f71f16366423fd93750 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Tue, 8 Dec 2015 09:15:06 -0800 Subject: [PATCH] liblog: logprint use uid name if length less then 5 Bug: 25996918 Change-Id: Id882978b7b0b439e39bedeafc39edf80892f0317 --- liblog/logprint.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/liblog/logprint.c b/liblog/logprint.c index b745cf671..746eb8aa2 100644 --- a/liblog/logprint.c +++ b/liblog/logprint.c @@ -32,6 +32,7 @@ #include #include #include +#include #define MS_PER_NSEC 1000000 #define US_PER_NSEC 1000 @@ -1328,7 +1329,21 @@ char *android_log_formatLogLine ( uid[0] = '\0'; if (p_format->uid_output) { if (entry->uid >= 0) { - snprintf(uid, sizeof(uid), "%5d:", entry->uid); + const struct android_id_info *info = android_ids; + size_t i; + + for (i = 0; i < android_id_count; ++i) { + if (info->aid == (unsigned int)entry->uid) { + break; + } + ++info; + } + if ((i < android_id_count) && (strlen(info->name) <= 5)) { + snprintf(uid, sizeof(uid), "%5s:", info->name); + } else { + // Not worth parsing package list, names all longer than 5 + snprintf(uid, sizeof(uid), "%5d:", entry->uid); + } } else { snprintf(uid, sizeof(uid), " "); }