dragon: crash_collector use getpwnam()

Use getpwnam() instead of android_ids[] array.

Bug: 27999086
Change-Id: If66274083bc36d159505bd2a25acb7f17ac40bf7
diff --git a/crash_collector/crash_collector.cc b/crash_collector/crash_collector.cc
index 483b9b1..7cfc7e3 100644
--- a/crash_collector/crash_collector.cc
+++ b/crash_collector/crash_collector.cc
@@ -18,7 +18,9 @@
 
 #include <dirent.h>
 #include <errno.h>
+#include <pwd.h>
 #include <sys/capability.h>
+#include <sys/types.h>
 #include <unistd.h>
 
 #include <string>
@@ -202,13 +204,8 @@
   }
 
   // Username lookup.
-  std::string username;
-  for (size_t i = 0; i < android_id_count; ++i) {
-    if (android_ids[i].aid == appid) {
-      username = android_ids[i].name;
-      break;
-    }
-  }
+  passwd* pwd = getpwuid(appid);
+  std::string username((pwd != NULL) ? pwd->pw_name : "");
   // Delete old crash reports.
   if (!MakeRoomForNewReport()) {
     ALOGE("Failed to delete old crash reports.");