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

Commit cb35a06f authored by Victor Hsieh's avatar Victor Hsieh
Browse files

installd: Replace Dex2oatFileWrapper with UniqueFile

UniqueFile is based on the original Dex2oatFileWrapper, but support
extra features. The class now maintains the file path as a member
variable. This the client to access both fd and file path when they see
fit. As a result, the client no longer provides the cleanup function
with a closure capture, since the class can provide the file path.

Additionally, reduce code duplication in constructors.

Bug: 161470356
Test: atest run_dex2oat_test
Test: atest installd_dexopt_test

Change-Id: I1b66bc58b1885933d1601fdc2f4218c4a262d9f3
parent 6d4f6b9b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ cc_defaults {
        "execv_helper.cpp",
        "globals.cpp",
        "run_dex2oat.cpp",
        "unique_file.cpp",
        "utils.cpp",
        "utils_default.cpp",
        "view_compiler.cpp",
@@ -114,6 +115,7 @@ cc_test_host {
    srcs: [
        "run_dex2oat_test.cpp",
        "run_dex2oat.cpp",
        "unique_file.cpp",
        "execv_helper.cpp",
    ],
    cflags: ["-Wall", "-Werror"],
@@ -121,9 +123,6 @@ cc_test_host {
        "libbase",
        "server_configurable_flags",
    ],
    static_libs: [
        //"libinstalld",
    ],
    test_config: "run_dex2oat_test.xml",
}

@@ -234,6 +233,7 @@ cc_binary {
        "otapreopt.cpp",
        "otapreopt_utils.cpp",
        "run_dex2oat.cpp",
        "unique_file.cpp",
        "utils.cpp",
        "utils_default.cpp",
        "view_compiler.cpp",
+104 −193

File changed.

Preview size limit exceeded, changes collapsed.

+41 −43

File changed.

Preview size limit exceeded, changes collapsed.

+20 −22
Original line number Diff line number Diff line
@@ -25,31 +25,31 @@
namespace android {
namespace installd {

class UniqueFile;

class RunDex2Oat {
  public:
    explicit RunDex2Oat(const char* dex2oat_bin, ExecVHelper* execv_helper);
    virtual ~RunDex2Oat();

    void Initialize(int zip_fd,
                    int oat_fd,
                    int input_vdex_fd,
                    int output_vdex_fd,
                    int image_fd,
                    const char* input_file_name,
                    const char* output_file_name,
    void Initialize(const UniqueFile& output_oat,
                    const UniqueFile& output_vdex,
                    const UniqueFile& output_image,
                    const UniqueFile& input_dex,
                    const UniqueFile& input_vdex,
                    const UniqueFile& dex_metadata,
                    const UniqueFile& profile,
                    const char* class_loader_context,
                    const std::string& class_loader_context_fds,
                    int swap_fd,
                    const char* instruction_set,
                    const char* compiler_filter,
                    bool debuggable,
                    bool post_bootcomplete,
                    bool for_restore,
                    int profile_fd,
                    const char* class_loader_context,
                    const std::string& class_loader_context_fds,
                    int target_sdk_version,
                    bool enable_hidden_api_checks,
                    bool generate_compact_dex,
                    int dex_metadata_fd,
                    bool use_jitzygote_image,
                    const char* compilation_reason);

@@ -57,20 +57,18 @@ class RunDex2Oat {

  protected:
    void PrepareBootImageAndBootClasspathFlags(bool use_jitzygote_image);
    void PrepareInputFileFlags(int zip_fd,
                               int oat_fd,
                               int input_vdex_fd,
                               int output_vdex_fd,
                               int image_fd,
                               const char* input_file_name,
                               const char* output_file_name,
                               int profile_fd,
                               int dex_metadata_fd,
    void PrepareInputFileFlags(const UniqueFile& output_oat,
                               const UniqueFile& output_vdex,
                               const UniqueFile& output_image,
                               const UniqueFile& input_dex,
                               const UniqueFile& input_vdex,
                               const UniqueFile& dex_metadata,
                               const UniqueFile& profile,
                               int swap_fd,
                               const char* class_loader_context,
                               const std::string& class_loader_context_fds);
    void PrepareCompilerConfigFlags(int input_vdex_fd,
                                    int output_vdex_fd,
    void PrepareCompilerConfigFlags(const UniqueFile& input_vdex,
                                    const UniqueFile& output_vdex,
                                    const char* instruction_set,
                                    const char* compiler_filter,
                                    bool debuggable,
+37 −40

File changed.

Preview size limit exceeded, changes collapsed.

Loading