diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp index 66248128ff294cadb6ad82a0ea1e03162776d44b..a040b572a0031eb17bf26f2bb583842fb9518428 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 74ca41d0f9b4593aa9481e3690c18578c4258f46..4690f3386616828b45e3a49b0fae6693a8ce5205 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 6e0bd06292746ef303387e5043b35fd5ac916916..0d9f4e92662b66a904e516bd0c351194d548659d 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 e9bc70f370261e0f7ca60c91c4493551afa3307c..e625afa626ec1fa1f84b218393f12f446d754eda 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 ff5fd86cf11eedd85f9bf4b7848d26df7c779614..cc03d4a65f1789ade1ad5b5de656e4af002d559f 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 ced6cf807e0d9de1b08350952d94a6000a0134ea..2a032fbf3aa60edb9d6dc9d20b939f3798cdf6e7 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 43a12f603ba38dc75cf3bb2ba6ecb2bac7725220..c9bf4c5281092d1eec4b6d7eafb6c5f1162293c6 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 5d525e6c7f3ea941e02bca582c9bf383728bca63..77751a2fdfc0eaa464564ed49a1552eb6a295b25 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 4fd6b068cf1e9cc94a626bd2b1a1698ab9d285e6..0474a5055bf250b5722b3633803cf14f1559060d 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 85beaf06eeb8d1e5ceb7eb1ea2b2069260fd602b..d16c23cce29b59cf8012e95be9838146e0f471db 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 2a89c920c1195595123ac9a6c1286bb2690b9ad6..36710dfea8f1f7e6f25511a97d4fb8cb3cd24de2 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 4763b482e36889308b19bb006fa070ce9a2d51d8..997d2e50a14be1f1fbe8a4a3a26cb6d1c39eb6c2 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 d3cb4be59f66cc5e91fc1734d1dfa757324496f5..55aa555794c09e808240175f98d4ca4ebb2502e8 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 eba536bd9e9cc10a01069c983f192930bd584c53..86c34bc25bd8e3266c5c7fc4a8d7aab5f7aed290 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 05a43ad7d936311d6d395c1abeafb6d835e6d837..53c7b744ee0fc0cfdf0f0654bc7eef31417f1c31 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 86a78f095f52c0cf0bef5cca059ae4ad40d3a999..c9cf7275a8211436399d58753a0107064ee68f91 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 581367a758046933c8253af493a0efc0bb8d6e86..c2aa26948146421c95c0b9a33d962b35cda79a10 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 7d20a74437ce8bb3d752105c7bd0b900f4ba0166..6b2fb8ec308a2252dcd8c284e2749aa0ce2c58c6 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--; } diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp index 21369f9cf5f8c5903c3d5c6d54551041025a3269..d6c559322ef1420e210804ca441e322ed383803c 100644 --- a/core/jni/android_app_NativeActivity.cpp +++ b/core/jni/android_app_NativeActivity.cpp @@ -352,7 +352,7 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName const char* dirStr = env->GetStringUTFChars(internalDataDir, NULL); code->internalDataPathObj = dirStr; - code->internalDataPath = code->internalDataPathObj.string(); + code->internalDataPath = code->internalDataPathObj.c_str(); env->ReleaseStringUTFChars(internalDataDir, dirStr); if (externalDataDir != NULL) { @@ -360,7 +360,7 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName code->externalDataPathObj = dirStr; env->ReleaseStringUTFChars(externalDataDir, dirStr); } - code->externalDataPath = code->externalDataPathObj.string(); + code->externalDataPath = code->externalDataPathObj.c_str(); code->sdkVersion = sdkVersion; @@ -372,7 +372,7 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName code->obbPathObj = dirStr; env->ReleaseStringUTFChars(obbDir, dirStr); } - code->obbPath = code->obbPathObj.string(); + code->obbPath = code->obbPathObj.c_str(); jbyte* rawSavedState = NULL; jsize rawSavedSize = 0; diff --git a/core/jni/android_app_backup_FullBackup.cpp b/core/jni/android_app_backup_FullBackup.cpp index 339a7d30e4072e47e3af3b15b1ba4c9316d1f503..5e096d7623addfb7c1f26b302b59a2310f1e76c8 100644 --- a/core/jni/android_app_backup_FullBackup.cpp +++ b/core/jni/android_app_backup_FullBackup.cpp @@ -106,15 +106,14 @@ static jint backupToTar(JNIEnv* env, jobject clazz, jstring packageNameObj, : NULL; if (path.length() < rootpath.length()) { - ALOGE("file path [%s] shorter than root path [%s]", - path.string(), rootpath.string()); + ALOGE("file path [%s] shorter than root path [%s]", path.c_str(), rootpath.c_str()); return (jint) -1; } off64_t tarSize = 0; jint err = write_tarfile(packageName, domain, rootpath, path, &tarSize, writer); if (!err) { - ALOGI("measured [%s] at %lld", path.string(), (long long)tarSize); + ALOGI("measured [%s] at %lld", path.c_str(), (long long)tarSize); env->CallVoidMethod(dataOutputObj, sFullBackupDataOutput.addSize, (jlong) tarSize); } diff --git a/core/jni/android_backup_BackupDataInput.cpp b/core/jni/android_backup_BackupDataInput.cpp index 79fa2a28666c3726de7728c2e57f78a1f3c509fe..fc081a782b4a6335b14ac5cbf67ca982bd51fc8e 100644 --- a/core/jni/android_backup_BackupDataInput.cpp +++ b/core/jni/android_backup_BackupDataInput.cpp @@ -76,7 +76,7 @@ readNextHeader_native(JNIEnv* env, jobject clazz, jlong r, jobject entity) return err < 0 ? err : -1; } // TODO: Set the fields in the entity object - jstring keyStr = env->NewStringUTF(key.string()); + jstring keyStr = env->NewStringUTF(key.c_str()); env->SetObjectField(entity, s_keyField, keyStr); env->SetIntField(entity, s_dataSizeField, dataSize); return 0; diff --git a/core/jni/android_backup_BackupHelperDispatcher.cpp b/core/jni/android_backup_BackupHelperDispatcher.cpp index efe7d0b6ad0aecf14475f9b5f37f63e058e04ff0..efce8e164817691b2573eeb276eef90ca19a30ee 100644 --- a/core/jni/android_backup_BackupHelperDispatcher.cpp +++ b/core/jni/android_backup_BackupHelperDispatcher.cpp @@ -118,7 +118,7 @@ readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj) } env->SetIntField(headerObj, s_chunkSizeField, flattenedHeader.dataSize); - env->SetObjectField(headerObj, s_keyPrefixField, env->NewStringUTF(keyPrefix.string())); + env->SetObjectField(headerObj, s_keyPrefixField, env->NewStringUTF(keyPrefix.c_str())); return (jint) 0; } diff --git a/core/jni/android_database_CursorWindow.cpp b/core/jni/android_database_CursorWindow.cpp index 2435406937856c7ab3b744f714b2078135f77751..60da2c2abdd9629dfac0b8cc2d27410dddf07aae 100644 --- a/core/jni/android_database_CursorWindow.cpp +++ b/core/jni/android_database_CursorWindow.cpp @@ -58,13 +58,13 @@ static void throwExceptionWithRowCol(JNIEnv* env, jint row, jint column) { msg.appendFormat("Couldn't read row %d, col %d from CursorWindow. " "Make sure the Cursor is initialized correctly before accessing data from it.", row, column); - jniThrowException(env, "java/lang/IllegalStateException", msg.string()); + jniThrowException(env, "java/lang/IllegalStateException", msg.c_str()); } static void throwUnknownTypeException(JNIEnv * env, jint type) { String8 msg; msg.appendFormat("UNKNOWN type %d", type); - jniThrowException(env, "java/lang/IllegalStateException", msg.string()); + jniThrowException(env, "java/lang/IllegalStateException", msg.c_str()); } static int getFdCount() { @@ -107,7 +107,7 @@ static jlong nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint curso fail: jniThrowExceptionFmt(env, "android/database/CursorWindowAllocationException", "Could not allocate CursorWindow '%s' of size %d due to error %d.", - name.string(), cursorWindowSize, status); + name.c_str(), cursorWindowSize, status); return 0; } @@ -139,7 +139,7 @@ static void nativeDispose(JNIEnv* env, jclass clazz, jlong windowPtr) { static jstring nativeGetName(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); - return env->NewStringUTF(window->name().string()); + return env->NewStringUTF(window->name().c_str()); } static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jlong windowPtr, @@ -151,7 +151,7 @@ static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jlong windowPtr, if (status) { String8 msg; msg.appendFormat("Could not write CursorWindow to Parcel due to error %d.", status); - jniThrowRuntimeException(env, msg.string()); + jniThrowRuntimeException(env, msg.c_str()); } } @@ -267,7 +267,7 @@ static jstring nativeGetString(JNIEnv* env, jclass clazz, jlong windowPtr, // doesn't like UTF-8 strings with high codepoints. It actually expects // Modified UTF-8 with encoded surrogate pairs. String16 utf16(value, sizeIncludingNull - 1); - return env->NewString(reinterpret_cast<const jchar*>(utf16.string()), utf16.size()); + return env->NewString(reinterpret_cast<const jchar*>(utf16.c_str()), utf16.size()); } else if (type == CursorWindow::FIELD_TYPE_INTEGER) { int64_t value = window->getFieldSlotValueLong(fieldSlot); char buf[32]; diff --git a/core/jni/android_database_SQLiteCommon.cpp b/core/jni/android_database_SQLiteCommon.cpp index daa20876ba65424f7c279ae8d41baeb06715bb5c..c6a75112d1854324a9799d81de5dcc9a3c5cae0c 100644 --- a/core/jni/android_database_SQLiteCommon.cpp +++ b/core/jni/android_database_SQLiteCommon.cpp @@ -229,7 +229,7 @@ void throw_sqlite3_exception(JNIEnv* env, int errcode, fullMessage.append(": "); fullMessage.append(message); } - jniThrowException(env, exceptionClass, fullMessage.string()); + jniThrowException(env, exceptionClass, fullMessage.c_str()); } else { jniThrowException(env, exceptionClass, message); } diff --git a/core/jni/android_database_SQLiteConnection.cpp b/core/jni/android_database_SQLiteConnection.cpp index 32697aeaa47ffd41b65e915b1fbf3eb3b061bb02..03d3bc6857e449e3a7df3c3a9f914308aa01064c 100644 --- a/core/jni/android_database_SQLiteConnection.cpp +++ b/core/jni/android_database_SQLiteConnection.cpp @@ -91,15 +91,14 @@ struct SQLiteConnection { // Called each time a statement begins execution, when tracing is enabled. static void sqliteTraceCallback(void *data, const char *sql) { SQLiteConnection* connection = static_cast<SQLiteConnection*>(data); - ALOG(LOG_VERBOSE, SQLITE_TRACE_TAG, "%s: \"%s\"\n", - connection->label.string(), sql); + ALOG(LOG_VERBOSE, SQLITE_TRACE_TAG, "%s: \"%s\"\n", connection->label.c_str(), sql); } // Called each time a statement finishes execution, when profiling is enabled. static void sqliteProfileCallback(void *data, const char *sql, sqlite3_uint64 tm) { SQLiteConnection* connection = static_cast<SQLiteConnection*>(data); - ALOG(LOG_VERBOSE, SQLITE_PROFILE_TAG, "%s: \"%s\" took %0.3f ms\n", - connection->label.string(), sql, tm * 0.000001f); + ALOG(LOG_VERBOSE, SQLITE_PROFILE_TAG, "%s: \"%s\" took %0.3f ms\n", connection->label.c_str(), + sql, tm * 0.000001f); } // Called after each SQLite VM instruction when cancelation is enabled. @@ -130,7 +129,7 @@ static jlong nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFla env->ReleaseStringUTFChars(labelStr, labelChars); sqlite3* db; - int err = sqlite3_open_v2(path.string(), &db, sqliteFlags, NULL); + int err = sqlite3_open_v2(path.c_str(), &db, sqliteFlags, NULL); if (err != SQLITE_OK) { throw_sqlite3_exception_errcode(env, err, "Could not open database"); return 0; @@ -180,7 +179,7 @@ static jlong nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFla sqlite3_profile(db, &sqliteProfileCallback, connection); } - ALOGV("Opened connection %p with label '%s'", db, label.string()); + ALOGV("Opened connection %p with label '%s'", db, label.c_str()); return reinterpret_cast<jlong>(connection); } @@ -760,7 +759,7 @@ static jlong nativeExecuteForCursorWindow(JNIEnv* env, jclass clazz, if (status) { String8 msg; msg.appendFormat("Failed to clear the cursor window, status=%d", status); - throw_sqlite3_exception(env, connection->db, msg.string()); + throw_sqlite3_exception(env, connection->db, msg.c_str()); return 0; } @@ -770,7 +769,7 @@ static jlong nativeExecuteForCursorWindow(JNIEnv* env, jclass clazz, String8 msg; msg.appendFormat("Failed to set the cursor window column count to %d, status=%d", numColumns, status); - throw_sqlite3_exception(env, connection->db, msg.string()); + throw_sqlite3_exception(env, connection->db, msg.c_str()); return 0; } @@ -845,7 +844,7 @@ static jlong nativeExecuteForCursorWindow(JNIEnv* env, jclass clazz, String8 msg; msg.appendFormat("Row too big to fit into CursorWindow requiredPos=%d, totalRows=%d", requiredPos, totalRows); - throw_sqlite3_exception(env, SQLITE_TOOBIG, NULL, msg.string()); + throw_sqlite3_exception(env, SQLITE_TOOBIG, NULL, msg.c_str()); return 0; } diff --git a/core/jni/android_ddm_DdmHandleNativeHeap.cpp b/core/jni/android_ddm_DdmHandleNativeHeap.cpp index 2ca4500991fac1e2eb6adb51bd332c222764e244..d36d29ca301d5acba51403850c72cb333b2a1ce0 100644 --- a/core/jni/android_ddm_DdmHandleNativeHeap.cpp +++ b/core/jni/android_ddm_DdmHandleNativeHeap.cpp @@ -100,8 +100,8 @@ static jbyteArray DdmHandleNativeHeap_getLeakInfo(JNIEnv* env, jobject) { if (array != NULL) { env->SetByteArrayRegion(array, 0, sizeof(header), reinterpret_cast<jbyte*>(&header)); - env->SetByteArrayRegion(array, sizeof(header), - maps.size(), reinterpret_cast<const jbyte*>(maps.string())); + env->SetByteArrayRegion(array, sizeof(header), maps.size(), + reinterpret_cast<const jbyte*>(maps.c_str())); env->SetByteArrayRegion(array, sizeof(header) + maps.size(), header.allocSize, reinterpret_cast<jbyte*>(leak_info.buffer)); } diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index eb49f411159cd7f7c0d7025fae7c6821a320aeca..5f3a1b5be154c9107ea20171bab9c8e5d787da21 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -878,7 +878,7 @@ static jstring android_hardware_Camera_getParameters(JNIEnv *env, jobject thiz) jniThrowRuntimeException(env, "getParameters failed (empty parameters)"); return 0; } - return env->NewStringUTF(params8.string()); + return env->NewStringUTF(params8.c_str()); } static void android_hardware_Camera_reconnect(JNIEnv *env, jobject thiz) diff --git a/core/jni/android_hardware_camera2_CameraMetadata.cpp b/core/jni/android_hardware_camera2_CameraMetadata.cpp index 3e4c7c7f751e864837fc58f3fbcb4cdef6274555..041fed74c57397cc8e83b82c7284b3606e3ec1a0 100644 --- a/core/jni/android_hardware_camera2_CameraMetadata.cpp +++ b/core/jni/android_hardware_camera2_CameraMetadata.cpp @@ -514,7 +514,7 @@ static void CameraMetadata_dump(JNIEnv *env, jclass thiz, jlong ptr) { ssize_t res; while ((res = TEMP_FAILURE_RETRY(read(readFd, &out[0], /*count*/1))) > 0) { if (out[0] == '\n') { - ALOGD("%s", logLine.string()); + ALOGD("%s", logLine.c_str()); logLine.clear(); } else { logLine.append(out); @@ -527,7 +527,7 @@ static void CameraMetadata_dump(JNIEnv *env, jclass thiz, jlong ptr) { errno, strerror(errno)); //return; } else if (!logLine.empty()) { - ALOGD("%s", logLine.string()); + ALOGD("%s", logLine.c_str()); } close(readFd); @@ -956,8 +956,8 @@ static jint CameraMetadata_setupGlobalVendorTagDescriptor(JNIEnv *env, jclass th return OK; } else if (!res.isOk()) { VendorTagDescriptor::clearGlobalVendorTagDescriptor(); - ALOGE("%s: Failed to setup vendor tag descriptors: %s", - __FUNCTION__, res.toString8().string()); + ALOGE("%s: Failed to setup vendor tag descriptors: %s", __FUNCTION__, + res.toString8().c_str()); return res.serviceSpecificErrorCode(); } if (0 < desc->getTagCount()) { @@ -971,8 +971,8 @@ static jint CameraMetadata_setupGlobalVendorTagDescriptor(JNIEnv *env, jclass th return OK; } else if (!res.isOk()) { VendorTagDescriptorCache::clearGlobalVendorTagCache(); - ALOGE("%s: Failed to setup vendor tag cache: %s", - __FUNCTION__, res.toString8().string()); + ALOGE("%s: Failed to setup vendor tag cache: %s", __FUNCTION__, + res.toString8().c_str()); return res.serviceSpecificErrorCode(); } diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp index c947fba2dbd921de52d7998d8ed9e0f4aaf8968a..30e546cc290d33deac1ad46a4a8f588d9d813960 100644 --- a/core/jni/android_hardware_camera2_DngCreator.cpp +++ b/core/jni/android_hardware_camera2_DngCreator.cpp @@ -1543,7 +1543,8 @@ static sp<TiffWriter> DngCreator_setup(JNIEnv* env, jobject thiz, uint32_t image String8 captureTime = nativeContext->getCaptureTime(); if (writer->addEntry(TAG_DATETIME, NativeContext::DATETIME_COUNT, - reinterpret_cast<const uint8_t*>(captureTime.string()), TIFF_IFD_0) != OK) { + reinterpret_cast<const uint8_t*>(captureTime.c_str()), + TIFF_IFD_0) != OK) { jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException", "Invalid metadata for tag %x", TAG_DATETIME); return nullptr; @@ -1551,7 +1552,8 @@ static sp<TiffWriter> DngCreator_setup(JNIEnv* env, jobject thiz, uint32_t image // datetime original if (writer->addEntry(TAG_DATETIMEORIGINAL, NativeContext::DATETIME_COUNT, - reinterpret_cast<const uint8_t*>(captureTime.string()), TIFF_IFD_0) != OK) { + reinterpret_cast<const uint8_t*>(captureTime.c_str()), + TIFF_IFD_0) != OK) { jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException", "Invalid metadata for tag %x", TAG_DATETIMEORIGINAL); return nullptr; @@ -1879,8 +1881,10 @@ static sp<TiffWriter> DngCreator_setup(JNIEnv* env, jobject thiz, uint32_t image cameraModel += brand.c_str(); BAIL_IF_INVALID_RET_NULL_SP(writer->addEntry(TAG_UNIQUECAMERAMODEL, cameraModel.size() + 1, - reinterpret_cast<const uint8_t*>(cameraModel.string()), TIFF_IFD_0), env, - TAG_UNIQUECAMERAMODEL, writer); + reinterpret_cast<const uint8_t*>( + cameraModel.c_str()), + TIFF_IFD_0), + env, TAG_UNIQUECAMERAMODEL, writer); } { @@ -2165,7 +2169,8 @@ static sp<TiffWriter> DngCreator_setup(JNIEnv* env, jobject thiz, uint32_t image String8 description = nativeContext->getDescription(); size_t len = description.bytes() + 1; if (writer->addEntry(TAG_IMAGEDESCRIPTION, len, - reinterpret_cast<const uint8_t*>(description.string()), TIFF_IFD_0) != OK) { + reinterpret_cast<const uint8_t*>(description.c_str()), + TIFF_IFD_0) != OK) { jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException", "Invalid metadata for tag %x", TAG_IMAGEDESCRIPTION); } diff --git a/core/jni/android_os_HwParcel.cpp b/core/jni/android_os_HwParcel.cpp index 4c4443fc29c3d0bca0b378d006f17e4d9faa821e..0e3c51047b31cb71caec08d9009d824613f32824 100644 --- a/core/jni/android_os_HwParcel.cpp +++ b/core/jni/android_os_HwParcel.cpp @@ -285,7 +285,7 @@ static void JHwParcel_native_writeInterfaceToken( hardware::Parcel *parcel = JHwParcel::GetNativeContext(env, thiz)->getParcel(); - status_t err = parcel->writeInterfaceToken(nameCopy.string()); + status_t err = parcel->writeInterfaceToken(nameCopy.c_str()); signalExceptionForError(env, err); } } @@ -687,9 +687,7 @@ static void JHwParcel_native_writeHidlMemory( static jstring MakeStringObjFromHidlString(JNIEnv *env, const hidl_string &s) { String16 utf16String(s.c_str(), s.size()); - return env->NewString( - reinterpret_cast<const jchar *>(utf16String.string()), - utf16String.size()); + return env->NewString(reinterpret_cast<const jchar *>(utf16String.c_str()), utf16String.size()); } static jstring JHwParcel_native_readString(JNIEnv *env, jobject thiz) { diff --git a/core/jni/android_os_UEventObserver.cpp b/core/jni/android_os_UEventObserver.cpp index eda50758bca9b3632a3d9f76828e301c122cfabe..43a8be1ddc2656bbf57147435e35e813704f20b3 100644 --- a/core/jni/android_os_UEventObserver.cpp +++ b/core/jni/android_os_UEventObserver.cpp @@ -51,8 +51,8 @@ static bool isMatch(const char* buffer, size_t length) { const char* field = buffer; const char* end = buffer + length + 1; do { - if (strstr(field, match.string())) { - ALOGV("Matched uevent message with pattern: %s", match.string()); + if (strstr(field, match.c_str())) { + ALOGV("Matched uevent message with pattern: %s", match.c_str()); return true; } field += strlen(field) + 1; diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index 9dce5e3a10f34f6d20a34c73c2726fdb101fc9aa..6ed0a8a047f5d744036ad792dcb7981de587bdcb 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -953,8 +953,10 @@ void signalExceptionForError(JNIEnv* env, jobject obj, status_t err, String8 msg; msg.appendFormat("Unknown binder error code. 0x%" PRIx32, err); // RemoteException is a checked exception, only throw from certain methods. - jniThrowException(env, canThrowRemoteException - ? "android/os/RemoteException" : "java/lang/RuntimeException", msg.string()); + jniThrowException(env, + canThrowRemoteException ? "android/os/RemoteException" + : "java/lang/RuntimeException", + msg.c_str()); break; } } @@ -1286,8 +1288,7 @@ static jstring android_os_BinderProxy_getInterfaceDescriptor(JNIEnv* env, jobjec IBinder* target = getBPNativeData(env, obj)->mObject.get(); if (target != NULL) { const String16& desc = target->getInterfaceDescriptor(); - return env->NewString(reinterpret_cast<const jchar*>(desc.string()), - desc.size()); + return env->NewString(reinterpret_cast<const jchar*>(desc.c_str()), desc.size()); } jniThrowException(env, "java/lang/RuntimeException", "No binder found for object"); diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index e9dd75b28fbd07508b30eeb573a2ff018e788b60..66f5df3ed4775d6adde1170a75bc412e650e0723 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -148,7 +148,7 @@ jint android_os_Process_getUidForName(JNIEnv* env, jobject clazz, jstring name) const size_t N = name8.size(); if (N > 0) { - const char* str = name8.string(); + const char* str = name8.c_str(); for (size_t i=0; i<N; i++) { if (str[i] < '0' || str[i] > '9') { struct passwd* pwd = getpwnam(str); @@ -180,7 +180,7 @@ jint android_os_Process_getGidForName(JNIEnv* env, jobject clazz, jstring name) const size_t N = name8.size(); if (N > 0) { - const char* str = name8.string(); + const char* str = name8.c_str(); for (size_t i=0; i<N; i++) { if (str[i] < '0' || str[i] > '9') { struct group* grp = getgrnam(str); @@ -584,7 +584,7 @@ void android_os_Process_setArgV0(JNIEnv* env, jobject clazz, jstring name) } if (!name8.empty()) { - AndroidRuntime::getRuntime()->setArgv0(name8.string(), true /* setProcName */); + AndroidRuntime::getRuntime()->setArgv0(name8.c_str(), true /* setProcName */); } } @@ -690,7 +690,7 @@ void android_os_Process_readProcLines(JNIEnv* env, jobject clazz, jstring fileSt return; } - int fd = open(file.string(), O_RDONLY | O_CLOEXEC); + int fd = open(file.c_str(), O_RDONLY | O_CLOEXEC); if (fd >= 0) { //ALOGI("Clearing %" PRId32 " sizes", count); @@ -704,7 +704,7 @@ void android_os_Process_readProcLines(JNIEnv* env, jobject clazz, jstring fileSt close(fd); if (len < 0) { - ALOGW("Unable to read %s", file.string()); + ALOGW("Unable to read %s", file.c_str()); len = 0; } buffer[len] = 0; @@ -717,7 +717,7 @@ void android_os_Process_readProcLines(JNIEnv* env, jobject clazz, jstring fileSt //ALOGI("Parsing at: %s", p); for (i=0; i<count; i++) { const String8& field = fields[i]; - if (strncmp(p, field.string(), field.length()) == 0) { + if (strncmp(p, field.c_str(), field.length()) == 0) { p += field.length(); while (*p == ' ' || *p == '\t') p++; char* num = p; @@ -729,7 +729,7 @@ void android_os_Process_readProcLines(JNIEnv* env, jobject clazz, jstring fileSt } char* end; sizesArray[i] = strtoll(num, &end, 10); - //ALOGI("Field %s = %" PRId64, field.string(), sizesArray[i]); + // ALOGI("Field %s = %" PRId64, field.c_str(), sizesArray[i]); foundCount++; break; } @@ -746,7 +746,7 @@ void android_os_Process_readProcLines(JNIEnv* env, jobject clazz, jstring fileSt free(buffer); } else { - ALOGW("Unable to open %s", file.string()); + ALOGW("Unable to open %s", file.c_str()); } //ALOGI("Done!"); diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index e2bb6a6f4d1a90c87e69e1fe95042e494aba435f..14d5eafa194510b18908049ad408ac861c2cb664 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -167,8 +167,8 @@ void JNIOnInfoListener::onInfo(const DrmInfoEvent& event) { jint uniqueId = event.getUniqueId(); jint type = event.getType(); JNIEnv *env = AndroidRuntime::getJNIEnv(); - jstring message = env->NewStringUTF(event.getMessage().string()); - ALOGV("JNIOnInfoListener::onInfo => %d | %d | %s", uniqueId, type, event.getMessage().string()); + jstring message = env->NewStringUTF(event.getMessage().c_str()); + ALOGV("JNIOnInfoListener::onInfo => %d | %d | %s", uniqueId, type, event.getMessage().c_str()); env->CallStaticVoidMethod( mClass, @@ -273,15 +273,15 @@ static jobject android_drm_DrmManagerClient_getConstraintsFromContent( const char* value = pConstraints->getAsByteArray(&key); if (NULL != value) { ScopedLocalRef<jbyteArray> dataArray(env, env->NewByteArray(strlen(value))); - ScopedLocalRef<jstring> keyString(env, env->NewStringUTF(key.string())); + ScopedLocalRef<jstring> keyString(env, env->NewStringUTF(key.c_str())); env->SetByteArrayRegion(dataArray.get(), 0, strlen(value), (jbyte*)value); env->CallVoidMethod(constraints, ContentValues_putByteArray, keyString.get(), dataArray.get()); } } else { String8 value = pConstraints->get(key); - ScopedLocalRef<jstring> keyString(env, env->NewStringUTF(key.string())); - ScopedLocalRef<jstring> valueString(env, env->NewStringUTF(value.string())); + ScopedLocalRef<jstring> keyString(env, env->NewStringUTF(key.c_str())); + ScopedLocalRef<jstring> valueString(env, env->NewStringUTF(value.c_str())); env->CallVoidMethod(constraints, ContentValues_putString, keyString.get(), valueString.get()); } @@ -320,8 +320,8 @@ static jobject android_drm_DrmManagerClient_getMetadataFromContent( // insert the entry<constraintKey, constraintValue> // to newly created java object String8 value = pMetadata->get(key); - ScopedLocalRef<jstring> keyString(env, env->NewStringUTF(key.string())); - ScopedLocalRef<jstring> valueString(env, env->NewStringUTF(value.string())); + ScopedLocalRef<jstring> keyString(env, env->NewStringUTF(key.c_str())); + ScopedLocalRef<jstring> valueString(env, env->NewStringUTF(value.c_str())); env->CallVoidMethod(metadata, ContentValues_putString, keyString.get(), valueString.get()); } @@ -357,19 +357,19 @@ static jobjectArray android_drm_DrmManagerClient_getAllSupportInfo( env->CallVoidMethod( drmSupportInfo, env->GetMethodID(clazz, "setDescription", "(Ljava/lang/String;)V"), - env->NewStringUTF(info.getDescription().string())); + env->NewStringUTF(info.getDescription().c_str())); DrmSupportInfo::MimeTypeIterator iterator = info.getMimeTypeIterator(); while (iterator.hasNext()) { String8 value = iterator.next(); - env->CallVoidMethod(drmSupportInfo, addMimeTypeId, env->NewStringUTF(value.string())); + env->CallVoidMethod(drmSupportInfo, addMimeTypeId, env->NewStringUTF(value.c_str())); } DrmSupportInfo::FileSuffixIterator it = info.getFileSuffixIterator(); while (it.hasNext()) { String8 value = it.next(); env->CallVoidMethod( - drmSupportInfo, addFileSuffixId, env->NewStringUTF(value.string())); + drmSupportInfo, addFileSuffixId, env->NewStringUTF(value.c_str())); } env->SetObjectArrayElement(array, i, drmSupportInfo); @@ -459,7 +459,7 @@ static jobject android_drm_DrmManagerClient_processDrmInfo( String8 keyString = Utility::getStringValue(env, key.get()); String8 valueString = Utility::getStringValue(env, valString.get()); - ALOGV("Key: %s | Value: %s", keyString.string(), valueString.string()); + ALOGV("Key: %s | Value: %s", keyString.c_str(), valueString.c_str()); drmInfo.put(keyString, valueString); } @@ -488,15 +488,15 @@ static jobject android_drm_DrmManagerClient_processDrmInfo( jmethodID constructorId = env->GetMethodID(clazz, "<init>", "([BLjava/lang/String;Ljava/lang/String;)V"); jobject processedData = env->NewObject(clazz, constructorId, dataArray, - env->NewStringUTF((drmInfo.get(DrmInfoRequest::ACCOUNT_ID)).string()), - env->NewStringUTF((drmInfo.get(DrmInfoRequest::SUBSCRIPTION_ID)).string())); + env->NewStringUTF((drmInfo.get(DrmInfoRequest::ACCOUNT_ID)).c_str()), + env->NewStringUTF((drmInfo.get(DrmInfoRequest::SUBSCRIPTION_ID)).c_str())); constructorId = env->GetMethodID(localRef, "<init>", "(IILandroid/drm/ProcessedData;Ljava/lang/String;)V"); drmInfoStatus = env->NewObject(localRef, constructorId, statusCode, infoType, - processedData, env->NewStringUTF(pDrmInfoStatus->mimeType.string())); + processedData, env->NewStringUTF(pDrmInfoStatus->mimeType.c_str())); } delete[] mData; mData = NULL; @@ -533,7 +533,7 @@ static jobject android_drm_DrmManagerClient_acquireDrmInfo( String8 keyString = Utility::getStringValue(env, key.get()); String8 valueString = Utility::getStringValue(env, value.get()); - ALOGV("Key: %s | Value: %s", keyString.string(), valueString.string()); + ALOGV("Key: %s | Value: %s", keyString.c_str(), valueString.c_str()); drmInfoReq.put(keyString, valueString); } @@ -554,7 +554,7 @@ static jobject android_drm_DrmManagerClient_acquireDrmInfo( drmInfoObject = env->NewObject(localRef, env->GetMethodID(localRef, "<init>", "(I[BLjava/lang/String;)V"), - mInfoType, dataArray, env->NewStringUTF(pDrmInfo->getMimeType().string())); + mInfoType, dataArray, env->NewStringUTF(pDrmInfo->getMimeType().c_str())); DrmInfo::KeyIterator it = pDrmInfo->keyIterator(); jmethodID putMethodId @@ -563,8 +563,8 @@ static jobject android_drm_DrmManagerClient_acquireDrmInfo( while (it.hasNext()) { String8 key = it.next(); String8 value = pDrmInfo->get(key); - ScopedLocalRef<jstring> keyString(env, env->NewStringUTF(key.string())); - ScopedLocalRef<jstring> valueString(env, env->NewStringUTF(value.string())); + ScopedLocalRef<jstring> keyString(env, env->NewStringUTF(key.c_str())); + ScopedLocalRef<jstring> valueString(env, env->NewStringUTF(value.c_str())); env->CallVoidMethod(drmInfoObject, putMethodId, keyString.get(), valueString.get()); } @@ -602,7 +602,7 @@ static jstring android_drm_DrmManagerClient_getOriginalMimeType( ->getOriginalMimeType(uniqueId, Utility::getStringValue(env, path), fd); ALOGV("getOriginalMimeType Exit"); - return env->NewStringUTF(mimeType.string()); + return env->NewStringUTF(mimeType.c_str()); } static jint android_drm_DrmManagerClient_checkRightsStatus( diff --git a/libs/incident/src/IncidentReportArgs.cpp b/libs/incident/src/IncidentReportArgs.cpp index d344a981ecea11a2d6b2a219b0c853cfb4191b89..858813ff4276fb75e95d1557b67beae71faa3929 100644 --- a/libs/incident/src/IncidentReportArgs.cpp +++ b/libs/incident/src/IncidentReportArgs.cpp @@ -152,8 +152,8 @@ IncidentReportArgs::readFromParcel(const Parcel* in) } mPrivacyPolicy = privacyPolicy; - mReceiverPkg = String8(in->readString16()).string(); - mReceiverCls = String8(in->readString16()).string(); + mReceiverPkg = String8(in->readString16()).c_str(); + mReceiverCls = String8(in->readString16()).c_str(); int32_t gzip; err = in->readInt32(&gzip); diff --git a/libs/services/src/os/DropBoxManager.cpp b/libs/services/src/os/DropBoxManager.cpp index 3716e019f69ac9e2095329c2fc590a15d9ea8560..60bb00ab730933992175248ef6bc84393974107d 100644 --- a/libs/services/src/os/DropBoxManager.cpp +++ b/libs/services/src/os/DropBoxManager.cpp @@ -196,7 +196,7 @@ DropBoxManager::addData(const String16& tag, uint8_t const* data, vector<uint8_t> dataArg; dataArg.assign(data, data + size); Status status = service->addData(tag, dataArg, flags); - ALOGD("service->add returned %s", status.toString8().string()); + ALOGD("service->add returned %s", status.toString8().c_str()); return status; } @@ -230,7 +230,7 @@ DropBoxManager::addFile(const String16& tag, int fd, int flags) android::base::unique_fd uniqueFd(fd); android::os::ParcelFileDescriptor parcelFd(std::move(uniqueFd)); Status status = service->addFile(tag, parcelFd, flags); - ALOGD("service->add returned %s", status.toString8().string()); + ALOGD("service->add returned %s", status.toString8().c_str()); return status; } diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index 3b93b07b98bcf387883fe5cc4378c591dfa836cc..f7d4825844ccf7e932b60e1a24ac7c8ac0d94628 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -617,7 +617,7 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, jobject image) { "match the ImageReader's configured buffer format 0x%x.", bufferFormat, ctx->getBufferFormat()); jniThrowException(env, "java/lang/UnsupportedOperationException", - msg.string()); + msg.c_str()); return -1; } } @@ -789,7 +789,7 @@ static jobjectArray ImageReader_createImagePlanes(JNIEnv* env, jobject /*thiz*/, String8 msg; msg.appendFormat("Format 0x%x is opaque, thus not writable, the number of planes (%d)" " must be 0", halReaderFormat, numPlanes); - jniThrowException(env, "java/lang/IllegalArgumentException", msg.string()); + jniThrowException(env, "java/lang/IllegalArgumentException", msg.c_str()); return NULL; } @@ -854,7 +854,7 @@ static jobjectArray Image_createSurfacePlanes(JNIEnv* env, jobject thiz, String8 msg; msg.appendFormat("Format 0x%x is opaque, thus not writable, the number of planes (%d)" " must be 0", halReaderFormat, numPlanes); - jniThrowException(env, "java/lang/IllegalArgumentException", msg.string()); + jniThrowException(env, "java/lang/IllegalArgumentException", msg.c_str()); return NULL; } diff --git a/media/jni/android_media_ImageWriter.cpp b/media/jni/android_media_ImageWriter.cpp index 2c498e5bb4ef5cd950b9784bbed47e340a036a6c..dd1652c985969c07bed23bf436ca03c5ff1d6560 100644 --- a/media/jni/android_media_ImageWriter.cpp +++ b/media/jni/android_media_ImageWriter.cpp @@ -1068,7 +1068,7 @@ static jobjectArray Image_createSurfacePlanes(JNIEnv* env, jobject thiz, String8 msg; msg.appendFormat("Format 0x%x is opaque, thus not writable, the number of planes (%d)" " must be 0", writerFormat, numPlanes); - jniThrowException(env, "java/lang/IllegalArgumentException", msg.string()); + jniThrowException(env, "java/lang/IllegalArgumentException", msg.c_str()); return NULL; } diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp index f491be884b2feaf3bbd0cc7c3282f379a878cf66..5506f6149fa5252acfcc4d73b6bc18933ddb0708 100644 --- a/media/jni/android_media_MediaCrypto.cpp +++ b/media/jni/android_media_MediaCrypto.cpp @@ -299,7 +299,7 @@ static void android_media_MediaCrypto_setMediaDrmSession( std::string strerr(StrCryptoError(err)); msg.appendFormat(": general failure (%s)", strerr.c_str()); } - jniThrowException(env, "android/media/MediaCryptoException", msg.string()); + jniThrowException(env, "android/media/MediaCryptoException", msg.c_str()); } } diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp index b70818d1e1b0a3675687e223c44aaac5133f8f6b..c616b84fa6fb26f44833e683ba3e0a0cab8108e2 100644 --- a/media/jni/android_media_MediaDrm.cpp +++ b/media/jni/android_media_MediaDrm.cpp @@ -708,8 +708,8 @@ static jobject KeyedVectorToHashMap (JNIEnv *env, KeyedVector<String8, String8> jclass clazz = gFields.hashmapClassId; jobject hashMap = env->NewObject(clazz, gFields.hashmap.init); for (size_t i = 0; i < map.size(); ++i) { - jstring jkey = env->NewStringUTF(map.keyAt(i).string()); - jstring jvalue = env->NewStringUTF(map.valueAt(i).string()); + jstring jkey = env->NewStringUTF(map.keyAt(i).c_str()); + jstring jvalue = env->NewStringUTF(map.valueAt(i).c_str()); env->CallObjectMethod(hashMap, gFields.hashmap.put, jkey, jvalue); env->DeleteLocalRef(jkey); env->DeleteLocalRef(jvalue); @@ -1169,7 +1169,7 @@ static jobject android_media_MediaDrm_getKeyRequest( jbyteArray jrequest = VectorToJByteArray(env, request); env->SetObjectField(keyObj, gFields.keyRequest.data, jrequest); - jstring jdefaultUrl = env->NewStringUTF(defaultUrl.string()); + jstring jdefaultUrl = env->NewStringUTF(defaultUrl.c_str()); env->SetObjectField(keyObj, gFields.keyRequest.defaultUrl, jdefaultUrl); switch (keyRequestType) { @@ -1332,7 +1332,7 @@ static jobject android_media_MediaDrm_getProvisionRequestNative( jbyteArray jrequest = VectorToJByteArray(env, request); env->SetObjectField(provisionObj, gFields.provisionRequest.data, jrequest); - jstring jdefaultUrl = env->NewStringUTF(defaultUrl.string()); + jstring jdefaultUrl = env->NewStringUTF(defaultUrl.c_str()); env->SetObjectField(provisionObj, gFields.provisionRequest.defaultUrl, jdefaultUrl); } @@ -1686,7 +1686,7 @@ static jstring android_media_MediaDrm_getPropertyString( return NULL; } - return env->NewStringUTF(value.string()); + return env->NewStringUTF(value.c_str()); } static jbyteArray android_media_MediaDrm_getPropertyByteArray( diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index ddc51cdb861c5691df01c478d4a38c8f464fe9d3..14587589372bf14242647d6fe342afa7136170b1 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -126,7 +126,7 @@ android_media_MediaMetadataRetriever_setDataSourceAndHeaders( tmp = NULL; // Don't let somebody trick us in to reading some random block of memory - if (strncmp("mem://", pathStr.string(), 6) == 0) { + if (strncmp("mem://", pathStr.c_str(), 6) == 0) { jniThrowException( env, "java/lang/IllegalArgumentException", "Invalid pathname"); return; @@ -149,7 +149,7 @@ android_media_MediaMetadataRetriever_setDataSourceAndHeaders( env, retriever->setDataSource( httpService, - pathStr.string(), + pathStr.c_str(), headersVector.size() > 0 ? &headersVector : NULL), "java/lang/RuntimeException", diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index a548a472fc3a6cd646def0ae0b903212ab738fd6..43de37850b89be191a4dd84272ac74abe8b6fd70 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -1214,7 +1214,7 @@ static bool throwDrmExceptionAsNecessary(JNIEnv *env, status_t err, const char * String8 vendorMessage; if (err >= ERROR_DRM_VENDOR_MIN && err <= ERROR_DRM_VENDOR_MAX) { vendorMessage = String8::format("DRM vendor-defined error: %d", err); - drmMessage = vendorMessage.string(); + drmMessage = vendorMessage.c_str(); } if (err == BAD_VALUE) { @@ -1240,7 +1240,7 @@ static bool throwDrmExceptionAsNecessary(JNIEnv *env, status_t err, const char * msg = drmMessage; } else { errbuf = String8::format("%s: %s", msg, drmMessage); - msg = errbuf.string(); + msg = errbuf.c_str(); } } throwDrmStateException(env, msg, err); diff --git a/media/jni/android_media_Streams.cpp b/media/jni/android_media_Streams.cpp index 4fd515323181df29066cb2aafbaccaaed0305d39..dffeb890a840cbd6eb6be9346ebf36a8bbb0b72d 100644 --- a/media/jni/android_media_Streams.cpp +++ b/media/jni/android_media_Streams.cpp @@ -38,7 +38,7 @@ FileStream::FileStream(const int fd) FileStream::FileStream(const String8 filename) : mPosition(0) { - mFile = fopen(filename.string(), "r"); + mFile = fopen(filename.c_str(), "r"); if (mFile == NULL) { return; } @@ -86,7 +86,7 @@ bool GetExifFromRawImage( if (!piex::IsRaw(stream)) { // Format not supported. - ALOGV("Format not supported: %s", filename.string()); + ALOGV("Format not supported: %s", filename.c_str()); return false; } @@ -94,7 +94,7 @@ bool GetExifFromRawImage( if (err != piex::Error::kOk) { // The input data seems to be broken. - ALOGV("Raw image not detected: %s (piex error code: %d)", filename.string(), (int32_t)err); + ALOGV("Raw image not detected: %s (piex error code: %d)", filename.c_str(), (int32_t)err); return false; } diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp index 69cf80477dde42dcf9f20a61c956acee649c4987..1878716da3cdb0cb73c3d5f8327807d03cd34fff 100644 --- a/native/android/asset_manager.cpp +++ b/native/android/asset_manager.cpp @@ -118,7 +118,7 @@ const char* AAssetDir_getNextFileName(AAssetDir* assetDir) // the string to return and advance the iterator for next time. if (index < max) { assetDir->mCachedFileName = assetDir->mAssetDir->getFileName(index); - returnName = assetDir->mCachedFileName.string(); + returnName = assetDir->mCachedFileName.c_str(); index++; } @@ -134,7 +134,7 @@ void AAssetDir_rewind(AAssetDir* assetDir) const char* AAssetDir_getFileName(AAssetDir* assetDir, int index) { assetDir->mCachedFileName = assetDir->mAssetDir->getFileName(index); - return assetDir->mCachedFileName.string(); + return assetDir->mCachedFileName.c_str(); } void AAssetDir_close(AAssetDir* assetDir) diff --git a/native/android/sensor.cpp b/native/android/sensor.cpp index 968de34f5d69b36356a764c1e4929554e050a0b0..bb8708bd1e5e01215ffd041a430fa4ff35421342 100644 --- a/native/android/sensor.cpp +++ b/native/android/sensor.cpp @@ -304,12 +304,12 @@ int ASensorEventQueue_requestAdditionalInfoEvents(ASensorEventQueue* queue, bool const char* ASensor_getName(ASensor const* sensor) { RETURN_IF_SENSOR_IS_NULL(nullptr); - return static_cast<Sensor const*>(sensor)->getName().string(); + return static_cast<Sensor const*>(sensor)->getName().c_str(); } const char* ASensor_getVendor(ASensor const* sensor) { RETURN_IF_SENSOR_IS_NULL(nullptr); - return static_cast<Sensor const*>(sensor)->getVendor().string(); + return static_cast<Sensor const*>(sensor)->getVendor().c_str(); } int ASensor_getType(ASensor const* sensor) { @@ -339,7 +339,7 @@ int ASensor_getFifoReservedEventCount(ASensor const* sensor) { const char* ASensor_getStringType(ASensor const* sensor) { RETURN_IF_SENSOR_IS_NULL(nullptr); - return static_cast<Sensor const*>(sensor)->getStringType().string(); + return static_cast<Sensor const*>(sensor)->getStringType().c_str(); } int ASensor_getReportingMode(ASensor const* sensor) { diff --git a/native/android/storage_manager.cpp b/native/android/storage_manager.cpp index 294ca9cfd3b4479ef98adeadf7a31a48d89e2ae5..6db87dfdd565ac67790a650260a196c1f7d51186 100644 --- a/native/android/storage_manager.cpp +++ b/native/android/storage_manager.cpp @@ -175,7 +175,7 @@ public: String16 filename16(filename); String16 path16; if (mMountService->getMountedObbPath(filename16, path16)) { - return String8(path16).string(); + return String8(path16).c_str(); } else { return NULL; } @@ -183,7 +183,7 @@ public: }; void ObbActionListener::onObbResult(const android::String16& filename, const int32_t nonce, const int32_t state) { - mStorageManager->fireCallback(String8(filename).string(), nonce, state); + mStorageManager->fireCallback(String8(filename).c_str(), nonce, state); } diff --git a/services/core/jni/gnss/GnssVisibilityControlCallback.cpp b/services/core/jni/gnss/GnssVisibilityControlCallback.cpp index ec215f106650ffd85db1098a0c8c6a7f6ed9fb07..bc57c1d95b02292355689afc1da203347cc4bdfa 100644 --- a/services/core/jni/gnss/GnssVisibilityControlCallback.cpp +++ b/services/core/jni/gnss/GnssVisibilityControlCallback.cpp @@ -73,7 +73,7 @@ bool GnssVisibilityControlCallbackUtil::isInEmergencySession() { template <> jstring ToJstring(JNIEnv* env, const String16& value) { - const char16_t* str = value.string(); + const char16_t* str = value.c_str(); size_t len = value.size(); return env->NewString(reinterpret_cast<const jchar*>(str), len); } diff --git a/tools/obbtool/Main.cpp b/tools/obbtool/Main.cpp index 64808c0a755f2d5ef28cbb9c372f82e0f32d7931..70140685e37eb4e9cde28d00cb072ea55357dabf 100644 --- a/tools/obbtool/Main.cpp +++ b/tools/obbtool/Main.cpp @@ -135,7 +135,7 @@ void doInfo(const char* filename) { } printf("OBB info for '%s':\n", filename); - printf("Package name: %s\n", obb->getPackageName().string()); + printf("Package name: %s\n", obb->getPackageName().c_str()); printf(" Version: %d\n", obb->getVersion()); printf(" Flags: 0x%08x\n", obb->getFlags()); printf(" Overlay: %s\n", obb->isOverlay() ? "true" : "false");