Loading cmds/installd/Android.mk +37 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,43 @@ LOCAL_INIT_RC := installd.rc LOCAL_CLANG := true include $(BUILD_EXECUTABLE) # # OTA Executable # include $(CLEAR_VARS) LOCAL_MODULE := otapreopt LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := $(common_cflags) # Base & ASLR boundaries for boot image creation. ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA := -0x1000000 else LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA := $(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA) endif ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA := 0x1000000 else LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA := $(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA) endif LOCAL_CFLAGS += -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS) LOCAL_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA) LOCAL_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA) LOCAL_SRC_FILES := otapreopt.cpp $(common_src_files) LOCAL_SHARED_LIBRARIES := \ libbase \ libcutils \ liblog \ liblogwrap \ libselinux \ LOCAL_STATIC_LIBRARIES := libdiskusage LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk LOCAL_CLANG := true include $(BUILD_EXECUTABLE) # Tests. include $(LOCAL_PATH)/tests/Android.mk No newline at end of file cmds/installd/installd.cpp +31 −2 Original line number Diff line number Diff line Loading @@ -211,12 +211,41 @@ static int do_destroy_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSE return destroy_app_data(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3])); } static int do_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) static int do_ota_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { // Time to fork and run otapreopt. pid_t pid = fork(); if (pid == 0) { const char* argv[1 + 9 + 1]; argv[0] = "/system/bin/otapreopt"; for (size_t i = 1; i <= 9; ++i) { argv[i] = arg[i - 1]; } argv[10] = nullptr; execv(argv[0], (char * const *)argv); ALOGE("execv(OTAPREOPT) failed: %s\n", strerror(errno)); exit(99); } else { int res = wait_child(pid); if (res == 0) { ALOGV("DexInv: --- END OTAPREOPT (success) ---\n"); } else { ALOGE("DexInv: --- END OTAPREOPT --- status=0x%04x, process failed\n", res); } return res; } } static int do_dexopt(char **arg, char reply[REPLY_MAX]) { int dexopt_flags = atoi(arg[6]); if ((dexopt_flags & DEXOPT_OTA) != 0) { return do_ota_dexopt(arg, reply); } /* apk_path, uid, pkgname, instruction_set, dexopt_needed, oat_dir, dexopt_flags, volume_uuid, use_profiles */ return dexopt(arg[0], atoi(arg[1]), arg[2], arg[3], atoi(arg[4]), arg[5], atoi(arg[6]), parse_null(arg[7]), (atoi(arg[8]) == 0 ? false : true)); arg[5], dexopt_flags, parse_null(arg[7]), (atoi(arg[8]) == 0 ? false : true)); } static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) Loading cmds/installd/installd_constants.h +4 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory unde // This is used as a string literal, can't be constants. TODO: std::string... #define DALVIK_CACHE "dalvik-cache" constexpr const char* DALVIK_CACHE_POSTFIX = "/classes.dex"; constexpr const char* DALVIK_CACHE_POSTFIX2 = "@classes.dex"; constexpr const char* IDMAP_PREFIX = "/data/resource-cache/"; constexpr const char* IDMAP_SUFFIX = "@idmap"; Loading @@ -74,6 +75,7 @@ constexpr int DEXOPT_SAFEMODE = 1 << 2; constexpr int DEXOPT_DEBUGGABLE = 1 << 3; constexpr int DEXOPT_BOOTCOMPLETE = 1 << 4; constexpr int DEXOPT_EXTRACTONLY = 1 << 5; constexpr int DEXOPT_OTA = 1 << 6; /* all known values for dexopt flags */ constexpr int DEXOPT_MASK = Loading @@ -81,7 +83,8 @@ constexpr int DEXOPT_MASK = | DEXOPT_SAFEMODE | DEXOPT_DEBUGGABLE | DEXOPT_BOOTCOMPLETE | DEXOPT_EXTRACTONLY; | DEXOPT_EXTRACTONLY | DEXOPT_OTA; #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) Loading Loading
cmds/installd/Android.mk +37 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,43 @@ LOCAL_INIT_RC := installd.rc LOCAL_CLANG := true include $(BUILD_EXECUTABLE) # # OTA Executable # include $(CLEAR_VARS) LOCAL_MODULE := otapreopt LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := $(common_cflags) # Base & ASLR boundaries for boot image creation. ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA := -0x1000000 else LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA := $(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA) endif ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA := 0x1000000 else LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA := $(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA) endif LOCAL_CFLAGS += -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS) LOCAL_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA) LOCAL_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA) LOCAL_SRC_FILES := otapreopt.cpp $(common_src_files) LOCAL_SHARED_LIBRARIES := \ libbase \ libcutils \ liblog \ liblogwrap \ libselinux \ LOCAL_STATIC_LIBRARIES := libdiskusage LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk LOCAL_CLANG := true include $(BUILD_EXECUTABLE) # Tests. include $(LOCAL_PATH)/tests/Android.mk No newline at end of file
cmds/installd/installd.cpp +31 −2 Original line number Diff line number Diff line Loading @@ -211,12 +211,41 @@ static int do_destroy_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSE return destroy_app_data(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3])); } static int do_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) static int do_ota_dexopt(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { // Time to fork and run otapreopt. pid_t pid = fork(); if (pid == 0) { const char* argv[1 + 9 + 1]; argv[0] = "/system/bin/otapreopt"; for (size_t i = 1; i <= 9; ++i) { argv[i] = arg[i - 1]; } argv[10] = nullptr; execv(argv[0], (char * const *)argv); ALOGE("execv(OTAPREOPT) failed: %s\n", strerror(errno)); exit(99); } else { int res = wait_child(pid); if (res == 0) { ALOGV("DexInv: --- END OTAPREOPT (success) ---\n"); } else { ALOGE("DexInv: --- END OTAPREOPT --- status=0x%04x, process failed\n", res); } return res; } } static int do_dexopt(char **arg, char reply[REPLY_MAX]) { int dexopt_flags = atoi(arg[6]); if ((dexopt_flags & DEXOPT_OTA) != 0) { return do_ota_dexopt(arg, reply); } /* apk_path, uid, pkgname, instruction_set, dexopt_needed, oat_dir, dexopt_flags, volume_uuid, use_profiles */ return dexopt(arg[0], atoi(arg[1]), arg[2], arg[3], atoi(arg[4]), arg[5], atoi(arg[6]), parse_null(arg[7]), (atoi(arg[8]) == 0 ? false : true)); arg[5], dexopt_flags, parse_null(arg[7]), (atoi(arg[8]) == 0 ? false : true)); } static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) Loading
cmds/installd/installd_constants.h +4 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory unde // This is used as a string literal, can't be constants. TODO: std::string... #define DALVIK_CACHE "dalvik-cache" constexpr const char* DALVIK_CACHE_POSTFIX = "/classes.dex"; constexpr const char* DALVIK_CACHE_POSTFIX2 = "@classes.dex"; constexpr const char* IDMAP_PREFIX = "/data/resource-cache/"; constexpr const char* IDMAP_SUFFIX = "@idmap"; Loading @@ -74,6 +75,7 @@ constexpr int DEXOPT_SAFEMODE = 1 << 2; constexpr int DEXOPT_DEBUGGABLE = 1 << 3; constexpr int DEXOPT_BOOTCOMPLETE = 1 << 4; constexpr int DEXOPT_EXTRACTONLY = 1 << 5; constexpr int DEXOPT_OTA = 1 << 6; /* all known values for dexopt flags */ constexpr int DEXOPT_MASK = Loading @@ -81,7 +83,8 @@ constexpr int DEXOPT_MASK = | DEXOPT_SAFEMODE | DEXOPT_DEBUGGABLE | DEXOPT_BOOTCOMPLETE | DEXOPT_EXTRACTONLY; | DEXOPT_EXTRACTONLY | DEXOPT_OTA; #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) Loading