diff options
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/app_process/app_main.cpp | 10 | ||||
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 16 | ||||
-rw-r--r-- | cmds/incident/main.cpp | 10 | ||||
-rw-r--r-- | cmds/incident_helper/src/TextParserBase.cpp | 8 | ||||
-rw-r--r-- | cmds/incident_helper/src/main.cpp | 2 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/BatteryTypeParser.cpp | 4 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/CpuFreqParser.cpp | 4 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/CpuInfoParser.cpp | 10 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/EventLogTagsParser.cpp | 4 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/KernelWakesParser.cpp | 10 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp | 4 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/ProcrankParser.cpp | 8 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/PsParser.cpp | 10 | ||||
-rw-r--r-- | cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp | 4 | ||||
-rw-r--r-- | cmds/incidentd/src/IncidentService.cpp | 24 | ||||
-rw-r--r-- | cmds/incidentd/src/Reporter.cpp | 4 | ||||
-rw-r--r-- | cmds/incidentd/src/Section.cpp | 76 | ||||
-rw-r--r-- | cmds/incidentd/src/report_directory.cpp | 6 |
18 files changed, 107 insertions, 107 deletions
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp index 66248128ff29..a040b572a003 100644 --- a/cmds/app_process/app_main.cpp +++ b/cmds/app_process/app_main.cpp @@ -66,10 +66,10 @@ public: * executing boot class Java code and thereby deny ourselves access to * non-boot classes. */ - char* slashClassName = toSlashClassName(mClassName.string()); + char* slashClassName = toSlashClassName(mClassName.c_str()); mClass = env->FindClass(slashClassName); if (mClass == NULL) { - ALOGE("ERROR: could not find class '%s'\n", mClassName.string()); + ALOGE("ERROR: could not find class '%s'\n", mClassName.c_str()); } free(slashClassName); @@ -179,7 +179,7 @@ int main(int argc, char* const argv[]) argv_String.append(argv[i]); argv_String.append("\" "); } - ALOGV("app_process main with argv: %s", argv_String.string()); + ALOGV("app_process main with argv: %s", argv_String.c_str()); } AppRuntime runtime(argv[0], computeArgBlockSize(argc, argv)); @@ -300,7 +300,7 @@ int main(int argc, char* const argv[]) restOfArgs.append(argv_new[k]); restOfArgs.append("\" "); } - ALOGV("Class name = %s, args = %s", className.string(), restOfArgs.string()); + ALOGV("Class name = %s, args = %s", className.c_str(), restOfArgs.c_str()); } } else { // We're in zygote mode. @@ -329,7 +329,7 @@ int main(int argc, char* const argv[]) } if (!niceName.empty()) { - runtime.setArgv0(niceName.string(), true /* setProcName */); + runtime.setArgv0(niceName.c_str(), true /* setProcName */); } if (zygote) { diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 74ca41d0f9b4..4690f3386616 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -1137,7 +1137,7 @@ bool BootAnimation::parseAnimationDesc(Animation& animation) { if (!readFile(animation.zip, "desc.txt", desString)) { return false; } - char const* s = desString.string(); + char const* s = desString.c_str(); std::string dynamicColoringPartName = ""; bool postDynamicColoring = false; @@ -1146,7 +1146,7 @@ bool BootAnimation::parseAnimationDesc(Animation& animation) { const char* endl = strstr(s, "\n"); if (endl == nullptr) break; String8 line(s, endl - s); - const char* l = line.string(); + const char* l = line.c_str(); int fps = 0; int width = 0; int height = 0; @@ -1330,7 +1330,7 @@ bool BootAnimation::preloadZip(Animation& animation) { // If there is trimData present, override the positioning defaults. for (Animation::Part& part : animation.parts) { - const char* trimDataStr = part.trimData.string(); + const char* trimDataStr = part.trimData.c_str(); for (size_t frameIdx = 0; frameIdx < part.frames.size(); frameIdx++) { const char* endl = strstr(trimDataStr, "\n"); // No more trimData for this part. @@ -1338,7 +1338,7 @@ bool BootAnimation::preloadZip(Animation& animation) { break; } String8 line(trimDataStr, endl - trimDataStr); - const char* lineStr = line.string(); + const char* lineStr = line.c_str(); trimDataStr = ++endl; int width = 0, height = 0, x = 0, y = 0; if (sscanf(lineStr, "%dx%d+%d+%d", &width, &height, &x, &y) == 4) { @@ -1566,7 +1566,7 @@ bool BootAnimation::playAnimation(const Animation& animation) { 1.0f); ALOGD("Playing files = %s/%s, Requested repeat = %d, playUntilComplete = %s", - animation.fileName.string(), part.path.string(), part.count, + animation.fileName.c_str(), part.path.c_str(), part.count, part.playUntilComplete ? "true" : "false"); // For the last animation, if we have progress indicator from @@ -1787,17 +1787,17 @@ void BootAnimation::releaseAnimation(Animation* animation) const { BootAnimation::Animation* BootAnimation::loadAnimation(const String8& fn) { if (mLoadedFiles.indexOf(fn) >= 0) { SLOGE("File \"%s\" is already loaded. Cyclic ref is not allowed", - fn.string()); + fn.c_str()); return nullptr; } ZipFileRO *zip = ZipFileRO::open(fn); if (zip == nullptr) { SLOGE("Failed to open animation zip \"%s\": %s", - fn.string(), strerror(errno)); + fn.c_str(), strerror(errno)); return nullptr; } - ALOGD("%s is loaded successfully", fn.string()); + ALOGD("%s is loaded successfully", fn.c_str()); Animation *animation = new Animation; animation->fileName = fn; diff --git a/cmds/incident/main.cpp b/cmds/incident/main.cpp index 6e0bd0629274..0d9f4e92662b 100644 --- a/cmds/incident/main.cpp +++ b/cmds/incident/main.cpp @@ -83,8 +83,8 @@ StatusListener::onReportSectionStatus(int32_t section, int32_t status) Status StatusListener::onReportServiceStatus(const String16& service, int32_t status) { - fprintf(stderr, "service '%s' status %d\n", String8(service).string(), status); - ALOGD("service '%s' status %d\n", String8(service).string(), status); + fprintf(stderr, "service '%s' status %d\n", String8(service).c_str(), status); + ALOGD("service '%s' status %d\n", String8(service).c_str(), status); return Status::ok(); } @@ -384,7 +384,7 @@ main(int argc, char** argv) status = service->reportIncidentToStream(args, listener, std::move(writeEnd)); if (!status.isOk()) { - fprintf(stderr, "reportIncident returned \"%s\"\n", status.toString8().string()); + fprintf(stderr, "reportIncident returned \"%s\"\n", status.toString8().c_str()); return 1; } @@ -396,14 +396,14 @@ main(int argc, char** argv) sp<StatusListener> listener(new StatusListener()); status = service->reportIncidentToDumpstate(std::move(writeEnd), listener); if (!status.isOk()) { - fprintf(stderr, "reportIncident returned \"%s\"\n", status.toString8().string()); + fprintf(stderr, "reportIncident returned \"%s\"\n", status.toString8().c_str()); return 1; } return listener->getExitCodeOrElse(stream_output(fds[0], STDOUT_FILENO)); } else { status = service->reportIncident(args); if (!status.isOk()) { - fprintf(stderr, "reportIncident returned \"%s\"\n", status.toString8().string()); + fprintf(stderr, "reportIncident returned \"%s\"\n", status.toString8().c_str()); return 1; } else { return 0; diff --git a/cmds/incident_helper/src/TextParserBase.cpp b/cmds/incident_helper/src/TextParserBase.cpp index e9bc70f37026..e625afa626ec 100644 --- a/cmds/incident_helper/src/TextParserBase.cpp +++ b/cmds/incident_helper/src/TextParserBase.cpp @@ -27,11 +27,11 @@ status_t NoopParser::Parse(const int in, const int out) const { string content; if (!ReadFdToString(in, &content)) { - fprintf(stderr, "[%s]Failed to read data from incidentd\n", this->name.string()); + fprintf(stderr, "[%s]Failed to read data from incidentd\n", this->name.c_str()); return -1; } if (!WriteStringToFd(content, out)) { - fprintf(stderr, "[%s]Failed to write data to incidentd\n", this->name.string()); + fprintf(stderr, "[%s]Failed to write data to incidentd\n", this->name.c_str()); return -1; } return NO_ERROR; @@ -42,13 +42,13 @@ status_t ReverseParser::Parse(const int in, const int out) const { string content; if (!ReadFdToString(in, &content)) { - fprintf(stderr, "[%s]Failed to read data from incidentd\n", this->name.string()); + fprintf(stderr, "[%s]Failed to read data from incidentd\n", this->name.c_str()); return -1; } // reverse the content reverse(content.begin(), content.end()); if (!WriteStringToFd(content, out)) { - fprintf(stderr, "[%s]Failed to write data to incidentd\n", this->name.string()); + fprintf(stderr, "[%s]Failed to write data to incidentd\n", this->name.c_str()); return -1; } return NO_ERROR; diff --git a/cmds/incident_helper/src/main.cpp b/cmds/incident_helper/src/main.cpp index ff5fd86cf11e..cc03d4a65f17 100644 --- a/cmds/incident_helper/src/main.cpp +++ b/cmds/incident_helper/src/main.cpp @@ -101,7 +101,7 @@ int main(int argc, char** argv) { fprintf(stderr, "Pasring section %d...\n", sectionID); TextParserBase* parser = selectParser(sectionID); if (parser != nullptr) { - fprintf(stderr, "Running parser: %s\n", parser->name.string()); + fprintf(stderr, "Running parser: %s\n", parser->name.c_str()); status_t err = parser->Parse(STDIN_FILENO, STDOUT_FILENO); if (err != NO_ERROR) { fprintf(stderr, "Parse error in section %d: %s\n", sectionID, strerror(-err)); diff --git a/cmds/incident_helper/src/parsers/BatteryTypeParser.cpp b/cmds/incident_helper/src/parsers/BatteryTypeParser.cpp index ced6cf807e0d..2a032fbf3aa6 100644 --- a/cmds/incident_helper/src/parsers/BatteryTypeParser.cpp +++ b/cmds/incident_helper/src/parsers/BatteryTypeParser.cpp @@ -52,9 +52,9 @@ BatteryTypeParser::Parse(const int in, const int out) const } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incident_helper/src/parsers/CpuFreqParser.cpp b/cmds/incident_helper/src/parsers/CpuFreqParser.cpp index 43a12f603ba3..c9bf4c528109 100644 --- a/cmds/incident_helper/src/parsers/CpuFreqParser.cpp +++ b/cmds/incident_helper/src/parsers/CpuFreqParser.cpp @@ -82,9 +82,9 @@ CpuFreqParser::Parse(const int in, const int out) const } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incident_helper/src/parsers/CpuInfoParser.cpp b/cmds/incident_helper/src/parsers/CpuInfoParser.cpp index 5d525e6c7f3e..77751a2fdfc0 100644 --- a/cmds/incident_helper/src/parsers/CpuInfoParser.cpp +++ b/cmds/incident_helper/src/parsers/CpuInfoParser.cpp @@ -130,11 +130,11 @@ CpuInfoParser::Parse(const int in, const int out) const record = parseRecordByColumns(line, columnIndices); diff = record.size() - header.size(); if (diff < 0) { - fprintf(stderr, "[%s]Line %d has %d missing fields\n%s\n", this->name.string(), nline, -diff, line.c_str()); + fprintf(stderr, "[%s]Line %d has %d missing fields\n%s\n", this->name.c_str(), nline, -diff, line.c_str()); printRecord(record); continue; } else if (diff > 0) { - fprintf(stderr, "[%s]Line %d has %d extra fields\n%s\n", this->name.string(), nline, diff, line.c_str()); + fprintf(stderr, "[%s]Line %d has %d extra fields\n%s\n", this->name.c_str(), nline, diff, line.c_str()); printRecord(record); continue; } @@ -143,7 +143,7 @@ CpuInfoParser::Parse(const int in, const int out) const for (int i=0; i<(int)record.size(); i++) { if (!table.insertField(&proto, header[i], record[i])) { fprintf(stderr, "[%s]Line %d fails to insert field %s with value %s\n", - this->name.string(), nline, header[i].c_str(), record[i].c_str()); + this->name.c_str(), nline, header[i].c_str(), record[i].c_str()); } } proto.end(token); @@ -155,9 +155,9 @@ CpuInfoParser::Parse(const int in, const int out) const } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incident_helper/src/parsers/EventLogTagsParser.cpp b/cmds/incident_helper/src/parsers/EventLogTagsParser.cpp index 4fd6b068cf1e..0474a5055bf2 100644 --- a/cmds/incident_helper/src/parsers/EventLogTagsParser.cpp +++ b/cmds/incident_helper/src/parsers/EventLogTagsParser.cpp @@ -76,9 +76,9 @@ EventLogTagsParser::Parse(const int in, const int out) const } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incident_helper/src/parsers/KernelWakesParser.cpp b/cmds/incident_helper/src/parsers/KernelWakesParser.cpp index 85beaf06eeb8..d16c23cce29b 100644 --- a/cmds/incident_helper/src/parsers/KernelWakesParser.cpp +++ b/cmds/incident_helper/src/parsers/KernelWakesParser.cpp @@ -51,11 +51,11 @@ KernelWakesParser::Parse(const int in, const int out) const if (record.size() < header.size()) { // TODO: log this to incident report! - fprintf(stderr, "[%s]Line %d has missing fields\n%s\n", this->name.string(), nline, line.c_str()); + fprintf(stderr, "[%s]Line %d has missing fields\n%s\n", this->name.c_str(), nline, line.c_str()); continue; } else if (record.size() > header.size()) { // TODO: log this to incident report! - fprintf(stderr, "[%s]Line %d has extra fields\n%s\n", this->name.string(), nline, line.c_str()); + fprintf(stderr, "[%s]Line %d has extra fields\n%s\n", this->name.c_str(), nline, line.c_str()); continue; } @@ -63,7 +63,7 @@ KernelWakesParser::Parse(const int in, const int out) const for (int i=0; i<(int)record.size(); i++) { if (!table.insertField(&proto, header[i], record[i])) { fprintf(stderr, "[%s]Line %d has bad value %s of %s\n", - this->name.string(), nline, header[i].c_str(), record[i].c_str()); + this->name.c_str(), nline, header[i].c_str(), record[i].c_str()); } } proto.end(token); @@ -75,9 +75,9 @@ KernelWakesParser::Parse(const int in, const int out) const } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp b/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp index 2a89c920c119..36710dfea8f1 100644 --- a/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp +++ b/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp @@ -114,10 +114,10 @@ PageTypeInfoParser::Parse(const int in, const int out) const } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incident_helper/src/parsers/ProcrankParser.cpp b/cmds/incident_helper/src/parsers/ProcrankParser.cpp index 4763b482e368..997d2e50a14b 100644 --- a/cmds/incident_helper/src/parsers/ProcrankParser.cpp +++ b/cmds/incident_helper/src/parsers/ProcrankParser.cpp @@ -60,7 +60,7 @@ ProcrankParser::Parse(const int in, const int out) const if (record[record.size() - 1] == "TOTAL") { // TOTAL record total = line; } else { - fprintf(stderr, "[%s]Line %d has missing fields\n%s\n", this->name.string(), nline, + fprintf(stderr, "[%s]Line %d has missing fields\n%s\n", this->name.c_str(), nline, line.c_str()); } continue; @@ -70,7 +70,7 @@ ProcrankParser::Parse(const int in, const int out) const for (int i=0; i<(int)record.size(); i++) { if (!table.insertField(&proto, header[i], record[i])) { fprintf(stderr, "[%s]Line %d has bad value %s of %s\n", - this->name.string(), nline, header[i].c_str(), record[i].c_str()); + this->name.c_str(), nline, header[i].c_str(), record[i].c_str()); } } proto.end(token); @@ -104,9 +104,9 @@ ProcrankParser::Parse(const int in, const int out) const } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incident_helper/src/parsers/PsParser.cpp b/cmds/incident_helper/src/parsers/PsParser.cpp index d3cb4be59f66..55aa555794c0 100644 --- a/cmds/incident_helper/src/parsers/PsParser.cpp +++ b/cmds/incident_helper/src/parsers/PsParser.cpp @@ -61,12 +61,12 @@ status_t PsParser::Parse(const int in, const int out) const { diff = record.size() - header.size(); if (diff < 0) { // TODO: log this to incident report! - fprintf(stderr, "[%s]Line %d has %d missing fields\n%s\n", this->name.string(), nline, -diff, line.c_str()); + fprintf(stderr, "[%s]Line %d has %d missing fields\n%s\n", this->name.c_str(), nline, -diff, line.c_str()); printRecord(record); continue; } else if (diff > 0) { // TODO: log this to incident report! - fprintf(stderr, "[%s]Line %d has %d extra fields\n%s\n", this->name.string(), nline, diff, line.c_str()); + fprintf(stderr, "[%s]Line %d has %d extra fields\n%s\n", this->name.c_str(), nline, diff, line.c_str()); printRecord(record); continue; } @@ -75,7 +75,7 @@ status_t PsParser::Parse(const int in, const int out) const { for (int i=0; i<(int)record.size(); i++) { if (!table.insertField(&proto, header[i], record[i])) { fprintf(stderr, "[%s]Line %d has bad value %s of %s\n", - this->name.string(), nline, header[i].c_str(), record[i].c_str()); + this->name.c_str(), nline, header[i].c_str(), record[i].c_str()); } } proto.end(token); @@ -87,9 +87,9 @@ status_t PsParser::Parse(const int in, const int out) const { } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp b/cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp index eba536bd9e9c..86c34bc25bd8 100644 --- a/cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp +++ b/cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp @@ -219,9 +219,9 @@ SystemPropertiesParser::Parse(const int in, const int out) const } if (!proto.flush(out)) { - fprintf(stderr, "[%s]Error writing proto back\n", this->name.string()); + fprintf(stderr, "[%s]Error writing proto back\n", this->name.c_str()); return -1; } - fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size()); + fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.c_str(), proto.size()); return NO_ERROR; } diff --git a/cmds/incidentd/src/IncidentService.cpp b/cmds/incidentd/src/IncidentService.cpp index 05a43ad7d936..53c7b744ee0f 100644 --- a/cmds/incidentd/src/IncidentService.cpp +++ b/cmds/incidentd/src/IncidentService.cpp @@ -407,8 +407,8 @@ Status IncidentService::systemRunning() { Status IncidentService::getIncidentReportList(const String16& pkg16, const String16& cls16, vector<String16>* result) { status_t err; - const string pkg(String8(pkg16).string()); - const string cls(String8(cls16).string()); + const string pkg(String8(pkg16).c_str()); + const string cls(String8(cls16).c_str()); // List the reports vector<sp<ReportFile>> all; @@ -441,9 +441,9 @@ Status IncidentService::getIncidentReport(const String16& pkg16, const String16& const String16& id16, IncidentManager::IncidentReport* result) { status_t err; - const string pkg(String8(pkg16).string()); - const string cls(String8(cls16).string()); - const string id(String8(id16).string()); + const string pkg(String8(pkg16).c_str()); + const string cls(String8(cls16).c_str()); + const string id(String8(id16).c_str()); IncidentReportArgs args; sp<ReportFile> file = mWorkDirectory->getReport(pkg, cls, id, &args); @@ -470,9 +470,9 @@ Status IncidentService::getIncidentReport(const String16& pkg16, const String16& Status IncidentService::deleteIncidentReports(const String16& pkg16, const String16& cls16, const String16& id16) { - const string pkg(String8(pkg16).string()); - const string cls(String8(cls16).string()); - const string id(String8(id16).string()); + const string pkg(String8(pkg16).c_str()); + const string cls(String8(cls16).c_str()); + const string id(String8(id16).c_str()); sp<ReportFile> file = mWorkDirectory->getReport(pkg, cls, id, nullptr); if (file != nullptr) { @@ -484,7 +484,7 @@ Status IncidentService::deleteIncidentReports(const String16& pkg16, const Strin } Status IncidentService::deleteAllIncidentReports(const String16& pkg16) { - const string pkg(String8(pkg16).string()); + const string pkg(String8(pkg16).c_str()); mWorkDirectory->commitAll(pkg); mBroadcaster->clearPackageBroadcasts(pkg); @@ -568,7 +568,7 @@ status_t IncidentService::command(FILE* in, FILE* out, FILE* err, Vector<String8 while (SECTION_LIST[idx] != NULL) { const Section* section = SECTION_LIST[idx]; if (section->id == id) { - fprintf(out, "Section[%d] %s\n", id, section->name.string()); + fprintf(out, "Section[%d] %s\n", id, section->name.c_str()); break; } idx++; @@ -592,7 +592,7 @@ status_t IncidentService::cmd_help(FILE* out) { static void printPrivacy(const Privacy* p, FILE* out, String8 indent) { if (p == NULL) return; - fprintf(out, "%sid:%d, type:%d, dest:%d\n", indent.string(), p->field_id, p->type, p->policy); + fprintf(out, "%sid:%d, type:%d, dest:%d\n", indent.c_str(), p->field_id, p->type, p->policy); if (p->children == NULL) return; for (int i = 0; p->children[i] != NULL; i++) { // NULL-terminated. printPrivacy(p->children[i], out, indent + " "); @@ -605,7 +605,7 @@ status_t IncidentService::cmd_privacy(FILE* in, FILE* out, FILE* err, Vector<Str const int argCount = args.size(); if (argCount >= 3) { String8 opt = args[1]; - int sectionId = atoi(args[2].string()); + int sectionId = atoi(args[2].c_str()); const Privacy* p = get_privacy_of_section(sectionId); if (p == NULL) { diff --git a/cmds/incidentd/src/Reporter.cpp b/cmds/incidentd/src/Reporter.cpp index 86a78f095f52..c9cf7275a821 100644 --- a/cmds/incidentd/src/Reporter.cpp +++ b/cmds/incidentd/src/Reporter.cpp @@ -711,7 +711,7 @@ status_t Reporter::execute_section(const Section* section, IncidentMetadata* met return NO_ERROR; } - ALOGD("Start incident report section %d '%s'", sectionId, section->name.string()); + ALOGD("Start incident report section %d '%s'", sectionId, section->name.c_str()); IncidentMetadata::SectionStats* sectionMetadata = metadata->add_sections(); // Notify listener of starting @@ -747,7 +747,7 @@ status_t Reporter::execute_section(const Section* section, IncidentMetadata* met sectionId, IIncidentReportStatusListener::STATUS_FINISHED); }); - ALOGD("Finish incident report section %d '%s'", sectionId, section->name.string()); + ALOGD("Finish incident report section %d '%s'", sectionId, section->name.c_str()); return NO_ERROR; } diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp index 581367a75804..c2aa26948146 100644 --- a/cmds/incidentd/src/Section.cpp +++ b/cmds/incidentd/src/Section.cpp @@ -60,7 +60,7 @@ const char INCIDENT_HELPER[] = "/system/bin/incident_helper"; const char* GZIP[] = {"/system/bin/gzip", NULL}; static pid_t fork_execute_incident_helper(const int id, Fpipe* p2cPipe, Fpipe* c2pPipe) { - const char* ihArgs[]{INCIDENT_HELPER, "-s", String8::format("%d", id).string(), NULL}; + const char* ihArgs[]{INCIDENT_HELPER, "-s", String8::format("%d", id).c_str(), NULL}; return fork_execute_cmd(const_cast<char**>(ihArgs), p2cPipe, c2pPipe); } @@ -100,7 +100,7 @@ status_t FileSection::Execute(ReportWriter* writer) const { // add O_CLOEXEC to make sure it is closed when exec incident helper unique_fd fd(open(mFilename, O_RDONLY | O_CLOEXEC)); if (fd.get() == -1) { - ALOGW("[%s] failed to open file", this->name.string()); + ALOGW("[%s] failed to open file", this->name.c_str()); // There may be some devices/architectures that won't have the file. // Just return here without an error. return NO_ERROR; @@ -110,13 +110,13 @@ status_t FileSection::Execute(ReportWriter* writer) const { Fpipe c2pPipe; // initiate pipes to pass data to/from incident_helper if (!p2cPipe.init() || !c2pPipe.init()) { - ALOGW("[%s] failed to setup pipes", this->name.string()); + ALOGW("[%s] failed to setup pipes", this->name.c_str()); return -errno; } pid_t pid = fork_execute_incident_helper(this->id, &p2cPipe, &c2pPipe); if (pid == -1) { - ALOGW("[%s] failed to fork", this->name.string()); + ALOGW("[%s] failed to fork", this->name.c_str()); return -errno; } @@ -128,14 +128,14 @@ status_t FileSection::Execute(ReportWriter* writer) const { writer->setSectionStats(buffer); if (readStatus != NO_ERROR || buffer.timedOut()) { ALOGW("[%s] failed to read data from incident helper: %s, timedout: %s", - this->name.string(), strerror(-readStatus), buffer.timedOut() ? "true" : "false"); + this->name.c_str(), strerror(-readStatus), buffer.timedOut() ? "true" : "false"); kill_child(pid); return readStatus; } status_t ihStatus = wait_child(pid); if (ihStatus != NO_ERROR) { - ALOGW("[%s] abnormal child process: %s", this->name.string(), strerror(-ihStatus)); + ALOGW("[%s] abnormal child process: %s", this->name.c_str(), strerror(-ihStatus)); return OK; // Not a fatal error. } @@ -169,7 +169,7 @@ status_t GZipSection::Execute(ReportWriter* writer) const { index++; // look at the next file. } if (fd.get() == -1) { - ALOGW("[%s] can't open all the files", this->name.string()); + ALOGW("[%s] can't open all the files", this->name.c_str()); return NO_ERROR; // e.g. LAST_KMSG will reach here in user build. } FdBuffer buffer; @@ -177,13 +177,13 @@ status_t GZipSection::Execute(ReportWriter* writer) const { Fpipe c2pPipe; // initiate pipes to pass data to/from gzip if (!p2cPipe.init() || !c2pPipe.init()) { - ALOGW("[%s] failed to setup pipes", this->name.string()); + ALOGW("[%s] failed to setup pipes", this->name.c_str()); return -errno; } pid_t pid = fork_execute_cmd((char* const*)GZIP, &p2cPipe, &c2pPipe); if (pid == -1) { - ALOGW("[%s] failed to fork", this->name.string()); + ALOGW("[%s] failed to fork", this->name.c_str()); return -errno; } // parent process @@ -202,14 +202,14 @@ status_t GZipSection::Execute(ReportWriter* writer) const { size_t editPos = internalBuffer->wp()->pos(); internalBuffer->wp()->move(8); // reserve 8 bytes for the varint of the data size. size_t dataBeginAt = internalBuffer->wp()->pos(); - VLOG("[%s] editPos=%zu, dataBeginAt=%zu", this->name.string(), editPos, dataBeginAt); + VLOG("[%s] editPos=%zu, dataBeginAt=%zu", this->name.c_str(), editPos, dataBeginAt); status_t readStatus = buffer.readProcessedDataInStream( fd.get(), std::move(p2cPipe.writeFd()), std::move(c2pPipe.readFd()), this->timeoutMs, isSysfs(mFilenames[index])); writer->setSectionStats(buffer); if (readStatus != NO_ERROR || buffer.timedOut()) { - ALOGW("[%s] failed to read data from gzip: %s, timedout: %s", this->name.string(), + ALOGW("[%s] failed to read data from gzip: %s, timedout: %s", this->name.c_str(), strerror(-readStatus), buffer.timedOut() ? "true" : "false"); kill_child(pid); return readStatus; @@ -217,7 +217,7 @@ status_t GZipSection::Execute(ReportWriter* writer) const { status_t gzipStatus = wait_child(pid); if (gzipStatus != NO_ERROR) { - ALOGW("[%s] abnormal child process: %s", this->name.string(), strerror(-gzipStatus)); + ALOGW("[%s] abnormal child process: %s", this->name.c_str(), strerror(-gzipStatus)); return gzipStatus; } // Revisit the actual size from gzip result and edit the internal buffer accordingly. @@ -290,7 +290,7 @@ status_t WorkerThreadSection::Execute(ReportWriter* writer) const { FdBuffer buffer; err = buffer.read(data->pipe.readFd().get(), this->timeoutMs); if (err != NO_ERROR) { - ALOGE("[%s] reader failed with error '%s'", this->name.string(), strerror(-err)); + ALOGE("[%s] reader failed with error '%s'", this->name.c_str(), strerror(-err)); } // If the worker side is finished, then return its error (which may overwrite @@ -300,7 +300,7 @@ status_t WorkerThreadSection::Execute(ReportWriter* writer) const { data->pipe.close(); if (data->workerError != NO_ERROR) { err = data->workerError; - ALOGE("[%s] worker failed with error '%s'", this->name.string(), strerror(-err)); + ALOGE("[%s] worker failed with error '%s'", this->name.c_str(), strerror(-err)); } workerDone = data->workerDone; } @@ -309,17 +309,17 @@ status_t WorkerThreadSection::Execute(ReportWriter* writer) const { if (err != NO_ERROR) { char errMsg[128]; snprintf(errMsg, 128, "[%s] failed with error '%s'", - this->name.string(), strerror(-err)); + this->name.c_str(), strerror(-err)); writer->error(this, err, "WorkerThreadSection failed."); return NO_ERROR; } if (buffer.truncated()) { - ALOGW("[%s] too large, truncating", this->name.string()); + ALOGW("[%s] too large, truncating", this->name.c_str()); // Do not write a truncated section. It won't pass through the PrivacyFilter. return NO_ERROR; } if (!workerDone || buffer.timedOut()) { - ALOGW("[%s] timed out", this->name.string()); + ALOGW("[%s] timed out", this->name.c_str()); return NO_ERROR; } @@ -360,18 +360,18 @@ status_t CommandSection::Execute(ReportWriter* writer) const { Fpipe ihPipe; if (!cmdPipe.init() || !ihPipe.init()) { - ALOGW("[%s] failed to setup pipes", this->name.string()); + ALOGW("[%s] failed to setup pipes", this->name.c_str()); return -errno; } pid_t cmdPid = fork_execute_cmd((char* const*)mCommand, NULL, &cmdPipe); if (cmdPid == -1) { - ALOGW("[%s] failed to fork", this->name.string()); + ALOGW("[%s] failed to fork", this->name.c_str()); return -errno; } pid_t ihPid = fork_execute_incident_helper(this->id, &cmdPipe, &ihPipe); if (ihPid == -1) { - ALOGW("[%s] failed to fork", this->name.string()); + ALOGW("[%s] failed to fork", this->name.c_str()); return -errno; } @@ -381,7 +381,7 @@ status_t CommandSection::Execute(ReportWriter* writer) const { writer->setSectionStats(buffer); if (readStatus != NO_ERROR || buffer.timedOut()) { ALOGW("[%s] failed to read data from incident helper: %s, timedout: %s", - this->name.string(), strerror(-readStatus), buffer.timedOut() ? "true" : "false"); + this->name.c_str(), strerror(-readStatus), buffer.timedOut() ? "true" : "false"); kill_child(cmdPid); kill_child(ihPid); return readStatus; @@ -393,7 +393,7 @@ status_t CommandSection::Execute(ReportWriter* writer) const { status_t ihStatus = wait_child(ihPid); if (cmdStatus != NO_ERROR || ihStatus != NO_ERROR) { ALOGW("[%s] abnormal child processes, return status: command: %s, incident helper: %s", - this->name.string(), strerror(-cmdStatus), strerror(-ihStatus)); + this->name.c_str(), strerror(-cmdStatus), strerror(-ihStatus)); // Not a fatal error. return NO_ERROR; } @@ -428,7 +428,7 @@ status_t DumpsysSection::BlockingCall(unique_fd& pipeWriteFd) const { sp<IBinder> service = defaultServiceManager()->checkService(mService); if (service == NULL) { - ALOGW("DumpsysSection: Can't lookup service: %s", String8(mService).string()); + ALOGW("DumpsysSection: Can't lookup service: %s", String8(mService).c_str()); return NAME_NOT_FOUND; } @@ -463,14 +463,14 @@ status_t TextDumpsysSection::Execute(ReportWriter* writer) const { // checkService won't wait for the service to show up like getService will. sp<IBinder> service = defaultServiceManager()->checkService(mService); if (service == NULL) { - ALOGW("TextDumpsysSection: Can't lookup service: %s", String8(mService).string()); + ALOGW("TextDumpsysSection: Can't lookup service: %s", String8(mService).c_str()); return NAME_NOT_FOUND; } // Create pipe Fpipe dumpPipe; if (!dumpPipe.init()) { - ALOGW("[%s] failed to setup pipe", this->name.string()); + ALOGW("[%s] failed to setup pipe", this->name.c_str()); return -errno; } @@ -482,7 +482,7 @@ status_t TextDumpsysSection::Execute(ReportWriter* writer) const { signal(SIGPIPE, sigpipe_handler); status_t err = service->dump(write_fd.get(), this->mArgs); if (err != OK) { - ALOGW("[%s] dump thread failed. Error: %s", this->name.string(), strerror(-err)); + ALOGW("[%s] dump thread failed. Error: %s", this->name.c_str(), strerror(-err)); } write_fd.reset(); }); @@ -490,7 +490,7 @@ status_t TextDumpsysSection::Execute(ReportWriter* writer) const { // Collect dump content FdBuffer buffer; ProtoOutputStream proto; - proto.write(TextDumpProto::COMMAND, std::string(name.string())); + proto.write(TextDumpProto::COMMAND, std::string(name.c_str())); proto.write(TextDumpProto::DUMP_DURATION_NS, int64_t(Nanotime() - start)); buffer.write(proto.data()); @@ -504,7 +504,7 @@ status_t TextDumpsysSection::Execute(ReportWriter* writer) const { dumpPipe.readFd().reset(); writer->setSectionStats(buffer); if (readStatus != OK || buffer.timedOut()) { - ALOGW("[%s] failed to read from dumpsys: %s, timedout: %s", this->name.string(), + ALOGW("[%s] failed to read from dumpsys: %s, timedout: %s", this->name.c_str(), strerror(-readStatus), buffer.timedOut() ? "true" : "false"); worker.detach(); return readStatus; @@ -579,7 +579,7 @@ status_t LogSection::BlockingCall(unique_fd& pipeWriteFd) const { // Hence forking a new process to prevent memory fragmentation. pid_t pid = fork(); if (pid < 0) { - ALOGW("[%s] failed to fork", this->name.string()); + ALOGW("[%s] failed to fork", this->name.c_str()); return errno; } if (pid > 0) { @@ -593,7 +593,7 @@ status_t LogSection::BlockingCall(unique_fd& pipeWriteFd) const { android_logger_list_free); if (android_logger_open(loggers.get(), mLogID) == NULL) { - ALOGE("[%s] Can't get logger.", this->name.string()); + ALOGE("[%s] Can't get logger.", this->name.c_str()); _exit(EXIT_FAILURE); } @@ -610,7 +610,7 @@ status_t LogSection::BlockingCall(unique_fd& pipeWriteFd) const { // status = -EAGAIN, graceful indication for ANDRODI_LOG_NONBLOCK that this is the end. if (status <= 0) { if (status != -EAGAIN) { - ALOGW("[%s] fails to read a log_msg.\n", this->name.string()); + ALOGW("[%s] fails to read a log_msg.\n", this->name.c_str()); err = -status; } break; @@ -680,7 +680,7 @@ status_t LogSection::BlockingCall(unique_fd& pipeWriteFd) const { AndroidLogEntry entry; status = android_log_processLogBuffer(&msg.entry, &entry); if (status != OK) { - ALOGW("[%s] fails to process to an entry.\n", this->name.string()); + ALOGW("[%s] fails to process to an entry.\n", this->name.c_str()); err = status; break; } @@ -702,7 +702,7 @@ status_t LogSection::BlockingCall(unique_fd& pipeWriteFd) const { } if (!proto.flush(pipeWriteFd.get())) { if (errno == EPIPE) { - ALOGW("[%s] wrote to a broken pipe\n", this->name.string()); + ALOGW("[%s] wrote to a broken pipe\n", this->name.c_str()); } err = errno; break; @@ -757,7 +757,7 @@ status_t TombstoneSection::BlockingCall(unique_fd& pipeWriteFd) const { } ssize_t exe_name_len = readlink(link_name, exe_name, EXE_NAME_LEN); if (exe_name_len < 0 || exe_name_len >= EXE_NAME_LEN) { - ALOGE("[%s] Can't read '%s': %s", name.string(), link_name, strerror(errno)); + ALOGE("[%s] Can't read '%s': %s", name.c_str(), link_name, strerror(errno)); continue; } // readlink(2) does not put a null terminator at the end @@ -788,7 +788,7 @@ status_t TombstoneSection::BlockingCall(unique_fd& pipeWriteFd) const { Fpipe dumpPipe; if (!dumpPipe.init()) { - ALOGW("[%s] failed to setup dump pipe", this->name.string()); + ALOGW("[%s] failed to setup dump pipe", this->name.c_str()); err = -errno; break; } @@ -822,12 +822,12 @@ status_t TombstoneSection::BlockingCall(unique_fd& pipeWriteFd) const { // Wait on the child to avoid it becoming a zombie process. status_t cStatus = wait_child(child); if (err != NO_ERROR) { - ALOGW("[%s] failed to read stack dump: %d", this->name.string(), err); + ALOGW("[%s] failed to read stack dump: %d", this->name.c_str(), err); dumpPipe.readFd().reset(); break; } if (cStatus != NO_ERROR) { - ALOGE("[%s] child had an issue: %s\n", this->name.string(), strerror(-cStatus)); + ALOGE("[%s] child had an issue: %s\n", this->name.c_str(), strerror(-cStatus)); } // Resize dump buffer @@ -852,7 +852,7 @@ status_t TombstoneSection::BlockingCall(unique_fd& pipeWriteFd) const { dumpPipe.readFd().reset(); if (!proto.flush(pipeWriteFd.get())) { if (errno == EPIPE) { - ALOGE("[%s] wrote to a broken pipe\n", this->name.string()); + ALOGE("[%s] wrote to a broken pipe\n", this->name.c_str()); } err = errno; break; diff --git a/cmds/incidentd/src/report_directory.cpp b/cmds/incidentd/src/report_directory.cpp index 7d20a74437ce..6b2fb8ec308a 100644 --- a/cmds/incidentd/src/report_directory.cpp +++ b/cmds/incidentd/src/report_directory.cpp @@ -62,8 +62,8 @@ void clean_directory(const char* directory, off_t maxSize, size_t maxCount) { continue; } String8 filename = dirbase + entry->d_name; - if (stat(filename.string(), &st) != 0) { - ALOGE("Unable to stat file %s", filename.string()); + if (stat(filename.c_str(), &st) != 0) { + ALOGE("Unable to stat file %s", filename.c_str()); continue; } if (!S_ISREG(st.st_mode)) { @@ -88,7 +88,7 @@ void clean_directory(const char* directory, off_t maxSize, size_t maxCount) { // Remove files until we're under our limits. for (std::vector<std::pair<String8, struct stat>>::iterator it = files.begin(); it != files.end() && totalSize >= maxSize && totalCount >= maxCount; it++) { - remove(it->first.string()); + remove(it->first.c_str()); totalSize -= it->second.st_size; totalCount--; } |