Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a33a2173 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Automerger Merge Worker
Browse files

Merge "Use String8/16 c_str [cmds]" into main am: 4d322774 am: 0ef15887...

Merge "Use String8/16 c_str [cmds]" into main am: 4d322774 am: 0ef15887 am: 63a4968f am: ea3671a2 am: b827dab3

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2724474



Change-Id: I4effd16dbd0555f78919adbbbf77c14dbdfb2b62
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 92804557 b827dab3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -692,7 +692,7 @@ static bool verifyKernelTraceFuncs(const char* funcs)
    while (func) {
        if (!strchr(func, '*')) {
            String8 fancyFunc = String8::format("\n%s\n", func);
            bool found = funcList.find(fancyFunc.string(), 0) >= 0;
            bool found = funcList.find(fancyFunc.c_str(), 0) >= 0;
            if (!found || func[0] == '\0') {
                fprintf(stderr, "error: \"%s\" is not a valid kernel function "
                        "to trace.\n", func);
@@ -800,7 +800,7 @@ static bool setCategoriesEnableFromFile(const char* categories_file)
            tokenizer->skipDelimiters(" ");
            continue;
        }
        ok &= setCategoryEnable(token.string());
        ok &= setCategoryEnable(token.c_str());
    }
    delete tokenizer;
    return ok;
+8 −8
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public:
            return -EPERM;
        }
#if DEBUG
        ALOGD("openFile: %s, full=%s", path8.string(), fullPath.string());
        ALOGD("openFile: %s, full=%s", path8.c_str(), fullPath.c_str());
#endif
        int flags = 0;
        bool checkRead = false;
@@ -96,10 +96,10 @@ public:
            flags = O_RDWR;
            checkRead = checkWrite = true;
        } else {
            mErrorLog << "Invalid mode requested: " << mode.string() << endl;
            mErrorLog << "Invalid mode requested: " << mode.c_str() << endl;
            return -EINVAL;
        }
        int fd = open(fullPath.string(), flags, S_IRWXU|S_IRWXG);
        int fd = open(fullPath.c_str(), flags, S_IRWXU|S_IRWXG);
#if DEBUG
        ALOGD("openFile: fd=%d", fd);
#endif
@@ -109,29 +109,29 @@ public:
        if (is_selinux_enabled() && seLinuxContext.size() > 0) {
            String8 seLinuxContext8(seLinuxContext);
            char* tmp = nullptr;
            getfilecon(fullPath.string(), &tmp);
            getfilecon(fullPath.c_str(), &tmp);
            Unique_SecurityContext context(tmp);
            if (checkWrite) {
                int accessGranted = selinux_check_access(seLinuxContext8.string(), context.get(),
                int accessGranted = selinux_check_access(seLinuxContext8.c_str(), context.get(),
                        "file", "write", nullptr);
                if (accessGranted != 0) {
#if DEBUG
                    ALOGD("openFile: failed selinux write check!");
#endif
                    close(fd);
                    mErrorLog << "System server has no access to write file context " << context.get() << " (from path " << fullPath.string() << ", context " << seLinuxContext8.string() << ")" << endl;
                    mErrorLog << "System server has no access to write file context " << context.get() << " (from path " << fullPath.c_str() << ", context " << seLinuxContext8.c_str() << ")" << endl;
                    return -EPERM;
                }
            }
            if (checkRead) {
                int accessGranted = selinux_check_access(seLinuxContext8.string(), context.get(),
                int accessGranted = selinux_check_access(seLinuxContext8.c_str(), context.get(),
                        "file", "read", nullptr);
                if (accessGranted != 0) {
#if DEBUG
                    ALOGD("openFile: failed selinux read check!");
#endif
                    close(fd);
                    mErrorLog << "System server has no access to read file context " << context.get() << " (from path " << fullPath.string() << ", context " << seLinuxContext8.string() << ")" << endl;
                    mErrorLog << "System server has no access to read file context " << context.get() << " (from path " << fullPath.c_str() << ", context " << seLinuxContext8.c_str() << ")" << endl;
                    return -EPERM;
                }
            }
+2 −2
Original line number Diff line number Diff line
@@ -543,7 +543,7 @@ status_t Dumpsys::writeDump(int fd, const String16& serviceName, std::chrono::mi

    if ((status == TIMED_OUT) && (!asProto)) {
        std::string msg = StringPrintf("\n*** SERVICE '%s' DUMP TIMEOUT (%llums) EXPIRED ***\n\n",
                                       String8(serviceName).string(), timeout.count());
                                       String8(serviceName).c_str(), timeout.count());
        WriteStringToFd(msg, fd);
    }

@@ -562,6 +562,6 @@ void Dumpsys::writeDumpFooter(int fd, const String16& serviceName,
    oss << std::put_time(&finish_tm, "%Y-%m-%d %H:%M:%S");
    std::string msg =
        StringPrintf("--------- %.3fs was the duration of dumpsys %s, ending at: %s\n",
                     elapsedDuration.count(), String8(serviceName).string(), oss.str().c_str());
                     elapsedDuration.count(), String8(serviceName).c_str(), oss.str().c_str());
    WriteStringToFd(msg, fd);
}