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

Commit d579f3ef authored by Wonsik Kim's avatar Wonsik Kim
Browse files

Fix dumpsys media.player

- check dump permission
- fix truncation happening when details field is too long

Bug: 140444741
Test: dumpsys media.player
Test: atest CtsSecurityTestCases:android.security.cts.ServicePermissionsTest#testDumpProtected
Change-Id: Id04afba8195347c6a174e13743cedb422c8624a1
parent 5871ab51
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -421,9 +421,9 @@ static void dumpCodecDetails(int fd, const sp<IMediaCodecList> &codecList, bool
                printList("colors", list);
            }

            snprintf(buffer, SIZE - 1, "    details: %s\n",
                     caps->getDetails()->debugString(6).c_str());
            result.append(buffer);
            result.append("    details: ");
            result.append(caps->getDetails()->debugString(6).c_str());
            result.append("\n");
        }
    }
    result.append("\n");
@@ -688,6 +688,10 @@ status_t MediaPlayerService::dump(int fd, const Vector<String16>& args)

        gLooperRoster.dump(fd, args);

        sp<IMediaCodecList> codecList = getCodecList();
        dumpCodecDetails(fd, codecList, true /* decoders */);
        dumpCodecDetails(fd, codecList, false /* !decoders */);

        bool dumpMem = false;
        bool unreachableMemory = false;
        for (size_t i = 0; i < args.size(); i++) {
@@ -711,10 +715,6 @@ status_t MediaPlayerService::dump(int fd, const Vector<String16>& args)
    }
    write(fd, result.string(), result.size());

    sp<IMediaCodecList> codecList = getCodecList();
    dumpCodecDetails(fd, codecList, true /* decoders */);
    dumpCodecDetails(fd, codecList, false /* !decoders */);

    return NO_ERROR;
}