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

Commit fd000402 authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

Add a flag to dumpProfiles to send --dump-classes-and-methods to profman.

Test: adb root
      adb shell kill -SIGUSR1 '$(pidof com.android.systemui)' && \
        sleep 1 && \
        adb shell pm compile -m speed-profile com.android.systemui
      adb unroot
      adb shell pm dump-profiles --dump-classes-and-methods \
        com.android.systemui && \
        adb pull data/misc/profman/com.android.systemui-primary.prof.txt
  Check that the output is the same as:
      adb root && adb shell profman --dump-classes-and-methods \
        --reference-profile-file=data/misc/profiles/ref/com.android.systemui/primary.prof \
        --profile-file=data/misc/profiles/cur/0/com.android.systemui/primary.prof \
        --apk=system_ext/priv-app/SystemUI/SystemUI.apk
Test: adb shell pm dump-profiles \
        com.android.systemui && \
        adb pull data/misc/profman/com.android.systemui-primary.prof.txt
  Check that the output is in the usual `profman --dump-only` format
Bug: 198506529
Ignore-AOSP-First: Goes together with a change in PackageManager which
  is developed in internal.
Change-Id: I84ba3e3ee6c4077500d7cd5e077ac6a3bfeff265
parent 00679b8a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2976,13 +2976,15 @@ binder::Status InstalldNativeService::setAppQuota(const std::optional<std::strin
// Dumps the contents of a profile file, using pkgname's dex files for pretty
// printing the result.
binder::Status InstalldNativeService::dumpProfiles(int32_t uid, const std::string& packageName,
        const std::string& profileName, const std::string& codePath, bool* _aidl_return) {
                                                   const std::string& profileName,
                                                   const std::string& codePath,
                                                   bool dumpClassesAndMethods, bool* _aidl_return) {
    ENFORCE_UID(AID_SYSTEM);
    CHECK_ARGUMENT_PACKAGE_NAME(packageName);
    CHECK_ARGUMENT_PATH(codePath);
    LOCK_PACKAGE();

    *_aidl_return = dump_profiles(uid, packageName, profileName, codePath);
    *_aidl_return = dump_profiles(uid, packageName, profileName, codePath, dumpClassesAndMethods);
    return ok();
}

+2 −1
Original line number Diff line number Diff line
@@ -134,7 +134,8 @@ public:
    binder::Status mergeProfiles(int32_t uid, const std::string& packageName,
            const std::string& profileName, int* _aidl_return);
    binder::Status dumpProfiles(int32_t uid, const std::string& packageName,
            const std::string& profileName, const std::string& codePath, bool* _aidl_return);
                                const std::string& profileName, const std::string& codePath,
                                bool dumpClassesAndMethods, bool* _aidl_return);
    binder::Status copySystemProfile(const std::string& systemProfile,
            int32_t uid, const std::string& packageName, const std::string& profileName,
            bool* _aidl_return);
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ interface IInstalld {

    int mergeProfiles(int uid, @utf8InCpp String packageName, @utf8InCpp String profileName);
    boolean dumpProfiles(int uid, @utf8InCpp String packageName, @utf8InCpp String  profileName,
            @utf8InCpp String codePath);
            @utf8InCpp String codePath, boolean dumpClassesAndMethods);
    boolean copySystemProfile(@utf8InCpp String systemProfile, int uid,
            @utf8InCpp String packageName, @utf8InCpp String profileName);
    void clearAppProfiles(@utf8InCpp String packageName, @utf8InCpp String profileName);
+10 −6
Original line number Diff line number Diff line
@@ -624,12 +624,15 @@ class RunProfman : public ExecVHelper {
                  /*for_boot_image*/false);
    }

    void SetupDump(const std::vector<unique_fd>& profiles_fd,
                   const unique_fd& reference_profile_fd,
    void SetupDump(const std::vector<unique_fd>& profiles_fd, const unique_fd& reference_profile_fd,
                   const std::vector<std::string>& dex_locations,
                   const std::vector<unique_fd>& apk_fds,
                   const std::vector<unique_fd>& apk_fds, bool dump_classes_and_methods,
                   const unique_fd& output_fd) {
        if (dump_classes_and_methods) {
            AddArg("--dump-classes-and-methods");
        } else {
            AddArg("--dump-only");
        }
        AddArg(StringPrintf("--dump-output-to-fd=%d", output_fd.get()));
        SetupArgs(profiles_fd,
                  reference_profile_fd,
@@ -772,7 +775,7 @@ int analyze_primary_profiles(uid_t uid, const std::string& package_name,
}

bool dump_profiles(int32_t uid, const std::string& pkgname, const std::string& profile_name,
        const std::string& code_path) {
                   const std::string& code_path, bool dump_classes_and_methods) {
    std::vector<unique_fd> profile_fds;
    unique_fd reference_profile_fd;
    std::string out_file_name = StringPrintf("/data/misc/profman/%s-%s.txt",
@@ -808,7 +811,8 @@ bool dump_profiles(int32_t uid, const std::string& pkgname, const std::string& p


    RunProfman profman_dump;
    profman_dump.SetupDump(profile_fds, reference_profile_fd, dex_locations, apk_fds, output_fd);
    profman_dump.SetupDump(profile_fds, reference_profile_fd, dex_locations, apk_fds,
                           dump_classes_and_methods, output_fd);
    pid_t pid = fork();
    if (pid == 0) {
        /* child -- drop privileges before continuing */
+2 −4
Original line number Diff line number Diff line
@@ -88,10 +88,8 @@ bool create_profile_snapshot(int32_t app_id,
                             const std::string& profile_name,
                             const std::string& classpath);

bool dump_profiles(int32_t uid,
                   const std::string& pkgname,
                   const std::string& profile_name,
                   const std::string& code_path);
bool dump_profiles(int32_t uid, const std::string& pkgname, const std::string& profile_name,
                   const std::string& code_path, bool dump_classes_and_methods);

bool copy_system_profile(const std::string& system_profile,
                         uid_t packageUid,