diff --git a/Android.mk b/Android.mk index a750252f..1659e833 100755 --- a/Android.mk +++ b/Android.mk @@ -36,11 +36,6 @@ endif ifeq ($(PROJECT_PATH_AGREES),true) -ifneq (,$(filter $(PLATFORM_SDK_VERSION), 21 22)) -# Make recovery domain permissive for TWRP - BOARD_SEPOLICY_UNION += twrp.te -endif - ifeq ($(CM_PLATFORM_SDK_VERSION),) CM_PLATFORM_SDK_VERSION := 0 endif @@ -79,26 +74,25 @@ LOCAL_SRC_FILES := \ openrecoveryscript.cpp \ tarWrite.c \ twrpAdbBuFifo.cpp \ - twrpApex.cpp + twrpApex.cpp \ + twrpRepacker.cpp -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - LOCAL_STATIC_LIBRARIES += libavb - LOCAL_SHARED_LIBRARIES += libfs_mgr libinit - ifeq ($(TW_INCLUDE_CRYPTO),true) - LOCAL_CFLAGS += -DUSE_FSCRYPT -Wno-macro-redefined - LOCAL_C_INCLUDES += bootable/recovery/crypto/fscrypt \ - bootable/recovery/crypto - endif - LOCAL_C_INCLUDES += \ - system/core/fs_mgr/libfs_avb/include/ \ - system/core/fs_mgr/include_fstab/ \ - system/core/fs_mgr/include/ \ - system/core/fs_mgr/libdm/include/ \ - system/core/fs_mgr/liblp/include/ \ - system/gsid/include/ \ - system/core/init/ \ - system/extras/ext4_utils/include +LOCAL_STATIC_LIBRARIES += libavb +LOCAL_SHARED_LIBRARIES += libfs_mgr libinit +ifeq ($(TW_INCLUDE_CRYPTO),true) + LOCAL_CFLAGS += -DUSE_FSCRYPT -Wno-macro-redefined + LOCAL_C_INCLUDES += bootable/recovery/crypto/fscrypt \ + bootable/recovery/crypto endif +LOCAL_C_INCLUDES += \ + system/core/fs_mgr/libfs_avb/include/ \ + system/core/fs_mgr/include_fstab/ \ + system/core/fs_mgr/include/ \ + system/core/fs_mgr/libdm/include/ \ + system/core/fs_mgr/liblp/include/ \ + system/gsid/include/ \ + system/core/init/ \ + system/extras/ext4_utils/include ifneq ($(TARGET_RECOVERY_REBOOT_SRC),) LOCAL_SRC_FILES += $(TARGET_RECOVERY_REBOOT_SRC) @@ -113,71 +107,30 @@ LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function LOCAL_CLANG := true LOCAL_C_INCLUDES += \ + bionic \ system/vold \ system/extras \ system/core/adb \ system/core/libsparse \ external/zlib \ system/core/libpixelflinger/include \ + system/core/libziparchive/include \ external/freetype/include \ + external/boringssl/include \ + external/libcxx/include \ + external/libselinux/include \ $(LOCAL_PATH)/bootloader_message_twrp/include \ $(LOCAL_PATH)/recovery_ui/include \ $(LOCAL_PATH)/otautil/include \ - $(LOCAL_PATH)/install/include - -LOCAL_C_INCLUDES += bionic -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0) - LOCAL_C_INCLUDES += external/stlport/stlport external/openssl/include - LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22 -else - ifeq ($shell test $(PLATFORM_SDK_VERSION) -lt 29; echo $$?),0) - LOCAL_C_INCLUDES += $(LOCAL_PATH)/fuse_sideload28/ - else - LOCAL_C_FLAGS += -DUSE_OLD_LOAD_KEYS - LOCAL_C_INCLUDES += $(LOCAL_PATH)/fuse_sideload/include \ - $(LOCAL_PATH)/install/include - endif - LOCAL_C_INCLUDES += external/boringssl/include external/libcxx/include -endif + $(LOCAL_PATH)/install/include \ + $(LOCAL_PATH)/fuse_sideload/include \ + $(LOCAL_PATH)/install/include \ + $(LOCAL_PATH)/verifier28/ LOCAL_STATIC_LIBRARIES += libguitwrp LOCAL_SHARED_LIBRARIES += libz libc libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libtwadbbu libbootloader_message_twrp -LOCAL_SHARED_LIBRARIES += libcrecovery libtwadbbu libtwrpdigest libc++ libaosprecovery - -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0) - LOCAL_SHARED_LIBRARIES += libstlport - LOCAL_CFLAGS += -DTW_NO_SHA2_LIBRARY -endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0) - LOCAL_SHARED_LIBRARIES += libmincrypttwrp - LOCAL_C_INCLUDES += $(LOCAL_PATH)/libmincrypt/includes - LOCAL_CFLAGS += -DUSE_OLD_VERIFIER -else - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -le 29; echo $$?),0) - LOCAL_C_INCLUDES += $(LOCAL_PATH)/verifier28/ - LOCAL_CFLAGS += -DUSE_28_VERIFIER - else - LOCAL_C_INCLUDES += $(LOCAL_PATH)/install/include - endif - LOCAL_SHARED_LIBRARIES += libcrypto -endif - -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 23; echo $$?),0) - LOCAL_SHARED_LIBRARIES += libbase -endif - -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 29; echo $$?),0) - LOCAL_SHARED_LIBRARIES += libziparchive - LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include system/core/libziparchive/include - else - LOCAL_SHARED_LIBRARIES += libziparchive - LOCAL_C_INCLUDES += system/core/libziparchive/include - endif -else - LOCAL_SHARED_LIBRARIES += libminzip - LOCAL_CFLAGS += -DUSE_MINZIP -endif +LOCAL_SHARED_LIBRARIES += libcrecovery libtwadbbu libtwrpdigest libc++ libaosprecovery libinit libcrypto libbase libziparchive libselinux +LOCAL_CFLAGS += -DUSE_28_VERIFIER ifneq ($(wildcard system/core/libsparse/Android.mk),) LOCAL_SHARED_LIBRARIES += libsparse @@ -190,23 +143,6 @@ ifeq ($(TW_OEM_BUILD),true) TW_EXCLUDE_MTP := true endif -ifeq ($(TARGET_USERIMAGES_USE_EXT4), true) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 28; echo $$?),0) - LOCAL_CFLAGS += -DUSE_EXT4 - endif - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -le 28; echo $$?),0) - LOCAL_C_INCLUDES += system/extras/ext4_utils \ - system/extras/ext4_utils/include \ - $(commands_TWRP_local_path)/crypto/ext4crypt - LOCAL_SHARED_LIBRARIES += libext4_utils - ifneq ($(wildcard external/lz4/Android.mk),) - #LOCAL_STATIC_LIBRARIES += liblz4 - endif - endif -endif -LOCAL_C_INCLUDES += external/libselinux/include -LOCAL_SHARED_LIBRARIES += libselinux - ifeq ($(AB_OTA_UPDATER),true) LOCAL_CFLAGS += -DAB_OTA_UPDATER=1 LOCAL_SHARED_LIBRARIES += libhardware android.hardware.boot@1.0 @@ -221,7 +157,7 @@ ifeq ($(TW_NO_BIND_SYSTEM),true) LOCAL_CFLAGS += -DTW_NO_BIND_SYSTEM endif -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin ifeq ($(TARGET_RECOVERY_TWRP_LIB),) LOCAL_SRC_FILES += BasePartition.cpp @@ -237,7 +173,6 @@ ifeq ($(shell git -C $(LOCAL_PATH) diff --quiet; echo $$?),1) endif LOCAL_CFLAGS += -DTW_GIT_REVISION='"$(tw_git_revision)"' -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) ifeq ($(TW_FORCE_USE_BUSYBOX), true) TW_USE_TOOLBOX := false else @@ -246,12 +181,6 @@ endif ifeq ($(TW_EXCLUDE_MTP),) LOCAL_SHARED_LIBRARIES += libtwrpmtp-ffs endif -else -ifeq ($(TW_EXCLUDE_MTP),) - LOCAL_CFLAGS += -DTW_HAS_LEGACY_MTP - LOCAL_SHARED_LIBRARIES += libtwrpmtp-legacy -endif -endif #TWRP Build Flags ifeq ($(TW_EXCLUDE_MTP),) @@ -351,23 +280,14 @@ ifeq ($(TW_INCLUDE_CRYPTO), true) LOCAL_CFLAGS += -DTW_INCLUDE_CRYPTO LOCAL_SHARED_LIBRARIES += libcryptfsfde libgpt_twrp LOCAL_C_INCLUDES += external/boringssl/src/include - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0) - TW_INCLUDE_CRYPTO_FBE := true - LOCAL_CFLAGS += -DTW_INCLUDE_FBE - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - LOCAL_SHARED_LIBRARIES += libtwrpfscrypt - else - LOCAL_SHARED_LIBRARIES += libe4crypt - endif - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - LOCAL_CFLAGS += -DTW_INCLUDE_FBE_METADATA_DECRYPT - endif - endif + TW_INCLUDE_CRYPTO_FBE := true + LOCAL_CFLAGS += -DTW_INCLUDE_FBE + LOCAL_SHARED_LIBRARIES += libtwrpfscrypt android.frameworks.stats@1.0 android.hardware.authsecret@1.0 \ + android.hardware.oemlock@1.0 + LOCAL_CFLAGS += -DTW_INCLUDE_FBE_METADATA_DECRYPT ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),) ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),false) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) - TW_INCLUDE_LIBRESETPROP := true - endif + TW_INCLUDE_LIBRESETPROP := true LOCAL_CFLAGS += -DTW_CRYPTO_USE_SYSTEM_VOLD LOCAL_STATIC_LIBRARIES += libvolddecrypt endif @@ -422,9 +342,7 @@ endif ifneq ($(TARGET_RECOVERY_INITRC),) TW_EXCLUDE_DEFAULT_USB_INIT := true endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) - LOCAL_CFLAGS += -DTW_USE_NEW_MINADBD -endif +LOCAL_CFLAGS += -DTW_USE_NEW_MINADBD ifneq ($(TW_DEFAULT_LANGUAGE),) LOCAL_CFLAGS += -DTW_DEFAULT_LANGUAGE=$(TW_DEFAULT_LANGUAGE) else @@ -438,17 +356,14 @@ ifneq ($(TW_OVERRIDE_SYSTEM_PROPS),) LOCAL_CFLAGS += -DTW_OVERRIDE_SYSTEM_PROPS=$(TW_OVERRIDE_SYSTEM_PROPS) endif ifneq ($(TW_INCLUDE_LIBRESETPROP),) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0) - $(warning libresetprop is not available for android < 7) - else - LOCAL_SHARED_LIBRARIES += libresetprop - LOCAL_C_INCLUDES += external/magisk-prebuilt/include - LOCAL_CFLAGS += -DTW_INCLUDE_LIBRESETPROP - endif + LOCAL_SHARED_LIBRARIES += libresetprop + LOCAL_C_INCLUDES += external/magisk-prebuilt/include + LOCAL_CFLAGS += -DTW_INCLUDE_LIBRESETPROP endif TWRP_REQUIRED_MODULES += \ - relink \ + relink_libraries \ + relink_binaries \ twrp_ramdisk \ dump_image \ erase_image \ @@ -467,30 +382,23 @@ TWRP_REQUIRED_MODULES += \ init.recovery.service.rc \ init.recovery.ldconfig.rc \ awk \ + toybox \ + toolbox \ + mkshrc_twrp ifneq ($(TW_INCLUDE_CRYPTO),) TWRP_REQUIRED_MODULES += \ plat_service_contexts \ plat_hwservice_contexts \ vendor_hwservice_contexts \ - vndservice_contexts \ hwservicemanager \ servicemanager \ vndservicemanager \ vold_prepare_subdirs \ + task_recovery_profiles.json \ fscryptpolicyget endif -ifneq ($(TARGET_ARCH), arm64) - ifneq ($(TARGET_ARCH), x86_64) - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker - else - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 - endif -else - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 -endif - ifneq ($(wildcard external/zip/Android.mk),) TWRP_REQUIRED_MODULES += zip endif @@ -505,11 +413,7 @@ ifneq ($(TW_NO_EXFAT), true) endif endif ifeq ($(BOARD_HAS_NO_REAL_SDCARD),) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) - TWRP_REQUIRED_MODULES += sgdisk - else - TWRP_REQUIRED_MODULES += sgdisk_static - endif + TWRP_REQUIRED_MODULES += sgdisk endif ifneq ($(TW_EXCLUDE_ENCRYPTED_BACKUPS), true) TWRP_REQUIRED_MODULES += openaes openaes_license @@ -535,7 +439,7 @@ ifneq ($(TW_EXCLUDE_DEFAULT_USB_INIT), true) TWRP_REQUIRED_MODULES += init.recovery.usb.rc endif ifeq ($(TWRP_INCLUDE_LOGCAT), true) - TWRP_REQUIRED_MODULES += logcat + TWRP_REQUIRED_MODULES += logcat event-log-tags ifeq ($(TARGET_USES_LOGD), true) TWRP_REQUIRED_MODULES += logd libsysutils libnl init.recovery.logd.rc endif @@ -547,66 +451,25 @@ endif LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\" LOCAL_CFLAGS += -DTWHTCD_PATH=\"$(TWHTCD_PATH)\" ifeq ($(TW_INCLUDE_NTFS_3G),true) -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) TWRP_REQUIRED_MODULES += \ mount.ntfs \ fsck.ntfs \ mkfs.ntfs -else - TWRP_REQUIRED_MODULES += \ - ntfs-3g \ - ntfsfix \ - mkntfs -endif endif ifeq ($(TARGET_USERIMAGES_USE_F2FS), true) -ifeq ($(shell test $(CM_PLATFORM_SDK_VERSION) -ge 3; echo $$?),0) - TWRP_REQUIRED_MODULES += \ - fsck.f2fs \ - mkfs.f2fs -endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) TWRP_REQUIRED_MODULES += sload.f2fs \ libfs_mgr \ fs_mgr \ libinit endif + +TWRP_REQUIRED_MODULES += file_contexts_text + +ifeq ($(BOARD_CACHEIMAGE_PARTITION_SIZE),) + TWRP_REQUIRED_MODULES += recovery-persist recovery-refresh endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) - TWRP_REQUIRED_MODULES += ld.config.txt - ifeq ($(BOARD_VNDK_RUNTIME_DISABLE),true) - LOCAL_POST_INSTALL_CMD += \ - sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths = \/sbin\n\1 +=/' \ - $(TARGET_OUT_ETC)/ld.config.vndk_lite.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt; - else - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - LOCAL_POST_INSTALL_CMD += \ - sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths = \/sbin\n\1 +=/' \ - $(TARGET_RECOVERY_ROOT_OUT)/system/etc/ld.config.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt - else - LOCAL_POST_INSTALL_CMD += \ - sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths = \/sbin\n\1 +=/' \ - $(TARGET_OUT_ETC)/ld.config.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt; - endif - endif -endif - -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 25; echo $$?),0) - TWRP_REQUIRED_MODULES += file_contexts_text -endif - -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0) - ifeq ($(BOARD_CACHEIMAGE_PARTITION_SIZE),) - TWRP_REQUIRED_MODULES += recovery-persist recovery-refresh - endif -endif - -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - LOCAL_REQUIRED_MODULES += $(TWRP_REQUIRED_MODULES) -else - LOCAL_ADDITIONAL_DEPENDENCIES += $(TWRP_REQUIRED_MODULES) -endif +LOCAL_REQUIRED_MODULES += $(TWRP_REQUIRED_MODULES) include $(BUILD_EXECUTABLE) @@ -615,11 +478,8 @@ include $(CLEAR_VARS) LOCAL_MODULE := file_contexts_text LOCAL_MODULE_TAGS := optional -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - LOCAL_REQUIRED_MODULES := file_contexts.bin -else - LOCAL_ADDITIONAL_DEPENDENCIES := file_contexts.bin -endif +LOCAL_REQUIRED_MODULES := file_contexts.bin + LOCAL_POST_INSTALL_CMD := \ $(hide) cp -f $(PRODUCT_OUT)/obj/ETC/file_contexts.bin_intermediates/file_contexts.concat.tmp $(TARGET_RECOVERY_ROOT_OUT)/file_contexts @@ -627,69 +487,31 @@ include $(BUILD_PHONY_PACKAGE) # recovery-persist (system partition dynamic executable run after /data mounts) # =============================== -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0) - include $(CLEAR_VARS) - LOCAL_SRC_FILES := \ - recovery-persist.cpp - LOCAL_MODULE := recovery-persist - LOCAL_SHARED_LIBRARIES := liblog libbase libmetricslogger - LOCAL_STATIC_LIBRARIES := libotautil - LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - LOCAL_C_INCLUDES += system/core/libmetricslogger/include \ - system/core/libstats/include - endif - LOCAL_CFLAGS := -Werror - LOCAL_INIT_RC := recovery-persist.rc - include $(BUILD_EXECUTABLE) -endif +include $(CLEAR_VARS) +LOCAL_SRC_FILES := \ + recovery-persist.cpp +LOCAL_MODULE := recovery-persist +LOCAL_SHARED_LIBRARIES := liblog libbase libmetricslogger +LOCAL_STATIC_LIBRARIES := libotautil +LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include +LOCAL_C_INCLUDES += system/core/libmetricslogger/include \ + system/core/libstats/include +LOCAL_CFLAGS := -Werror +LOCAL_INIT_RC := recovery-persist.rc +include $(BUILD_EXECUTABLE) # recovery-refresh (system partition dynamic executable run at init) # =============================== -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0) - include $(CLEAR_VARS) - LOCAL_SRC_FILES := \ - recovery-refresh.cpp - LOCAL_MODULE := recovery-refresh - LOCAL_SHARED_LIBRARIES := liblog libbase - LOCAL_STATIC_LIBRARIES := libotautil - LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include - LOCAL_CFLAGS := -Werror - LOCAL_INIT_RC := recovery-refresh.rc - include $(BUILD_EXECUTABLE) -endif - -# shared libfusesideload -# =============================== -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 29; echo $$?),0) - include $(CLEAR_VARS) - LOCAL_CLANG := true - LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter - LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE - - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE := libfusesideload - LOCAL_SHARED_LIBRARIES := libcutils libc - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0) - LOCAL_C_INCLUDES := $(LOCAL_PATH)/libmincrypt/includes - LOCAL_SHARED_LIBRARIES += libmincrypttwrp - LOCAL_CFLAGS += -DUSE_MINCRYPT - else - LOCAL_SHARED_LIBRARIES += libcrypto libbase - endif - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0) - LOCAL_SRC_FILES := fuse_sideload22.cpp - LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22 - else - # ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 29; echo $$?),0) - LOCAL_SRC_FILES := fuse_sideload28/fuse_sideload.cpp - # else - # LOCAL_SRC_FILES := fuse_sideload/fuse_sideload.cpp \ - fuse_sideload/fuse_provider.cpp - # endif - endif - include $(BUILD_SHARED_LIBRARY) -endif +include $(CLEAR_VARS) +LOCAL_SRC_FILES := \ + recovery-refresh.cpp +LOCAL_MODULE := recovery-refresh +LOCAL_SHARED_LIBRARIES := liblog libbase +LOCAL_STATIC_LIBRARIES := libotautil +LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include +LOCAL_CFLAGS := -Werror +LOCAL_INIT_RC := recovery-refresh.rc +include $(BUILD_EXECUTABLE) # libmounts (static library) # =============================== @@ -733,75 +555,30 @@ include $(CLEAR_VARS) LOCAL_MODULE := libaosprecovery LOCAL_MODULE_TAGS := optional -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 29; echo $$?),0) - LOCAL_SRC_FILES := install28/adb_install.cpp legacy_property_service.cpp set_metadata.cpp tw_atomic.cpp \ - installcommand.cpp zipwrap.cpp -else - LOCAL_SRC_FILES := install/adb_install.cpp install/asn1_decoder.cpp install/fuse_sdcard_install.cpp\ - install/install.cpp install/installcommand.cpp install/legacy_property_service.cpp \ - install/package.cpp install/verifier.cpp install/wipe_data.cpp install/tw_atomic.cpp \ - install/set_metadata.cpp verifier28/verifier.cpp install/zipwrap.cpp install/ZipUtil.cpp -endif + +LOCAL_SRC_FILES := install/adb_install.cpp install/asn1_decoder.cpp install/fuse_sdcard_install.cpp\ + install/install.cpp install/installcommand.cpp install/legacy_property_service.cpp \ + install/package.cpp install/verifier.cpp install/wipe_data.cpp install/tw_atomic.cpp \ + install/set_metadata.cpp verifier28/verifier.cpp install/zipwrap.cpp install/ZipUtil.cpp LOCAL_SHARED_LIBRARIES += libbase libbootloader_message libcrypto libext4_utils \ libfs_mgr libfusesideload libhidl-gen-utils libhidlbase \ liblog libselinux libtinyxml2 libutils libz libziparchive libcutils LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0) - LOCAL_SHARED_LIBRARIES += libstdc++ libstlport - LOCAL_C_INCLUDES += bionic external/stlport/stlport - LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22 -else - LOCAL_SHARED_LIBRARIES += libc++ -endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0) - LOCAL_SHARED_LIBRARIES += libmincrypttwrp - LOCAL_C_INCLUDES += $(LOCAL_PATH)/libmincrypt/includes - LOCAL_SRC_FILES += verifier24/verifier.cpp verifier24/asn1_decoder.cpp - LOCAL_CFLAGS += -DUSE_OLD_VERIFIER -else - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 24; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 28; echo $$?),0) - LOCAL_CFLAGS := -std=gnu++2a - LOCAL_C_INCLUDES += $(commands_TWRP_local_path)/install/include \ - $(commands_TWRP_local_path)/recovery_ui/include \ - $(commands_TWRP_local_path)/otautil/include \ - $(commands_TWRP_local_path)/minadbd \ - $(commands_TWRP_local_path)/minzip \ - system/libvintf/include - LOCAL_STATIC_LIBRARIES += libotautil libvintf_recovery libvintf - else - LOCAL_C_INCLUDES += $(commands_TWRP_local_path)/install28/ - LOCAL_CFLAGS += -DUSE_28_INSTALL - endif - LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) - else - LOCAL_SHARED_LIBRARIES += libcrypto libbase - LOCAL_SRC_FILES += verifier28/verifier.cpp verifier28/asn1_decoder.cpp - LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include $(LOCAL_PATH)/verifier28 \ - system/libvintf/include - LOCAL_CFLAGS += -DUSE_28_VERIFIER - endif -endif +LOCAL_SHARED_LIBRARIES += libc++ +LOCAL_CFLAGS := -std=gnu++2a +LOCAL_C_INCLUDES += $(commands_TWRP_local_path)/install/include \ + $(commands_TWRP_local_path)/recovery_ui/include \ + $(commands_TWRP_local_path)/otautil/include \ + $(commands_TWRP_local_path)/minadbd \ + $(commands_TWRP_local_path)/minzip \ + system/libvintf/include +LOCAL_STATIC_LIBRARIES += libotautil libvintf_recovery libvintf libhidl-gen-utils +LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) ifeq ($(AB_OTA_UPDATER),true) LOCAL_CFLAGS += -DAB_OTA_UPDATER=1 endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 29; echo $$?),0) - # LOCAL_SRC_FILES += otautil/ZipUtil.cpp otautil/SysUtil.cpp otautil/DirUtil.cpp - LOCAL_SHARED_LIBRARIES += libziparchive libext4_utils libcrypto libcrypto_utils libfs_mgr - LOCAL_STATIC_LIBRARIES += libvintf_recovery liblogwrap libavb libvintf libtinyxml2 libz - LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 27; echo $$?),0) - # Android 9.0's libvintf also needs this library - LOCAL_STATIC_LIBRARIES += libhidl-gen-utils - endif - endif -else - LOCAL_CFLAGS += -DUSE_MINZIP -endif - include $(BUILD_SHARED_LIBRARY) # libverifier (static library) @@ -831,34 +608,16 @@ include \ $(commands_TWRP_local_path)/updater/Android.mk \ $(commands_TWRP_local_path)/bootloader_message_twrp/Android.mk -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -le 25; echo $$?),0) -include $(commands_TWRP_local_path)/bootloader_message/Android.mk -endif - -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - include $(commands_TWRP_local_path)/mtp/ffs/Android.mk -else - include $(commands_TWRP_local_path)/mtp/legacy/Android.mk -endif +include $(commands_TWRP_local_path)/mtp/ffs/Android.mk ifeq ($(wildcard system/core/uncrypt/Android.mk),) #include $(commands_TWRP_local_path)/uncrypt/Android.mk endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 26; echo $$?),0) - TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_WITH_DATA - CLANG_TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_WITH_DATA - endif - include $(commands_TWRP_local_path)/minadbd/Android.mk \ - $(commands_TWRP_local_path)/minui/Android.mk -else - TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_21 - include $(commands_TWRP_local_path)/minadbd21/Android.mk \ - $(commands_TWRP_local_path)/minui21/Android.mk -endif +include $(commands_TWRP_local_path)/minadbd/Android.mk \ + $(commands_TWRP_local_path)/minui/Android.mk - # $(commands_TWRP_local_path)/otautil/Android.mk \ +# $(commands_TWRP_local_path)/otautil/Android.mk \ #includes for TWRP include $(commands_TWRP_local_path)/injecttwrp/Android.mk \ @@ -885,10 +644,6 @@ include $(commands_TWRP_local_path)/injecttwrp/Android.mk \ $(commands_TWRP_local_path)/twrpDigest/Android.mk \ $(commands_TWRP_local_path)/attr/Android.mk -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0) - include $(commands_TWRP_local_path)/libmincrypt/Android.mk -endif - ifneq ($(TW_OZIP_DECRYPT_KEY),) TWRP_REQUIRED_MODULES += ozip_decrypt include $(commands_TWRP_local_path)/ozip_decrypt/Android.mk @@ -898,11 +653,7 @@ ifeq ($(TW_INCLUDE_CRYPTO), true) include $(commands_TWRP_local_path)/crypto/fde/Android.mk include $(commands_TWRP_local_path)/crypto/scrypt/Android.mk ifeq ($(TW_INCLUDE_CRYPTO_FBE), true) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - include $(commands_TWRP_local_path)/crypto/fscrypt/Android.mk - else - include $(commands_TWRP_local_path)/crypto/ext4crypt/Android.mk - endif + include $(commands_TWRP_local_path)/crypto/fscrypt/Android.mk endif ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),) ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),false) diff --git a/adbbu/Android.mk b/adbbu/Android.mk old mode 100644 new mode 100755 index e2719389..23a58f3b --- a/adbbu/Android.mk +++ b/adbbu/Android.mk @@ -43,6 +43,6 @@ LOCAL_MODULE:= twrpbu LOCAL_MODULE_STEM := bu LOCAL_MODULE_TAGS:= optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ include $(BUILD_EXECUTABLE) diff --git a/attr/Android.mk b/attr/Android.mk old mode 100644 new mode 100755 index ab1d892e..121ae02d --- a/attr/Android.mk +++ b/attr/Android.mk @@ -6,17 +6,17 @@ LOCAL_CFLAGS := -c -W LOCAL_MODULE := listxattr LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_PACK_MODULE_RELOCATIONS := false ifneq ($(TARGET_ARCH), arm64) ifneq ($(TARGET_ARCH), x86_64) - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker + LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker else - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 + LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64 endif else - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 + LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64 endif include $(BUILD_EXECUTABLE) diff --git a/bmlutils/bmlutils.c b/bmlutils/bmlutils.c old mode 100644 new mode 100755 index b5da0789..382c0a5f --- a/bmlutils/bmlutils.c +++ b/bmlutils/bmlutils.c @@ -180,14 +180,14 @@ int format_rfs_device (const char *device, const char *path) { // dump 10KB of zeros to partition before format due to fat.format bug char cmd[PATH_MAX]; - sprintf(cmd, "/sbin/dd if=/dev/zero of=%s bs=4096 count=10", device); + sprintf(cmd, "/system/bin/dd if=/dev/zero of=%s bs=4096 count=10", device); if(__system(cmd)) { printf("failure while zeroing rfs partition.\n"); return -1; } // Run fat.format - sprintf(cmd, "/sbin/fat.format -F %s -S 4096 -s %s %s", fatsize, sectorsize, device); + sprintf(cmd, "/system/bin/fat.format -F %s -S 4096 -s %s %s", fatsize, sectorsize, device); if(__system(cmd)) { printf("failure while running fat.format\n"); return -1; diff --git a/crypto/ext4crypt/Android.mk b/crypto/ext4crypt/Android.mk index 955bd3b8..8b1372b5 100755 --- a/crypto/ext4crypt/Android.mk +++ b/crypto/ext4crypt/Android.mk @@ -75,10 +75,9 @@ include $(CLEAR_VARS) LOCAL_MODULE := twrpfbe LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_SRC_FILES := main.cpp LOCAL_SHARED_LIBRARIES := libe4crypt -#LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 include $(BUILD_EXECUTABLE) @@ -86,10 +85,10 @@ include $(CLEAR_VARS) LOCAL_MODULE := e4policyget LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_SRC_FILES := e4policyget.cpp LOCAL_SHARED_LIBRARIES := libe4crypt -LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 +LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64 include $(BUILD_EXECUTABLE) @@ -97,7 +96,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := keystore_auth LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_SRC_FILES := keystore_auth.cpp LOCAL_SHARED_LIBRARIES := libc libkeystore_binder libutils libbinder liblog ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) @@ -105,7 +104,7 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) LOCAL_CFLAGS += -DUSE_SECURITY_NAMESPACE LOCAL_SHARED_LIBRARIES += libkeystore_aidl endif -LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 +LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64 include $(BUILD_EXECUTABLE) diff --git a/crypto/ext4crypt/Decrypt.cpp b/crypto/ext4crypt/Decrypt.cpp index dcd390f1..85d14eaf 100755 --- a/crypto/ext4crypt/Decrypt.cpp +++ b/crypto/ext4crypt/Decrypt.cpp @@ -659,7 +659,7 @@ std::string unwrapSyntheticPasswordBlob(const std::string& spblob_path, const st if (auth_wait_count == 0 || access("/auth_error", F_OK) == 0) { printf("error during keymaster_auth service\n"); /* If you are getting this error, make sure that you have the keymaster_auth service defined in your init scripts, preferrably in init.recovery.{ro.hardware}.rc - * service keystore_auth /sbin/keystore_auth + * service keystore_auth /system/bin/keystore_auth * disabled * oneshot * user system @@ -804,7 +804,7 @@ std::string unwrapSyntheticPasswordBlob(const std::string& spblob_path, const st if (auth_wait_count == 0 || access("/auth_error", F_OK) == 0) { printf("error during keymaster_auth service\n"); /* If you are getting this error, make sure that you have the keymaster_auth service defined in your init scripts, preferrably in init.recovery.{ro.hardware}.rc - * service keystore_auth /sbin/keystore_auth + * service keystore_auth /system/bin/keystore_auth * disabled * oneshot * user system diff --git a/crypto/fde/Android.mk b/crypto/fde/Android.mk index 4fd8b0b7..f78697f7 100755 --- a/crypto/fde/Android.mk +++ b/crypto/fde/Android.mk @@ -65,7 +65,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := twrpdec LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_SRC_FILES := main.cpp cryptfs.cpp LOCAL_SHARED_LIBRARIES := libcrypto libhardware libcutils libc libstdc++ LOCAL_C_INCLUDES := external/openssl/include $(commands_recovery_local_path)/crypto/scrypt/lib/crypto diff --git a/crypto/fscrypt/Android.mk b/crypto/fscrypt/Android.mk index 8000d5e1..0fa36c8a 100755 --- a/crypto/fscrypt/Android.mk +++ b/crypto/fscrypt/Android.mk @@ -49,7 +49,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := twrpfbe LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SRC_FILES := main.cpp LOCAL_SHARED_LIBRARIES := libtwrpfscrypt @@ -59,10 +59,9 @@ include $(CLEAR_VARS) LOCAL_MODULE := fscryptpolicyget LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SRC_FILES := fscryptpolicyget.cpp LOCAL_SHARED_LIBRARIES := libtwrpfscrypt -LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 include $(BUILD_EXECUTABLE) @@ -70,12 +69,11 @@ include $(CLEAR_VARS) LOCAL_MODULE := keystore_auth LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SRC_FILES := keystore_auth.cpp LOCAL_SHARED_LIBRARIES := libc libkeystore_binder libutils libbinder liblog LOCAL_CFLAGS += -DUSE_SECURITY_NAMESPACE LOCAL_SHARED_LIBRARIES += libkeystore_aidl -LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 include $(BUILD_EXECUTABLE) diff --git a/crypto/fscrypt/Decrypt.cpp b/crypto/fscrypt/Decrypt.cpp index b1a43c93..bd3d0679 100755 --- a/crypto/fscrypt/Decrypt.cpp +++ b/crypto/fscrypt/Decrypt.cpp @@ -629,7 +629,7 @@ std::string unwrapSyntheticPasswordBlob(const std::string& spblob_path, const st if (auth_wait_count == 0 || access("/auth_error", F_OK) == 0) { printf("error during keymaster_auth service\n"); /* If you are getting this error, make sure that you have the keymaster_auth service defined in your init scripts, preferrably in init.recovery.{ro.hardware}.rc - * service keystore_auth /sbin/keystore_auth + * service keystore_auth /system/bin/keystore_auth * disabled * oneshot * user system diff --git a/crypto/fscrypt/FsCrypt.cpp b/crypto/fscrypt/FsCrypt.cpp index 397f131e..5d68fce8 100755 --- a/crypto/fscrypt/FsCrypt.cpp +++ b/crypto/fscrypt/FsCrypt.cpp @@ -89,7 +89,7 @@ const std::string device_key_temp = device_key_dir + "/temp"; const std::string user_key_dir = std::string() + DATA_MNT_POINT + "/misc/vold/user_keys"; const std::string user_key_temp = user_key_dir + "/temp"; -const std::string prepare_subdirs_path = "/sbin/vold_prepare_subdirs"; +const std::string prepare_subdirs_path = "/system/bin/vold_prepare_subdirs"; const std::string systemwide_volume_key_dir = std::string() + DATA_MNT_POINT + "/misc/vold/volume_keys"; diff --git a/crypto/vold_decrypt/Android.mk b/crypto/vold_decrypt/Android.mk old mode 100644 new mode 100755 index 25d6ab0f..a36abf49 --- a/crypto/vold_decrypt/Android.mk +++ b/crypto/vold_decrypt/Android.mk @@ -128,7 +128,7 @@ ifeq ($(TW_INCLUDE_CRYPTO), true) LOCAL_SRC_FILES := vdc_pie.cpp LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_CLANG := true LOCAL_TIDY := true LOCAL_TIDY_FLAGS := -warnings-as-errors=clang-analyzer-security*,cert-* @@ -141,12 +141,12 @@ ifeq ($(TW_INCLUDE_CRYPTO), true) endif ifneq ($(TARGET_ARCH), arm64) ifneq ($(TARGET_ARCH), x86_64) - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker + LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker else - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 + LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64 endif else - LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 + LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64 endif include $(BUILD_EXECUTABLE) diff --git a/crypto/vold_decrypt/vold_decrypt.cpp b/crypto/vold_decrypt/vold_decrypt.cpp index 078cd5fa..4a76405d 100755 --- a/crypto/vold_decrypt/vold_decrypt.cpp +++ b/crypto/vold_decrypt/vold_decrypt.cpp @@ -81,7 +81,7 @@ int sdkver = 20; #ifdef TW_CRYPTO_SYSTEM_VOLD_DEBUG #ifndef VD_STRACE_BIN -#define VD_STRACE_BIN "/sbin/strace" +#define VD_STRACE_BIN "/system/bin/strace" #endif bool has_strace = false; @@ -399,7 +399,7 @@ void Symlink_Firmware_Files(bool is_vendor_symlinked, bool is_firmware_symlinked LOGINFO("%d file(s) symlinked.\n", (int)FirmwareFiles.size()); } -// Android 8.0 fs_mgr checks for "/sbin/recovery", in which case it will +// Android 8.0 fs_mgr checks for "/system/bin/recovery", in which case it will // use /etc/recovery.fstab -> symlink it temporarily. Reference: // https://android.googlesource.com/platform/system/core/+/android-8.0.0_r17/fs_mgr/fs_mgr_fstab.cpp#693 bool Symlink_Recovery_Fstab(void) { @@ -716,8 +716,8 @@ vector Get_List_Of_Additional_Services(void) { if (Service_Exists(services[j].Service_Name)) services[j].TWRP_Service_Name = services[j].Service_Name; - else if (Service_Exists("sbin" + services[j].Service_Name)) - services[j].TWRP_Service_Name = "sbin" + services[j].Service_Name; + else if (Service_Exists("system/bin" + services[j].Service_Name)) + services[j].TWRP_Service_Name = "system/bin" + services[j].Service_Name; else services[j].TWRP_Service_Name.clear(); @@ -995,7 +995,7 @@ int Exec_vdc_cryptfs(const string& command, const string& argument, vdc_ReturnVa } // getpwtype and checkpw commands are removed from Pie vdc, using modified vdc_pie - const char *cmd[] = { "/sbin/vdc_pie", "cryptfs" }; + const char *cmd[] = { "/system/bin/vdc_pie", "cryptfs" }; if (sdkver < 28) cmd[0] = "/system/bin/vdc"; const char *env[] = { "LD_LIBRARY_PATH=/system/lib64:/system/lib", NULL }; diff --git a/data.cpp b/data.cpp index b5b7c9ea..a13fbe79 100755 --- a/data.cpp +++ b/data.cpp @@ -917,7 +917,7 @@ void DataManager::SetDefaultValues() mData.SetValue("tw_enable_adb_backup", "0"); - if (TWFunc::Path_Exists("/sbin/magiskboot")) + if (TWFunc::Path_Exists("/system/bin/magiskboot")) mConst.SetValue("tw_has_repack_tools", "1"); else mConst.SetValue("tw_has_repack_tools", "0"); diff --git a/dosfstools/Android.mk b/dosfstools/Android.mk old mode 100644 new mode 100755 index 7b6d6234..d4b85a09 --- a/dosfstools/Android.mk +++ b/dosfstools/Android.mk @@ -19,7 +19,7 @@ LOCAL_CFLAGS += -Wno-sign-compare LOCAL_MODULE = fsck.fat LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) @@ -40,7 +40,7 @@ LOCAL_CFLAGS += -Wno-sign-compare LOCAL_MODULE = fatlabel LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) @@ -52,7 +52,7 @@ LOCAL_CFLAGS += -Wno-sign-compare LOCAL_MODULE = mkfs.fat LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin include $(BUILD_EXECUTABLE) endif diff --git a/etc/Android.mk b/etc/Android.mk old mode 100644 new mode 100755 index 5f669063..cb31a681 --- a/etc/Android.mk +++ b/etc/Android.mk @@ -31,54 +31,32 @@ include $(BUILD_PREBUILT) endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 22; echo $$?),0) - include $(CLEAR_VARS) - LOCAL_MODULE := init.recovery.service.rc - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) +include $(CLEAR_VARS) +LOCAL_MODULE := init.recovery.service.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES +LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) - LOCAL_SRC_FILES := init.recovery.service22.rc - include $(BUILD_PREBUILT) -else - include $(CLEAR_VARS) - LOCAL_MODULE := init.recovery.service.rc - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) +LOCAL_SRC_FILES := init.recovery.service22.rc +include $(BUILD_PREBUILT) - LOCAL_SRC_FILES := init.recovery.service21.rc - include $(BUILD_PREBUILT) -endif +include $(CLEAR_VARS) +LOCAL_MODULE := init.recovery.hlthchrg.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES +LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) - include $(CLEAR_VARS) - LOCAL_MODULE := init.recovery.hlthchrg.rc - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) +LOCAL_SRC_FILES := init.recovery.hlthchrg26.rc +include $(BUILD_PREBUILT) - LOCAL_SRC_FILES := init.recovery.hlthchrg26.rc - include $(BUILD_PREBUILT) +include $(CLEAR_VARS) +LOCAL_MODULE := init.recovery.ldconfig.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES +LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) - include $(CLEAR_VARS) - LOCAL_MODULE := init.recovery.ldconfig.rc - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) - - LOCAL_SRC_FILES := init.recovery.ldconfig.rc - include $(BUILD_PREBUILT) -else - include $(CLEAR_VARS) - LOCAL_MODULE := init.recovery.hlthchrg.rc - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) - - LOCAL_SRC_FILES := init.recovery.hlthchrg25.rc - include $(BUILD_PREBUILT) -endif +LOCAL_SRC_FILES := init.recovery.ldconfig.rc +include $(BUILD_PREBUILT) ifeq ($(TWRP_INCLUDE_LOGCAT), true) ifeq ($(TARGET_USES_LOGD), true) diff --git a/etc/init.rc b/etc/init.rc index 73b88d21..81a19745 100644 --- a/etc/init.rc +++ b/etc/init.rc @@ -17,7 +17,7 @@ on early-init on init export PATH /sbin:/system/bin - export LD_LIBRARY_PATH /sbin + export LD_LIBRARY_PATH /system/lib64 export ANDROID_ROOT /system export ANDROID_DATA /data @@ -103,11 +103,11 @@ on late-init on property:sys.powerctl=* powerctl ${sys.powerctl} -service ueventd /sbin/ueventd +service ueventd /system/bin/ueventd critical seclabel u:r:ueventd:s0 -service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery +service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery disabled socket adbd stream 660 system system seclabel u:r:adbd:s0 @@ -118,7 +118,7 @@ on property:ro.debuggable=1 #start adbd setprop service.adb.root 1 -service fastbootd /sbin/fastbootd +service fastbootd /system/bin/fastbootd disabled group system seclabel u:r:fastbootd:s0 diff --git a/etc/init.recovery.hlthchrg25.rc b/etc/init.recovery.hlthchrg25.rc old mode 100644 new mode 100755 index 62b24894..99a8baa1 --- a/etc/init.recovery.hlthchrg25.rc +++ b/etc/init.recovery.hlthchrg25.rc @@ -1,5 +1,5 @@ # healthd for pre Android 8.0 -service healthd /sbin/healthd -r +service healthd /system/bin/healthd -r critical seclabel u:r:healthd:s0 diff --git a/etc/init.recovery.ldconfig.rc b/etc/init.recovery.ldconfig.rc index ad9c2968..c99f802b 100755 --- a/etc/init.recovery.ldconfig.rc +++ b/etc/init.recovery.ldconfig.rc @@ -1,2 +1,2 @@ on fs - export LD_CONFIG_FILE /sbin/ld.config.txt + export LD_CONFIG_FILE /system/etc/ld.config.txt diff --git a/etc/init.recovery.logd.rc b/etc/init.recovery.logd.rc index 364fd82a..42537c76 100644 --- a/etc/init.recovery.logd.rc +++ b/etc/init.recovery.logd.rc @@ -1,4 +1,4 @@ -service logd /sbin/logd +service logd /system/bin/logd class core socket logdr seqpacket 0666 root root socket logdw dgram+passcred 0222 root root diff --git a/etc/init.recovery.service21.rc b/etc/init.recovery.service21.rc deleted file mode 100644 index 892b226f..00000000 --- a/etc/init.recovery.service21.rc +++ /dev/null @@ -1,4 +0,0 @@ -on boot - -# For starting recovery on 4.4 and older -service recovery /sbin/recovery diff --git a/etc/init.recovery.service22.rc b/etc/init.recovery.service22.rc index 438bb3bf..d9f661d8 100755 --- a/etc/init.recovery.service22.rc +++ b/etc/init.recovery.service22.rc @@ -1,7 +1,7 @@ on boot # For starting recovery on 5.0 and newer -service recovery /sbin/recovery +service recovery /system/bin/recovery seclabel u:r:recovery:s0 on early-init diff --git a/etc/init28.rc b/etc/init28.rc deleted file mode 100755 index 0b2a4ef8..00000000 --- a/etc/init28.rc +++ /dev/null @@ -1,225 +0,0 @@ -import /init.recovery.logd.rc -import /init.recovery.ldconfig.rc -import /init.recovery.mksh.rc -import /init.recovery.usb.rc -import /init.recovery.service.rc -import /init.recovery.vold_decrypt.rc -import /init.recovery.${ro.hardware}.rc - -on early-init - # Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls. - write /sys/fs/selinux/checkreqprot 0 - - # Set the security context for the init process. - # This should occur before anything else (e.g. ueventd) is started. - setcon u:r:init:s0 - - # Set the security context of /postinstall if present. - restorecon /postinstall - - start ueventd - -service set_permissive /sbin/permissive.sh - oneshot - seclabel u:r:recovery:s0 - -on init - export PATH /sbin:/system/bin - export LD_LIBRARY_PATH /sbin - - export ANDROID_ROOT /system - export ANDROID_DATA /data - export EXTERNAL_STORAGE /sdcard - - symlink /proc/self/fd/0 /dev/stdin - symlink /proc/self/fd/1 /dev/stdout - symlink /proc/self/fd/2 /dev/stderr - - symlink /system/bin /bin - symlink /system/etc /etc - - mount cgroup none /acct cpuacct - mkdir /acct/uid - - mkdir /system - mkdir /data - mkdir /cache - mkdir /sideload - mkdir /mnt/system - mount tmpfs tmpfs /tmp - - chown root shell /tmp - chmod 0775 /tmp - - write /proc/sys/kernel/panic_on_oops 1 - write /proc/sys/vm/max_map_count 1000000 - -on fs - mount pstore pstore /sys/fs/pstore - mkdir /dev/usb-ffs 0770 shell shell - mkdir /dev/usb-ffs/adb 0770 shell shell - mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 - -on boot - ifup lo - hostname localhost - domainname localdomain - - class_start default - -# Load properties, pre-Android 6.0 -on load_all_props_action - load_all_props - -# Load properties, Android 6.0+ -on load_system_props_action - load_system_props - -# Load properties, Android 6.0+, vendor init lives here -on load_persist_props_action - load_persist_props - -on firmware_mounts_complete - rm /dev/.booting - -# Mount filesystems and start core system services. -on late-init - trigger early-fs - trigger fs - trigger post-fs - trigger post-fs-data - - # Load properties, pre-Android 6.0 - trigger load_all_props_action - - # Load properties from /system/ + /factory after fs mount. Place - # this in another action so that the load will be scheduled after the prior - # issued fs triggers have completed. - trigger load_system_props_action - - # Load properties, Android 6.0+, vendor init lives here - trigger load_persist_props_action - - # Remove a file to wake up anything waiting for firmware - trigger firmware_mounts_complete - - trigger early-boot - trigger boot - -on property:sys.powerctl=* - powerctl ${sys.powerctl} - -service ueventd /sbin/ueventd - critical - seclabel u:r:ueventd:s0 - -service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery - disabled - socket adbd stream 660 system system - seclabel u:r:adbd:s0 - -# Always start adbd on userdebug and eng builds -on property:ro.debuggable=1 - #write /sys/class/android_usb/android0/enable 1 - #start adbd - setprop service.adb.root 1 - -service fastbootd /sbin/fastbootd - disabled - group system - seclabel u:r:fastbootd:s0 - -# Restart adbd so it can run as root -on property:service.adb.root=1 - restart adbd - -# Always start adbd on userdebug and eng builds -on fs && property:ro.debuggable=1 - setprop sys.usb.config adb - -on fs && property:sys.usb.configfs=1 - mount configfs none /config - mkdir /config/usb_gadget/g1 0770 shell shell - write /config/usb_gadget/g1/idVendor 0x18D1 - mkdir /config/usb_gadget/g1/strings/0x409 0770 - write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} - write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} - write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} - mkdir /config/usb_gadget/g1/functions/ffs.adb - mkdir /config/usb_gadget/g1/functions/ffs.fastboot - mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell - mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell - -on fs && property:sys.usb.configfs=0 - write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot - write /sys/class/android_usb/android0/idVendor 18D1 - write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer} - write /sys/class/android_usb/android0/iProduct ${ro.product.model} - write /sys/class/android_usb/android0/iSerial ${ro.serialno} - -on fs - mkdir /dev/usb-ffs 0775 shell shell - mkdir /dev/usb-ffs/adb 0770 shell shell - mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 - mkdir /dev/usb-ffs/fastboot 0770 system system - mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000 - -on property:sys.usb.config=adb - start adbd - -on property:sys.usb.config=fastboot - start fastbootd - -on property:sys.usb.config=none && property:sys.usb.configfs=0 - stop adbd - stop fastboot - write /sys/class/android_usb/android0/enable 0 - setprop sys.usb.state ${sys.usb.config} - -on property:sys.usb.config=adb && property:sys.usb.configfs=0 - write /sys/class/android_usb/android0/idProduct D001 - write /sys/class/android_usb/android0/functions adb - write /sys/class/android_usb/android0/enable 1 - setprop sys.usb.state ${sys.usb.config} - -on property:sys.usb.config=sideload && property:sys.usb.configfs=0 - write /sys/class/android_usb/android0/idProduct D001 - write /sys/class/android_usb/android0/functions adb - write /sys/class/android_usb/android0/enable 1 - setprop sys.usb.state ${sys.usb.config} - -on property:sys.usb.config=fastboot && property:sys.usb.configfs=0 - write /sys/class/android_usb/android0/idProduct 4EE0 - write /sys/class/android_usb/android0/functions fastboot - write /sys/class/android_usb/android0/enable 1 - setprop sys.usb.state ${sys.usb.config} - -# Configfs triggers -on property:sys.usb.config=none && property:sys.usb.configfs=1 - write /config/usb_gadget/g1/UDC "none" - stop adbd - stop fastbootd - setprop sys.usb.ffs.ready 0 - rm /config/usb_gadget/g1/configs/b.1/f1 - setprop sys.usb.state ${sys.usb.config} - -on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 - write /config/usb_gadget/g1/idProduct 0xD001 - write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" - symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 - write /config/usb_gadget/g1/UDC ${sys.usb.controller} - setprop sys.usb.state ${sys.usb.config} - -on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 - write /config/usb_gadget/g1/idProduct 0xD001 - write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" - symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 - write /config/usb_gadget/g1/UDC ${sys.usb.controller} - setprop sys.usb.state ${sys.usb.config} - -on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 - write /config/usb_gadget/g1/idProduct 0x4EE0 - write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot" - symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1 - write /config/usb_gadget/g1/UDC ${sys.usb.controller} - setprop sys.usb.state ${sys.usb.config} diff --git a/exfat/fsck/Android.mk b/exfat/fsck/Android.mk old mode 100644 new mode 100755 index 64ebc0fa..085dda40 --- a/exfat/fsck/Android.mk +++ b/exfat/fsck/Android.mk @@ -5,7 +5,7 @@ LOCAL_MODULE := fsckexfat LOCAL_MODULE_STEM := fsck.exfat LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64 -Wno-sign-compare LOCAL_SRC_FILES = main.c LOCAL_C_INCLUDES += $(LOCAL_PATH) \ diff --git a/exfat/fuse/Android.mk b/exfat/fuse/Android.mk old mode 100644 new mode 100755 index 57f35be5..b0cca7d0 --- a/exfat/fuse/Android.mk +++ b/exfat/fuse/Android.mk @@ -4,7 +4,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := exfat-fuse LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64 -Wno-sign-compare -Wno-unused-parameter LOCAL_SRC_FILES = main.c LOCAL_C_INCLUDES += $(LOCAL_PATH) \ diff --git a/exfat/mkfs/Android.mk b/exfat/mkfs/Android.mk old mode 100644 new mode 100755 index 9f3e7cb5..e1158f20 --- a/exfat/mkfs/Android.mk +++ b/exfat/mkfs/Android.mk @@ -4,7 +4,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := mkexfatfs LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64 -Wno-sign-compare LOCAL_SRC_FILES = cbm.c fat.c main.c mkexfat.c rootdir.c uct.c uctc.c vbr.c LOCAL_C_INCLUDES += $(LOCAL_PATH) \ diff --git a/flashutils/Android.mk b/flashutils/Android.mk old mode 100644 new mode 100755 index 1c5872ef..0a045092 --- a/flashutils/Android.mk +++ b/flashutils/Android.mk @@ -99,7 +99,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := flash_image LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SRC_FILES := flash_image.c LOCAL_SHARED_LIBRARIES := libmtdutils libflashutils libmmcutils libbmlutils libcutils libc include $(BUILD_EXECUTABLE) @@ -108,7 +108,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := dump_image LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SRC_FILES := dump_image.c LOCAL_SHARED_LIBRARIES := libmtdutils libflashutils libmmcutils libbmlutils libcutils libc include $(BUILD_EXECUTABLE) @@ -117,7 +117,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := erase_image LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SRC_FILES := erase_image.c LOCAL_SHARED_LIBRARIES := libmtdutils libflashutils libmmcutils libbmlutils libcutils libc include $(BUILD_EXECUTABLE) diff --git a/fuse_sideload22.cpp b/fuse_sideload22.cpp deleted file mode 100644 index f57d479b..00000000 --- a/fuse_sideload22.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This module creates a special filesystem containing two files. -// -// "/sideload/package.zip" appears to be a normal file, but reading -// from it causes data to be fetched from the adb host. We can use -// this to sideload packages over an adb connection without having to -// store the entire package in RAM on the device. -// -// Because we may not trust the adb host, this filesystem maintains -// the following invariant: each read of a given position returns the -// same data as the first read at that position. That is, once a -// section of the file is read, future reads of that section return -// the same data. (Otherwise, a malicious adb host process could -// return one set of bits when the package is read for signature -// verification, and then different bits for when the package is -// accessed by the installer.) If the adb host returns something -// different than it did on the first read, the reader of the file -// will see their read fail with EINVAL. -// -// The other file, "/sideload/exit", is used to control the subprocess -// that creates this filesystem. Calling stat() on the exit file -// causes the filesystem to be unmounted and the adb process on the -// device shut down. -// -// Note that only the minimal set of file operations needed for these -// two files is implemented. In particular, you can't opendir() or -// readdir() on the "/sideload" directory; ls on it won't work. - -#include -#include -#include -#include -#include -#include "fuse.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef USE_MINCRYPT -#include "mincrypt/sha256.h" -#define SHA256_DIGEST_LENGTH SHA256_DIGEST_SIZE -#else -#include -#endif - -#include "fuse_sideload.h" - -#define PACKAGE_FILE_ID (FUSE_ROOT_ID+1) -#define EXIT_FLAG_ID (FUSE_ROOT_ID+2) - -#define NO_STATUS 1 -#define NO_STATUS_EXIT 2 - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif - -struct fuse_data { - int ffd; // file descriptor for the fuse socket - - struct provider_vtab* vtab; - void* cookie; - - uint64_t file_size; // bytes - - uint32_t block_size; // block size that the adb host is using to send the file to us - uint32_t file_blocks; // file size in block_size blocks - - uid_t uid; - gid_t gid; - - uint32_t curr_block; // cache the block most recently read from the host - uint8_t* block_data; - - uint8_t* extra_block; // another block of storage for reads that - // span two blocks - - uint8_t* hashes; // SHA-256 hash of each block (all zeros - // if block hasn't been read yet) -}; - -static void fuse_reply(struct fuse_data* fd, __u64 unique, const void *data, size_t len) -{ - struct fuse_out_header hdr; - struct iovec vec[2]; - int res; - - hdr.len = len + sizeof(hdr); - hdr.error = 0; - hdr.unique = unique; - - vec[0].iov_base = &hdr; - vec[0].iov_len = sizeof(hdr); - vec[1].iov_base = /* const_cast */(void*)(data); - vec[1].iov_len = len; - - res = writev(fd->ffd, vec, 2); - if (res < 0) { - printf("*** REPLY FAILED *** %s\n", strerror(errno)); - } -} - -static int handle_init(void* data, struct fuse_data* fd, const struct fuse_in_header* hdr) { - const struct fuse_init_in* req = reinterpret_cast(data); - struct fuse_init_out out; - size_t fuse_struct_size; - - - /* Kernel 2.6.16 is the first stable kernel with struct fuse_init_out - * defined (fuse version 7.6). The structure is the same from 7.6 through - * 7.22. Beginning with 7.23, the structure increased in size and added - * new parameters. - */ - if (req->major != FUSE_KERNEL_VERSION || req->minor < 6) { - printf("Fuse kernel version mismatch: Kernel version %d.%d, Expected at least %d.6", - req->major, req->minor, FUSE_KERNEL_VERSION); - return -1; - } - - out.minor = MIN(req->minor, FUSE_KERNEL_MINOR_VERSION); - fuse_struct_size = sizeof(out); -#if defined(FUSE_COMPAT_22_INIT_OUT_SIZE) - /* FUSE_KERNEL_VERSION >= 23. */ - - /* If the kernel only works on minor revs older than or equal to 22, - * then use the older structure size since this code only uses the 7.22 - * version of the structure. */ - if (req->minor <= 22) { - fuse_struct_size = FUSE_COMPAT_22_INIT_OUT_SIZE; - } -#endif - - out.major = FUSE_KERNEL_VERSION; - out.max_readahead = req->max_readahead; - out.flags = 0; - out.max_background = 32; - out.congestion_threshold = 32; - out.max_write = 4096; - fuse_reply(fd, hdr->unique, &out, fuse_struct_size); - - return NO_STATUS; -} - -static void fill_attr(struct fuse_attr* attr, struct fuse_data* fd, - uint64_t nodeid, uint64_t size, uint32_t mode) { - memset(attr, 0, sizeof(*attr)); - attr->nlink = 1; - attr->uid = fd->uid; - attr->gid = fd->gid; - attr->blksize = 4096; - - attr->ino = nodeid; - attr->size = size; - attr->blocks = (size == 0) ? 0 : (((size-1) / attr->blksize) + 1); - attr->mode = mode; -} - -static int handle_getattr(void* /* data */, struct fuse_data* fd, const struct fuse_in_header* hdr) { - struct fuse_attr_out out; - memset(&out, 0, sizeof(out)); - out.attr_valid = 10; - - if (hdr->nodeid == FUSE_ROOT_ID) { - fill_attr(&(out.attr), fd, hdr->nodeid, 4096, S_IFDIR | 0555); - } else if (hdr->nodeid == PACKAGE_FILE_ID) { - fill_attr(&(out.attr), fd, PACKAGE_FILE_ID, fd->file_size, S_IFREG | 0444); - } else if (hdr->nodeid == EXIT_FLAG_ID) { - fill_attr(&(out.attr), fd, EXIT_FLAG_ID, 0, S_IFREG | 0); - } else { - return -ENOENT; - } - - fuse_reply(fd, hdr->unique, &out, sizeof(out)); - return (hdr->nodeid == EXIT_FLAG_ID) ? NO_STATUS_EXIT : NO_STATUS; -} - -static int handle_lookup(void* data, struct fuse_data* fd, - const struct fuse_in_header* hdr) { - struct fuse_entry_out out; - memset(&out, 0, sizeof(out)); - out.entry_valid = 10; - out.attr_valid = 10; - - if (strncmp(FUSE_SIDELOAD_HOST_FILENAME, reinterpret_cast(data), - sizeof(FUSE_SIDELOAD_HOST_FILENAME)) == 0) { - out.nodeid = PACKAGE_FILE_ID; - out.generation = PACKAGE_FILE_ID; - fill_attr(&(out.attr), fd, PACKAGE_FILE_ID, fd->file_size, S_IFREG | 0444); - } else if (strncmp(FUSE_SIDELOAD_HOST_EXIT_FLAG, reinterpret_cast(data), - sizeof(FUSE_SIDELOAD_HOST_EXIT_FLAG)) == 0) { - out.nodeid = EXIT_FLAG_ID; - out.generation = EXIT_FLAG_ID; - fill_attr(&(out.attr), fd, EXIT_FLAG_ID, 0, S_IFREG | 0); - } else { - return -ENOENT; - } - - fuse_reply(fd, hdr->unique, &out, sizeof(out)); - return (out.nodeid == EXIT_FLAG_ID) ? NO_STATUS_EXIT : NO_STATUS; -} - -static int handle_open(void* /* data */, struct fuse_data* fd, const struct fuse_in_header* hdr) { - if (hdr->nodeid == EXIT_FLAG_ID) return -EPERM; - if (hdr->nodeid != PACKAGE_FILE_ID) return -ENOENT; - - struct fuse_open_out out; - memset(&out, 0, sizeof(out)); - out.fh = 10; // an arbitrary number; we always use the same handle - fuse_reply(fd, hdr->unique, &out, sizeof(out)); - return NO_STATUS; -} - -static int handle_flush(void* data, struct fuse_data* fd, const struct fuse_in_header* hdr) { - return 0; -} - -static int handle_release(void* data, struct fuse_data* fd, const struct fuse_in_header* hdr) { - return 0; -} - -// Fetch a block from the host into fd->curr_block and fd->block_data. -// Returns 0 on successful fetch, negative otherwise. -static int fetch_block(struct fuse_data* fd, uint32_t block) { - if (block == fd->curr_block) { - return 0; - } - - if (block >= fd->file_blocks) { - memset(fd->block_data, 0, fd->block_size); - fd->curr_block = block; - return 0; - } - - size_t fetch_size = fd->block_size; - if (block * fd->block_size + fetch_size > fd->file_size) { - // If we're reading the last (partial) block of the file, - // expect a shorter response from the host, and pad the rest - // of the block with zeroes. - fetch_size = fd->file_size - (block * fd->block_size); - memset(fd->block_data + fetch_size, 0, fd->block_size - fetch_size); - } - - int result = fd->vtab->read_block(fd->cookie, block, fd->block_data, fetch_size); - if (result < 0) return result; - - fd->curr_block = block; - - // Verify the hash of the block we just got from the host. - // - // - If the hash of the just-received data matches the stored hash - // for the block, accept it. - // - If the stored hash is all zeroes, store the new hash and - // accept the block (this is the first time we've read this - // block). - // - Otherwise, return -EINVAL for the read. - - uint8_t hash[SHA256_DIGEST_LENGTH]; -#ifdef USE_MINCRYPT - SHA256_hash(fd->block_data, fd->block_size, hash); -#else - SHA256(fd->block_data, fd->block_size, hash); -#endif - uint8_t* blockhash = fd->hashes + block * SHA256_DIGEST_LENGTH; - if (memcmp(hash, blockhash, SHA256_DIGEST_LENGTH) == 0) { - return 0; - } - - int i; - for (i = 0; i < SHA256_DIGEST_LENGTH; ++i) { - if (blockhash[i] != 0) { - fd->curr_block = -1; - return -EIO; - } - } - - memcpy(blockhash, hash, SHA256_DIGEST_LENGTH); - return 0; -} - -static int handle_read(void* data, struct fuse_data* fd, const struct fuse_in_header* hdr) { - const struct fuse_read_in* req = reinterpret_cast(data); - struct fuse_out_header outhdr; - struct iovec vec[3]; - int vec_used; - int result; - - if (hdr->nodeid != PACKAGE_FILE_ID) return -ENOENT; - - uint64_t offset = req->offset; - uint32_t size = req->size; - - // The docs on the fuse kernel interface are vague about what to - // do when a read request extends past the end of the file. We - // can return a short read -- the return structure does include a - // length field -- but in testing that caused the program using - // the file to segfault. (I speculate that this is due to the - // reading program accessing it via mmap; maybe mmap dislikes when - // you return something short of a whole page?) To fix this we - // zero-pad reads that extend past the end of the file so we're - // always returning exactly as many bytes as were requested. - // (Users of the mapped file have to know its real length anyway.) - - outhdr.len = sizeof(outhdr) + size; - outhdr.error = 0; - outhdr.unique = hdr->unique; - vec[0].iov_base = &outhdr; - vec[0].iov_len = sizeof(outhdr); - - uint32_t block = offset / fd->block_size; - result = fetch_block(fd, block); - if (result != 0) return result; - - // Two cases: - // - // - the read request is entirely within this block. In this - // case we can reply immediately. - // - // - the read request goes over into the next block. Note that - // since we mount the filesystem with max_read=block_size, a - // read can never span more than two blocks. In this case we - // copy the block to extra_block and issue a fetch for the - // following block. - - uint32_t block_offset = offset - (block * fd->block_size); - - if (size + block_offset <= fd->block_size) { - // First case: the read fits entirely in the first block. - - vec[1].iov_base = fd->block_data + block_offset; - vec[1].iov_len = size; - vec_used = 2; - } else { - // Second case: the read spills over into the next block. - - memcpy(fd->extra_block, fd->block_data + block_offset, - fd->block_size - block_offset); - vec[1].iov_base = fd->extra_block; - vec[1].iov_len = fd->block_size - block_offset; - - result = fetch_block(fd, block+1); - if (result != 0) return result; - vec[2].iov_base = fd->block_data; - vec[2].iov_len = size - vec[1].iov_len; - vec_used = 3; - } - - if (writev(fd->ffd, vec, vec_used) < 0) { - printf("*** READ REPLY FAILED: %s ***\n", strerror(errno)); - } - return NO_STATUS; -} - -int run_fuse_sideload(struct provider_vtab* vtab, void* cookie, - uint64_t file_size, uint32_t block_size) -{ - int result; - - // If something's already mounted on our mountpoint, try to remove - // it. (Mostly in case of a previous abnormal exit.) - umount2(FUSE_SIDELOAD_HOST_MOUNTPOINT, MNT_FORCE); - - if (block_size < 1024) { - fprintf(stderr, "block size (%u) is too small\n", block_size); - return -1; - } - if (block_size > (1<<22)) { // 4 MiB - fprintf(stderr, "block size (%u) is too large\n", block_size); - return -1; - } - - struct fuse_data fd; - memset(&fd, 0, sizeof(fd)); - fd.vtab = vtab; - fd.cookie = cookie; - fd.file_size = file_size; - fd.block_size = block_size; - fd.file_blocks = (file_size == 0) ? 0 : (((file_size-1) / block_size) + 1); - - if (fd.file_blocks > (1<<18)) { - fprintf(stderr, "file has too many blocks (%u)\n", fd.file_blocks); - result = -1; - goto done; - } - - fd.hashes = (uint8_t*)calloc(fd.file_blocks, SHA256_DIGEST_LENGTH); - if (fd.hashes == NULL) { - fprintf(stderr, "failed to allocate %d bites for hashes\n", - fd.file_blocks * SHA256_DIGEST_LENGTH); - result = -1; - goto done; - } - - fd.uid = getuid(); - fd.gid = getgid(); - - fd.curr_block = -1; - fd.block_data = (uint8_t*)malloc(block_size); - if (fd.block_data == NULL) { - fprintf(stderr, "failed to allocate %d bites for block_data\n", block_size); - result = -1; - goto done; - } - fd.extra_block = (uint8_t*)malloc(block_size); - if (fd.extra_block == NULL) { - fprintf(stderr, "failed to allocate %d bites for extra_block\n", block_size); - result = -1; - goto done; - } - - fd.ffd = open("/dev/fuse", O_RDWR); - if (fd.ffd < 0) { - perror("open /dev/fuse"); - result = -1; - goto done; - } - - char opts[256]; - snprintf(opts, sizeof(opts), - ("fd=%d,user_id=%d,group_id=%d,max_read=%u," - "allow_other,rootmode=040000"), - fd.ffd, fd.uid, fd.gid, block_size); - - result = mount("/dev/fuse", FUSE_SIDELOAD_HOST_MOUNTPOINT, - "fuse", MS_NOSUID | MS_NODEV | MS_RDONLY | MS_NOEXEC, opts); - if (result < 0) { - perror("mount"); - goto done; - } - uint8_t request_buffer[sizeof(struct fuse_in_header) + PATH_MAX*8]; - for (;;) { - ssize_t len = TEMP_FAILURE_RETRY(read(fd.ffd, request_buffer, sizeof(request_buffer))); - if (len == -1) { - perror("read request"); - if (errno == ENODEV) { - result = -1; - break; - } - continue; - } - - if ((size_t)len < sizeof(struct fuse_in_header)) { - fprintf(stderr, "request too short: len=%zu\n", (size_t)len); - continue; - } - - struct fuse_in_header* hdr = (struct fuse_in_header*) request_buffer; - void* data = request_buffer + sizeof(struct fuse_in_header); - - result = -ENOSYS; - - switch (hdr->opcode) { - case FUSE_INIT: - result = handle_init(data, &fd, hdr); - break; - - case FUSE_LOOKUP: - result = handle_lookup(data, &fd, hdr); - break; - - case FUSE_GETATTR: - result = handle_getattr(data, &fd, hdr); - break; - - case FUSE_OPEN: - result = handle_open(data, &fd, hdr); - break; - - case FUSE_READ: - result = handle_read(data, &fd, hdr); - break; - - case FUSE_FLUSH: - result = handle_flush(data, &fd, hdr); - break; - - case FUSE_RELEASE: - result = handle_release(data, &fd, hdr); - break; - - default: - fprintf(stderr, "unknown fuse request opcode %d\n", hdr->opcode); - break; - } - - if (result == NO_STATUS_EXIT) { - result = 0; - break; - } - - if (result != NO_STATUS) { - struct fuse_out_header outhdr; - outhdr.len = sizeof(outhdr); - outhdr.error = result; - outhdr.unique = hdr->unique; - TEMP_FAILURE_RETRY(write(fd.ffd, &outhdr, sizeof(outhdr))); - } - } - - done: - fd.vtab->close(fd.cookie); - - result = umount2(FUSE_SIDELOAD_HOST_MOUNTPOINT, MNT_DETACH); - if (result < 0) { - printf("fuse_sideload umount failed: %s\n", strerror(errno)); - } - - if (fd.ffd) close(fd.ffd); - free(fd.hashes); - free(fd.block_data); - free(fd.extra_block); - - return result; -} - -extern "C" int run_old_fuse_sideload(struct provider_vtab* vtab, void* cookie, - uint64_t file_size, uint32_t block_size) -{ - return run_fuse_sideload(vtab, cookie, file_size, block_size); -} diff --git a/fuse_sideload22.h b/fuse_sideload22.h deleted file mode 100644 index 98254d46..00000000 --- a/fuse_sideload22.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __FUSE_SIDELOAD22_H -#define __FUSE_SIDELOAD22_H - -// define the filenames created by the sideload FUSE filesystem -#define FUSE_SIDELOAD_HOST_MOUNTPOINT "/sideload" -#define FUSE_SIDELOAD_HOST_FILENAME "package.zip" -#define FUSE_SIDELOAD_HOST_PATHNAME (FUSE_SIDELOAD_HOST_MOUNTPOINT "/" FUSE_SIDELOAD_HOST_FILENAME) -#define FUSE_SIDELOAD_HOST_EXIT_FLAG "exit" -#define FUSE_SIDELOAD_HOST_EXIT_PATHNAME (FUSE_SIDELOAD_HOST_MOUNTPOINT "/" FUSE_SIDELOAD_HOST_EXIT_FLAG) - -struct provider_vtab { - // read a block - int (*read_block)(void* cookie, uint32_t block, uint8_t* buffer, uint32_t fetch_size); - - // close down - void (*close)(void* cookie); -}; - -int run_fuse_sideload(struct provider_vtab* vtab, void* cookie, - uint64_t file_size, uint32_t block_size); - -#ifdef __cplusplus -extern "C" { -#endif -int run_old_fuse_sideload(struct provider_vtab* vtab, void* cookie, - uint64_t file_size, uint32_t block_size); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/fuse_sideload28/fuse_sideload.cpp b/fuse_sideload28/fuse_sideload.cpp deleted file mode 100644 index 45c79f90..00000000 --- a/fuse_sideload28/fuse_sideload.cpp +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This module creates a special filesystem containing two files. -// -// "/sideload/package.zip" appears to be a normal file, but reading -// from it causes data to be fetched from the adb host. We can use -// this to sideload packages over an adb connection without having to -// store the entire package in RAM on the device. -// -// Because we may not trust the adb host, this filesystem maintains -// the following invariant: each read of a given position returns the -// same data as the first read at that position. That is, once a -// section of the file is read, future reads of that section return -// the same data. (Otherwise, a malicious adb host process could -// return one set of bits when the package is read for signature -// verification, and then different bits for when the package is -// accessed by the installer.) If the adb host returns something -// different than it did on the first read, the reader of the file -// will see their read fail with EINVAL. -// -// The other file, "/sideload/exit", is used to control the subprocess -// that creates this filesystem. Calling stat() on the exit file -// causes the filesystem to be unmounted and the adb process on the -// device shut down. -// -// Note that only the minimal set of file operations needed for these -// two files is implemented. In particular, you can't opendir() or -// readdir() on the "/sideload" directory; ls on it won't work. - -#include "fuse_sideload.h" - -#include -#include -#include -#include "fuse.h" -#include -#include -#include -#include -#include -#include -#include // MIN -#include -#include -#include - -#ifdef USE_MINCRYPT -#include "mincrypt/sha256.h" -#define SHA256_DIGEST_LENGTH SHA256_DIGEST_SIZE -#else -#include -#endif - -#include -#include -#include - -//#include -//#include - -static constexpr uint64_t PACKAGE_FILE_ID = FUSE_ROOT_ID + 1; -static constexpr uint64_t EXIT_FLAG_ID = FUSE_ROOT_ID + 2; - -static constexpr int NO_STATUS = 1; -static constexpr int NO_STATUS_EXIT = 2; - -using SHA256Digest = std::array; - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif - -struct fuse_data { - int ffd; // file descriptor for the fuse socket - - provider_vtab vtab; - - uint64_t file_size; // bytes - - uint32_t block_size; // block size that the adb host is using to send the file to us - uint32_t file_blocks; // file size in block_size blocks - - uid_t uid; - gid_t gid; - - uint32_t curr_block; // cache the block most recently read from the host - uint8_t* block_data; - - uint8_t* extra_block; // another block of storage for reads that span two blocks - - uint8_t* hashes; // SHA-256 hash of each block (all zeros - // if block hasn't been read yet) -}; - -static void fuse_reply(const fuse_data* fd, uint64_t unique, const void* data, size_t len) { - fuse_out_header hdr; - hdr.len = len + sizeof(hdr); - hdr.error = 0; - hdr.unique = unique; - - struct iovec vec[2]; - vec[0].iov_base = &hdr; - vec[0].iov_len = sizeof(hdr); - vec[1].iov_base = const_cast(data); - vec[1].iov_len = len; - - int res = writev(fd->ffd, vec, 2); - if (res == -1) { - printf("*** REPLY FAILED *** %s\n", strerror(errno)); - } -} - -static int handle_init(void* data, fuse_data* fd, const fuse_in_header* hdr) { - const fuse_init_in* req = static_cast(data); - - // Kernel 2.6.16 is the first stable kernel with struct fuse_init_out defined (fuse version 7.6). - // The structure is the same from 7.6 through 7.22. Beginning with 7.23, the structure increased - // in size and added new parameters. - if (req->major != FUSE_KERNEL_VERSION || req->minor < 6) { - printf("Fuse kernel version mismatch: Kernel version %d.%d, Expected at least %d.6", req->major, - req->minor, FUSE_KERNEL_VERSION); - return -1; - } - - fuse_init_out out; - out.minor = MIN(req->minor, FUSE_KERNEL_MINOR_VERSION); - size_t fuse_struct_size = sizeof(out); -#if defined(FUSE_COMPAT_22_INIT_OUT_SIZE) - /* FUSE_KERNEL_VERSION >= 23. */ - - // If the kernel only works on minor revs older than or equal to 22, then use the older structure - // size since this code only uses the 7.22 version of the structure. - if (req->minor <= 22) { - fuse_struct_size = FUSE_COMPAT_22_INIT_OUT_SIZE; - } -#endif - - out.major = FUSE_KERNEL_VERSION; - out.max_readahead = req->max_readahead; - out.flags = 0; - out.max_background = 32; - out.congestion_threshold = 32; - out.max_write = 4096; - fuse_reply(fd, hdr->unique, &out, fuse_struct_size); - - return NO_STATUS; -} - -static void fill_attr(fuse_attr* attr, const fuse_data* fd, uint64_t nodeid, uint64_t size, - uint32_t mode) { - memset(attr, 0, sizeof(*attr)); - attr->nlink = 1; - attr->uid = fd->uid; - attr->gid = fd->gid; - attr->blksize = 4096; - - attr->ino = nodeid; - attr->size = size; - attr->blocks = (size == 0) ? 0 : (((size - 1) / attr->blksize) + 1); - attr->mode = mode; -} - -static int handle_getattr(void* /* data */, const fuse_data* fd, const fuse_in_header* hdr) { - struct fuse_attr_out out; - memset(&out, 0, sizeof(out)); - out.attr_valid = 10; - - if (hdr->nodeid == FUSE_ROOT_ID) { - fill_attr(&(out.attr), fd, hdr->nodeid, 4096, S_IFDIR | 0555); - } else if (hdr->nodeid == PACKAGE_FILE_ID) { - fill_attr(&(out.attr), fd, PACKAGE_FILE_ID, fd->file_size, S_IFREG | 0444); - } else if (hdr->nodeid == EXIT_FLAG_ID) { - fill_attr(&(out.attr), fd, EXIT_FLAG_ID, 0, S_IFREG | 0); - } else { - return -ENOENT; - } - - fuse_reply(fd, hdr->unique, &out, sizeof(out)); - return (hdr->nodeid == EXIT_FLAG_ID) ? NO_STATUS_EXIT : NO_STATUS; -} - -static int handle_lookup(void* data, const fuse_data* fd, const fuse_in_header* hdr) { - if (data == nullptr) return -ENOENT; - - struct fuse_entry_out out; - memset(&out, 0, sizeof(out)); - out.entry_valid = 10; - out.attr_valid = 10; - - std::string filename(static_cast(data)); - if (filename == FUSE_SIDELOAD_HOST_FILENAME) { - out.nodeid = PACKAGE_FILE_ID; - out.generation = PACKAGE_FILE_ID; - fill_attr(&(out.attr), fd, PACKAGE_FILE_ID, fd->file_size, S_IFREG | 0444); - } else if (filename == FUSE_SIDELOAD_HOST_EXIT_FLAG) { - out.nodeid = EXIT_FLAG_ID; - out.generation = EXIT_FLAG_ID; - fill_attr(&(out.attr), fd, EXIT_FLAG_ID, 0, S_IFREG | 0); - } else { - return -ENOENT; - } - - fuse_reply(fd, hdr->unique, &out, sizeof(out)); - return (out.nodeid == EXIT_FLAG_ID) ? NO_STATUS_EXIT : NO_STATUS; -} - -static int handle_open(void* /* data */, const fuse_data* fd, const fuse_in_header* hdr) { - if (hdr->nodeid == EXIT_FLAG_ID) return -EPERM; - if (hdr->nodeid != PACKAGE_FILE_ID) return -ENOENT; - - struct fuse_open_out out; - memset(&out, 0, sizeof(out)); - out.fh = 10; // an arbitrary number; we always use the same handle - fuse_reply(fd, hdr->unique, &out, sizeof(out)); - return NO_STATUS; -} - -static int handle_flush(void* /* data */, fuse_data* /* fd */, const fuse_in_header* /* hdr */) { - return 0; -} - -static int handle_release(void* /* data */, fuse_data* /* fd */, const fuse_in_header* /* hdr */) { - return 0; -} - -// Fetch a block from the host into fd->curr_block and fd->block_data. -// Returns 0 on successful fetch, negative otherwise. -static int fetch_block(fuse_data* fd, uint32_t block) { - if (block == fd->curr_block) { - return 0; - } - - if (block >= fd->file_blocks) { - memset(fd->block_data, 0, fd->block_size); - fd->curr_block = block; - return 0; - } - - size_t fetch_size = fd->block_size; - if (block * fd->block_size + fetch_size > fd->file_size) { - // If we're reading the last (partial) block of the file, expect a shorter response from the - // host, and pad the rest of the block with zeroes. - fetch_size = fd->file_size - (block * fd->block_size); - memset(fd->block_data + fetch_size, 0, fd->block_size - fetch_size); - } - - int result = fd->vtab.read_block(block, fd->block_data, fetch_size); - if (result < 0) return result; - - fd->curr_block = block; - - // Verify the hash of the block we just got from the host. - // - // - If the hash of the just-received data matches the stored hash for the block, accept it. - // - If the stored hash is all zeroes, store the new hash and accept the block (this is the first - // time we've read this block). - // - Otherwise, return -EINVAL for the read. - - uint8_t hash[SHA256_DIGEST_LENGTH]; -#ifdef USE_MINCRYPT - SHA256_hash(fd->block_data, fd->block_size, hash); -#else - SHA256(fd->block_data, fd->block_size, hash); -#endif - uint8_t* blockhash = fd->hashes + block * SHA256_DIGEST_LENGTH; - if (memcmp(hash, blockhash, SHA256_DIGEST_LENGTH) == 0) { - return 0; - } - - int i; - for (i = 0; i < SHA256_DIGEST_LENGTH; ++i) { - if (blockhash[i] != 0) { - fd->curr_block = -1; - return -EIO; - } - } - - memcpy(blockhash, hash, SHA256_DIGEST_LENGTH); - return 0; -} - -static int handle_read(void* data, fuse_data* fd, const fuse_in_header* hdr) { - if (hdr->nodeid != PACKAGE_FILE_ID) return -ENOENT; - - const fuse_read_in* req = static_cast(data); - uint64_t offset = req->offset; - uint32_t size = req->size; - - // The docs on the fuse kernel interface are vague about what to do when a read request extends - // past the end of the file. We can return a short read -- the return structure does include a - // length field -- but in testing that caused the program using the file to segfault. (I - // speculate that this is due to the reading program accessing it via mmap; maybe mmap dislikes - // when you return something short of a whole page?) To fix this we zero-pad reads that extend - // past the end of the file so we're always returning exactly as many bytes as were requested. - // (Users of the mapped file have to know its real length anyway.) - - fuse_out_header outhdr; - outhdr.len = sizeof(outhdr) + size; - outhdr.error = 0; - outhdr.unique = hdr->unique; - - struct iovec vec[3]; - vec[0].iov_base = &outhdr; - vec[0].iov_len = sizeof(outhdr); - - uint32_t block = offset / fd->block_size; - int result = fetch_block(fd, block); - if (result != 0) return result; - - // Two cases: - // - // - the read request is entirely within this block. In this case we can reply immediately. - // - // - the read request goes over into the next block. Note that since we mount the filesystem - // with max_read=block_size, a read can never span more than two blocks. In this case we copy - // the block to extra_block and issue a fetch for the following block. - - uint32_t block_offset = offset - (block * fd->block_size); - - int vec_used; - if (size + block_offset <= fd->block_size) { - // First case: the read fits entirely in the first block. - - vec[1].iov_base = fd->block_data + block_offset; - vec[1].iov_len = size; - vec_used = 2; - } else { - // Second case: the read spills over into the next block. - - memcpy(fd->extra_block, fd->block_data + block_offset, fd->block_size - block_offset); - vec[1].iov_base = fd->extra_block; - vec[1].iov_len = fd->block_size - block_offset; - - result = fetch_block(fd, block + 1); - if (result != 0) return result; - vec[2].iov_base = fd->block_data; - vec[2].iov_len = size - vec[1].iov_len; - vec_used = 3; - } - - if (writev(fd->ffd, vec, vec_used) == -1) { - printf("*** READ REPLY FAILED: %s ***\n", strerror(errno)); - } - return NO_STATUS; -} - -int run_fuse_sideload(const provider_vtab& vtab, uint64_t file_size, uint32_t block_size, - const char* mount_point) { - // If something's already mounted on our mountpoint, try to remove it. (Mostly in case of a - // previous abnormal exit.) - umount2(mount_point, MNT_FORCE); - - // fs/fuse/inode.c in kernel code uses the greater of 4096 and the passed-in max_read. - if (block_size < 4096) { - fprintf(stderr, "block size (%u) is too small\n", block_size); - return -1; - } - if (block_size > (1 << 22)) { // 4 MiB - fprintf(stderr, "block size (%u) is too large\n", block_size); - return -1; - } - - fuse_data fd; - memset(&fd, 0, sizeof(fd)); - fd.vtab = vtab; - fd.file_size = file_size; - fd.block_size = block_size; - fd.file_blocks = (file_size == 0) ? 0 : (((file_size - 1) / block_size) + 1); - - int result; - if (fd.file_blocks > (1 << 18)) { - fprintf(stderr, "file has too many blocks (%u)\n", fd.file_blocks); - result = -1; - goto done; - } - - fd.hashes = (uint8_t*)calloc(fd.file_blocks, SHA256_DIGEST_LENGTH); - if (fd.hashes == NULL) { - fprintf(stderr, "failed to allocate %d bites for hashes\n", - fd.file_blocks * SHA256_DIGEST_LENGTH); - result = -1; - goto done; - } - - fd.uid = getuid(); - fd.gid = getgid(); - - fd.curr_block = -1; - fd.block_data = static_cast(malloc(block_size)); - if (fd.block_data == nullptr) { - fprintf(stderr, "failed to allocate %d bites for block_data\n", block_size); - result = -1; - goto done; - } - fd.extra_block = static_cast(malloc(block_size)); - if (fd.extra_block == nullptr) { - fprintf(stderr, "failed to allocate %d bites for extra_block\n", block_size); - result = -1; - goto done; - } - - fd.ffd = open("/dev/fuse", O_RDWR); - if (!fd.ffd) { - perror("open /dev/fuse"); - result = -1; - goto done; - } - - { - char opts[256]; - snprintf(opts, sizeof(opts), - ("fd=%d,user_id=%d,group_id=%d,max_read=%u," - "allow_other,rootmode=040000"), - fd.ffd, fd.uid, fd.gid, block_size); - - result = mount("/dev/fuse", FUSE_SIDELOAD_HOST_MOUNTPOINT, "fuse", - MS_NOSUID | MS_NODEV | MS_RDONLY | MS_NOEXEC, opts); - if (result < 0) { - perror("mount"); - goto done; - } - } - - uint8_t request_buffer[sizeof(fuse_in_header) + PATH_MAX * 8]; - for (;;) { - ssize_t len = TEMP_FAILURE_RETRY(read(fd.ffd, request_buffer, sizeof(request_buffer))); - if (len == -1) { - perror("read request"); - if (errno == ENODEV) { - result = -1; - break; - } - continue; - } - - if (static_cast(len) < sizeof(fuse_in_header)) { - fprintf(stderr, "request too short: len=%zd\n", len); - continue; - } - - fuse_in_header* hdr = reinterpret_cast(request_buffer); - void* data = request_buffer + sizeof(fuse_in_header); - - result = -ENOSYS; - - switch (hdr->opcode) { - case FUSE_INIT: - result = handle_init(data, &fd, hdr); - break; - - case FUSE_LOOKUP: - result = handle_lookup(data, &fd, hdr); - break; - - case FUSE_GETATTR: - result = handle_getattr(data, &fd, hdr); - break; - - case FUSE_OPEN: - result = handle_open(data, &fd, hdr); - break; - - case FUSE_READ: - result = handle_read(data, &fd, hdr); - break; - - case FUSE_FLUSH: - result = handle_flush(data, &fd, hdr); - break; - - case FUSE_RELEASE: - result = handle_release(data, &fd, hdr); - break; - - default: - fprintf(stderr, "unknown fuse request opcode %d\n", hdr->opcode); - break; - } - - if (result == NO_STATUS_EXIT) { - result = 0; - break; - } - - if (result != NO_STATUS) { - fuse_out_header outhdr; - outhdr.len = sizeof(outhdr); - outhdr.error = result; - outhdr.unique = hdr->unique; - TEMP_FAILURE_RETRY(write(fd.ffd, &outhdr, sizeof(outhdr))); - } - } - -done: - fd.vtab.close(); - - if (umount2(mount_point, MNT_DETACH) == -1) { - fprintf(stderr, "fuse_sideload umount failed: %s\n", strerror(errno)); - } - - free(fd.block_data); - free(fd.extra_block); - - return result; -} - -extern "C" int run_old_fuse_sideload(const struct provider_vtab& vtab, void* cookie __unused, - uint64_t file_size, uint32_t block_size) -{ - return run_fuse_sideload(vtab, file_size, block_size, FUSE_SIDELOAD_HOST_MOUNTPOINT); -} diff --git a/fuse_sideload28/fuse_sideload.h b/fuse_sideload28/fuse_sideload.h deleted file mode 100644 index 1ea1eb8d..00000000 --- a/fuse_sideload28/fuse_sideload.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __FUSE_SIDELOAD_H -#define __FUSE_SIDELOAD_H - -#ifdef USE_FUSE_SIDELOAD22 -#include "fuse_sideload22.h" -#else - -#include - -// Define the filenames created by the sideload FUSE filesystem. -static constexpr const char* FUSE_SIDELOAD_HOST_MOUNTPOINT = "/sideload"; -static constexpr const char* FUSE_SIDELOAD_HOST_FILENAME = "package.zip"; -static constexpr const char* FUSE_SIDELOAD_HOST_PATHNAME = "/sideload/package.zip"; -static constexpr const char* FUSE_SIDELOAD_HOST_EXIT_FLAG = "exit"; -static constexpr const char* FUSE_SIDELOAD_HOST_EXIT_PATHNAME = "/sideload/exit"; - -struct provider_vtab { - // read a block - std::function read_block; - - // close down - std::function close; -}; - -int run_fuse_sideload(const provider_vtab& vtab, uint64_t file_size, uint32_t block_size, - const char* mount_point = FUSE_SIDELOAD_HOST_MOUNTPOINT); - -#ifdef __cplusplus -extern "C" { -#endif -int run_old_fuse_sideload(const struct provider_vtab& vtab, void* cookie, - uint64_t file_size, uint32_t block_size); -#ifdef __cplusplus -} -#endif - -#endif - -#endif diff --git a/gui/action.cpp b/gui/action.cpp index 12ea91dd..5e842d50 100755 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -38,6 +38,7 @@ #include #include "../partitions.hpp" #include "../twrp-functions.hpp" +#include "../twrpRepacker.hpp" #include "../openrecoveryscript.hpp" #include "install/adb_install.h" @@ -396,12 +397,12 @@ int GUIAction::flash_zip(std::string filename, int* wipe_cache) // Now, check if we need to ensure TWRP remains installed... struct stat st; - if (stat("/sbin/installTwrp", &st) == 0) + if (stat("/system/bin/installTwrp", &st) == 0) { DataManager::SetValue("tw_operation", "Configuring TWRP"); DataManager::SetValue("tw_partition", ""); gui_msg("config_twrp=Configuring TWRP..."); - if (TWFunc::Exec_Cmd("/sbin/installTwrp reinstall") < 0) + if (TWFunc::Exec_Cmd("/system/bin/installTwrp reinstall") < 0) { gui_msg("config_twrp_err=Unable to configure TWRP with this kernel."); } @@ -921,19 +922,19 @@ int GUIAction::getpartitiondetails(std::string arg) DataManager::SetValue("tw_partition_can_resize", 1); else DataManager::SetValue("tw_partition_can_resize", 0); - if (TWFunc::Path_Exists("/sbin/mkfs.fat")) + if (TWFunc::Path_Exists("/system/bin/mkfs.fat")) DataManager::SetValue("tw_partition_vfat", 1); else DataManager::SetValue("tw_partition_vfat", 0); - if (TWFunc::Path_Exists("/sbin/mkexfatfs")) + if (TWFunc::Path_Exists("/system/bin/mkexfatfs")) DataManager::SetValue("tw_partition_exfat", 1); else DataManager::SetValue("tw_partition_exfat", 0); - if (TWFunc::Path_Exists("/sbin/mkfs.f2fs")) + if (TWFunc::Path_Exists("/system/bin/mkfs.f2fs")) DataManager::SetValue("tw_partition_f2fs", 1); else DataManager::SetValue("tw_partition_f2fs", 0); - if (TWFunc::Path_Exists("/sbin/mke2fs")) + if (TWFunc::Path_Exists("/system/bin/mke2fs")) DataManager::SetValue("tw_partition_ext", 1); else DataManager::SetValue("tw_partition_ext", 0); @@ -1031,7 +1032,7 @@ void GUIAction::reinject_after_flash() int GUIAction::ozip_decrypt(string zip_path) { - if (!TWFunc::Path_Exists("/sbin/ozip_decrypt")) { + if (!TWFunc::Path_Exists("/system/bin/ozip_decrypt")) { return 1; } gui_msg("ozip_decrypt_decryption=Starting Ozip Decryption..."); @@ -2025,7 +2026,7 @@ int GUIAction::installapp(std::string arg __unused) goto exit; } install_path += "/base.apk"; - if (TWFunc::copy_file("/sbin/me.twrp.twrpapp.apk", install_path, 0644)) { + if (TWFunc::copy_file("/system/bin/me.twrp.twrpapp.apk", install_path, 0644)) { LOGERR("Error copying apk file\n"); goto exit; } @@ -2058,7 +2059,7 @@ int GUIAction::installapp(std::string arg __unused) goto exit; } install_path += "/me.twrp.twrpapp.apk"; - if (TWFunc::copy_file("/sbin/me.twrp.twrpapp.apk", install_path, 0644)) { + if (TWFunc::copy_file("/system/bin/me.twrp.twrpapp.apk", install_path, 0644)) { LOGERR("Error copying apk file\n"); goto exit; } @@ -2069,7 +2070,7 @@ int GUIAction::installapp(std::string arg __unused) // System apps require their permissions to be pre-set via an XML file in /etc/permissions string permission_path = base_path + "/etc/permissions/privapp-permissions-twrpapp.xml"; - if (TWFunc::copy_file("/sbin/privapp-permissions-twrpapp.xml", permission_path, 0644)) { + if (TWFunc::copy_file("/system/bin/privapp-permissions-twrpapp.xml", permission_path, 0644)) { LOGERR("Error copying permission file\n"); goto exit; } @@ -2155,6 +2156,8 @@ exit: int GUIAction::repackimage(std::string arg __unused) { int op_status = 1; + twrpRepacker repacker; + operation_start("Repack Image"); if (!simulate) { @@ -2167,7 +2170,7 @@ int GUIAction::repackimage(std::string arg __unused) Repack_Options.Type = REPLACE_KERNEL; else Repack_Options.Type = REPLACE_RAMDISK; - if (!PartitionManager.Repack_Images(path, Repack_Options)) + if (!repacker.Repack_Image_And_Flash(path, Repack_Options)) goto exit; } else simulate_progress_bar(); @@ -2180,10 +2183,12 @@ exit: int GUIAction::fixabrecoverybootloop(std::string arg __unused) { int op_status = 1; + twrpRepacker repacker; + operation_start("Repack Image"); if (!simulate) { - if (!TWFunc::Path_Exists("/sbin/magiskboot")) { + if (!TWFunc::Path_Exists("/system/bin/magiskboot")) { LOGERR("Image repacking tool not present in this TWRP build!"); goto exit; } @@ -2195,11 +2200,11 @@ int GUIAction::fixabrecoverybootloop(std::string arg __unused) gui_msg(Msg(msg::kError, "unable_to_locate=Unable to locate {1}.")("/boot")); goto exit; } - if (!PartitionManager.Prepare_Repack(part, REPACK_ORIG_DIR, DataManager::GetIntValue("tw_repack_backup_first") != 0, gui_lookup("repack", "Repack"))) + if (!repacker.Backup_Image_For_Repack(part, REPACK_ORIG_DIR, DataManager::GetIntValue("tw_repack_backup_first") != 0, gui_lookup("repack", "Repack"))) goto exit; DataManager::SetProgress(.25); gui_msg("fixing_recovery_loop_patch=Patching kernel..."); - std::string command = "cd " REPACK_ORIG_DIR " && /sbin/magiskboot hexpatch kernel 77616E745F696E697472616D667300 736B69705F696E697472616D667300"; + std::string command = "cd " REPACK_ORIG_DIR " && /system/bin/magiskboot hexpatch kernel 77616E745F696E697472616D667300 736B69705F696E697472616D667300"; if (TWFunc::Exec_Cmd(command) != 0) { gui_msg(Msg(msg::kError, "fix_recovery_loop_patch_error=Error patching kernel.")); goto exit; @@ -2215,7 +2220,7 @@ int GUIAction::fixabrecoverybootloop(std::string arg __unused) } DataManager::SetProgress(.5); gui_msg(Msg("repacking_image=Repacking {1}...")(part->Display_Name)); - command = "cd " REPACK_ORIG_DIR " && /sbin/magiskboot repack " REPACK_ORIG_DIR "boot.img"; + command = "cd " REPACK_ORIG_DIR " && /system/bin/magiskboot repack " REPACK_ORIG_DIR "boot.img"; if (TWFunc::Exec_Cmd(command) != 0) { gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); goto exit; diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp old mode 100644 new mode 100755 index 63cd05c5..a9573ad5 --- a/gui/blanktimer.cpp +++ b/gui/blanktimer.cpp @@ -66,7 +66,7 @@ void blanktimer::checkForTimeout() { if (sleepTimer && diff.tv_sec > sleepTimer && state < kOff) { state = kOff; TWFunc::Set_Brightness("0"); - TWFunc::check_and_run_script("/sbin/postscreenblank.sh", "blank"); + TWFunc::check_and_run_script("/system/bin/postscreenblank.sh", "blank"); PageManager::ChangeOverlay("lock"); } #ifndef TW_NO_SCREEN_BLANK @@ -100,7 +100,7 @@ void blanktimer::resetTimerAndUnblank(void) { gr_fb_blank(false); #endif // TODO: this is asymmetric with postscreenblank.sh - shouldn't it be under the next case label? - TWFunc::check_and_run_script("/sbin/postscreenunblank.sh", "unblank"); + TWFunc::check_and_run_script("/system/bin/postscreenunblank.sh", "unblank"); // No break here, we want to keep going case kOff: gui_forceRender(); @@ -129,7 +129,7 @@ void blanktimer::blank(void) { orig_brightness = getBrightness(); state = kOff; TWFunc::Set_Brightness("0"); - TWFunc::check_and_run_script("/sbin/postscreenblank.sh", "blank"); + TWFunc::check_and_run_script("/system/bin/postscreenblank.sh", "blank"); } #ifndef TW_NO_SCREEN_BLANK if (state == kOff) { diff --git a/gui/terminal.cpp b/gui/terminal.cpp index e12df5c7..288a6c3c 100755 --- a/gui/terminal.cpp +++ b/gui/terminal.cpp @@ -116,7 +116,7 @@ public: // (Mandatory for programs like the shell to make them manage correctly their outputs) ioctl(0, TIOCSCTTY, 1); - execl("/sbin/sh", "sh", NULL); + execl("/system/bin/sh", "sh", NULL); _exit(127); } diff --git a/htcdumlock/Android.mk b/htcdumlock/Android.mk old mode 100644 new mode 100755 index 27b3c34f..ffc16018 --- a/htcdumlock/Android.mk +++ b/htcdumlock/Android.mk @@ -8,6 +8,6 @@ ifeq ($(TW_INCLUDE_DUMLOCK), true) LOCAL_MODULE:=htcdumlock LOCAL_MODULE_TAGS:= optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ include $(BUILD_EXECUTABLE) endif diff --git a/injecttwrp/Android.mk b/injecttwrp/Android.mk old mode 100644 new mode 100755 index d7f79361..51040f57 --- a/injecttwrp/Android.mk +++ b/injecttwrp/Android.mk @@ -8,6 +8,6 @@ ifeq ($(TW_INCLUDE_INJECTTWRP), true) LOCAL_MODULE:=injecttwrp LOCAL_MODULE_TAGS:= optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ include $(BUILD_EXECUTABLE) endif diff --git a/install/adb_install.cpp b/install/adb_install.cpp index 44a58a06..0db4a270 100755 --- a/install/adb_install.cpp +++ b/install/adb_install.cpp @@ -291,7 +291,7 @@ static void CreateMinadbdServiceAndExecuteCommands( if (child == 0) { recovery_socket.reset(); std::vector minadbd_commands = { - "/sbin/recovery", + "/system/bin/recovery", "recovery", "--adbd", install_file, diff --git a/install/installcommand.cpp b/install/installcommand.cpp index 5e284727..ee93484d 100755 --- a/install/installcommand.cpp +++ b/install/installcommand.cpp @@ -211,7 +211,7 @@ abupdate_binary_command(const char* path, ZipWrap* zip, int retry_count __unused } long payload_offset = zip->GetEntryOffset(AB_OTA_PAYLOAD); *cmd = { - "/sbin/update_engine_sideload", + "/system/bin/update_engine_sideload", android::base::StringPrintf("--payload=file://%s", path), android::base::StringPrintf("--offset=%ld", payload_offset), "--headers=" + std::string(payload_properties.begin(), diff --git a/install28/adb_install.cpp b/install28/adb_install.cpp deleted file mode 100755 index 5b576411..00000000 --- a/install28/adb_install.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cutils/properties.h" - -#include "common.h" -#ifdef USE_OLD_VERIFIER -#include "verifier24/verifier.h" -#include "ui.h" -#elif USE_28_VERIFIER -#include "verifier28/verifier.h" -#include "verifier28/adb_install.h" -#include "verifier28/ui.h" -#include "verifier28/fuse_sideload.h" -#else -#include "install/install.h" -#endif - -static void set_usb_driver(bool enabled) { - char configfs[PROPERTY_VALUE_MAX]; - property_get("sys.usb.configfs", configfs, "false"); - if (strcmp(configfs, "false") == 0 || strcmp(configfs, "0") == 0) - return; - - int fd = open("/sys/class/android_usb/android0/enable", O_WRONLY); - if (fd < 0) { -/* These error messages show when built in older Android branches (e.g. Gingerbread) - It's not a critical error so we're disabling the error messages. - ui->Print("failed to open driver control: %s\n", strerror(errno)); -*/ - printf("failed to open driver control: %s\n", strerror(errno)); - return; - } - - if (TEMP_FAILURE_RETRY(write(fd, enabled ? "1" : "0", 1)) == -1) { -/* - ui->Print("failed to set driver control: %s\n", strerror(errno)); -*/ - printf("failed to set driver control: %s\n", strerror(errno)); - } - if (close(fd) < 0) { -/* - ui->Print("failed to close driver control: %s\n", strerror(errno)); -*/ - printf("failed to close driver control: %s\n", strerror(errno)); - } -} - -// On Android 8.0 for some reason init can't seem to completely stop adbd -// so we have to kill it too if it doesn't die on its own. -static void kill_adbd() { - DIR* dir = opendir("/proc"); - if (dir) { - struct dirent* de = 0; - - while ((de = readdir(dir)) != 0) { - if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) - continue; - - int pid = -1; - int ret = sscanf(de->d_name, "%d", &pid); - - if (ret == 1) { - char cmdpath[PATH_MAX]; - sprintf(cmdpath, "/proc/%d/cmdline", pid); - - FILE* file = fopen(cmdpath, "r"); - size_t task_size = PATH_MAX; - char task[PATH_MAX]; - char* p = task; - if (getline(&p, &task_size, file) > 0) { - if (strstr(task, "adbd") != 0) { - printf("adbd pid %d found, sending kill.\n", pid); - kill(pid, SIGINT); - usleep(5000); - kill(pid, SIGKILL); - } - } - fclose(file); - } - } - closedir(dir); - } -} - -static void stop_adbd() { - printf("Stopping adbd...\n"); - property_set("ctl.stop", "adbd"); - usleep(5000); - kill_adbd(); - set_usb_driver(false); -} - -static bool is_ro_debuggable() { - char value[PROPERTY_VALUE_MAX+1]; - return (property_get("ro.debuggable", value, NULL) == 1 && value[0] == '1'); -} - -static void maybe_restart_adbd() { - if (is_ro_debuggable()) { - printf("Restarting adbd...\n"); - set_usb_driver(true); - property_set("ctl.start", "adbd"); - } -} - -// How long (in seconds) we wait for the host to start sending us a -// package, before timing out. -#define ADB_INSTALL_TIMEOUT 300 - -int -apply_from_adb(const char* install_file, pid_t* child_pid) { - - stop_adbd(); - set_usb_driver(true); -/* -int apply_from_adb(RecoveryUI* ui, bool* wipe_cache, const char* install_file) { - modified_flash = true; - - stop_adbd(ui); - set_usb_driver(ui, true); - - ui->Print("\n\nNow send the package you want to apply\n" - "to the device with \"adb sideload \"...\n"); -*/ - pid_t child; - if ((child = fork()) == 0) { - execl("/sbin/recovery", "recovery", "--adbd", install_file, NULL); - _exit(-1); - } - - *child_pid = child; - // caller can now kill the child thread from another thread - - // FUSE_SIDELOAD_HOST_PATHNAME will start to exist once the host - // connects and starts serving a package. Poll for its - // appearance. (Note that inotify doesn't work with FUSE.) - int result = INSTALL_ERROR; - int status; - bool waited = false; - struct stat st; - for (int i = 0; i < ADB_INSTALL_TIMEOUT; ++i) { - if (waitpid(child, &status, WNOHANG) != 0) { - result = -1; - waited = true; - break; - } - - if (stat(FUSE_SIDELOAD_HOST_PATHNAME, &st) != 0) { - if (errno == ENOENT && i < ADB_INSTALL_TIMEOUT-1) { - sleep(1); - continue; - } else { - printf("\nTimed out waiting for package: %s\n\n", strerror(errno)); - result = -1; - kill(child, SIGKILL); - break; - } - } - // Install is handled elsewhere in TWRP - //install_package(FUSE_SIDELOAD_HOST_PATHNAME, wipe_cache, install_file, false); - return 0; - } - - // if we got here, something failed - *child_pid = 0; - - if (!waited) { - // Calling stat() on this magic filename signals the minadbd - // subprocess to shut down. - stat(FUSE_SIDELOAD_HOST_EXIT_PATHNAME, &st); - - // TODO(dougz): there should be a way to cancel waiting for a - // package (by pushing some button combo on the device). For now - // you just have to 'adb sideload' a file that's not a valid - // package, like "/dev/null". - waitpid(child, &status, 0); - } - - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - if (WEXITSTATUS(status) == 3) { - printf("\nYou need adb 1.0.32 or newer to sideload\nto this device.\n\n"); - result = -2; - } else if (!WIFSIGNALED(status)) { - printf("adbd status %d\n", WEXITSTATUS(status)); - } - } - - set_usb_driver(false); - maybe_restart_adbd(); - - return result; -} diff --git a/install28/adb_install.h b/install28/adb_install.h deleted file mode 100644 index 97dc83d8..00000000 --- a/install28/adb_install.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _ADB_INSTALL_H -#define _ADB_INSTALL_H - -#include - -//class RecoveryUI; - -//static void set_usb_driver(bool enabled); -//static void maybe_restart_adbd(); -int apply_from_adb(const char* install_file, pid_t* child_pid); - -#endif diff --git a/libblkid/Android.mk b/libblkid/Android.mk old mode 100644 new mode 100755 index 38a192f9..6bdbe355 --- a/libblkid/Android.mk +++ b/libblkid/Android.mk @@ -4,7 +4,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libutil-linux LOCAL_MODULE_TAGS := optional -#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -DHAVE_LOFF_T -DHAVE_ERR_H -DHAVE_MEMPCPY -DHAVE_FSYNC LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wno-format -Wno-pointer-arith LOCAL_SRC_FILES = lib/at.c \ @@ -43,7 +43,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libuuid LOCAL_MODULE_TAGS := optional -#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -DHAVE_LOFF_T -DHAVE_ERR_H -DHAVE_MEMPCPY -DHAVE_FSYNC -DHAVE_SYS_FILE_H LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wno-format -Wno-pointer-arith LOCAL_SRC_FILES = libuuid/src/clear.c \ @@ -70,7 +70,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libfdisk LOCAL_MODULE_TAGS := optional -#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -DHAVE_LOFF_T -DHAVE_ERR_H -DHAVE_MEMPCPY -DHAVE_FSYNC LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wno-format -Wno-pointer-arith LOCAL_SRC_FILES = libfdisk/src/alignment.c \ @@ -103,7 +103,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libblkid LOCAL_MODULE_TAGS := optional -#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -DHAVE_LOFF_T -DHAVE_ERR_H -DHAVE_MEMPCPY -DHAVE_FSYNC LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wno-format -Wno-pointer-arith LOCAL_SRC_FILES = src/cache.c \ diff --git a/libcrecovery/defines.h b/libcrecovery/defines.h old mode 100644 new mode 100755 index d94ad2d6..9b1f2875 --- a/libcrecovery/defines.h +++ b/libcrecovery/defines.h @@ -1,2 +1,2 @@ #undef _PATH_BSHELL -#define _PATH_BSHELL "/sbin/sh" +#define _PATH_BSHELL "/system/bin/sh" diff --git a/minui21/Android.mk b/minui21/Android.mk deleted file mode 100644 index 6191448b..00000000 --- a/minui21/Android.mk +++ /dev/null @@ -1,143 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := graphics_overlay.c events.c resources.c -ifneq ($(BOARD_CUSTOM_GRAPHICS),) - LOCAL_SRC_FILES += $(BOARD_CUSTOM_GRAPHICS) -else - LOCAL_SRC_FILES += graphics.c -endif - -LOCAL_C_INCLUDES +=\ - external/libpng \ - external/zlib \ - system/core/include/pixelflinger - -ifeq ($(TW_TARGET_USES_QCOM_BSP), true) - LOCAL_CFLAGS += -DMSM_BSP - ifeq ($(TARGET_PREBUILT_KERNEL),) - LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr - LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include - else - ifeq ($(TARGET_CUSTOM_KERNEL_HEADERS),) - LOCAL_C_INCLUDES += $(commands_recovery_local_path)/minui/include - else - LOCAL_C_INCLUDES += $(TARGET_CUSTOM_KERNEL_HEADERS) - endif - endif -else - LOCAL_C_INCLUDES += $(commands_recovery_local_path)/minui/include -endif - -ifeq ($(TW_NEW_ION_HEAP), true) - LOCAL_CFLAGS += -DNEW_ION_HEAP -endif - -LOCAL_STATIC_LIBRARY := libpng -LOCAL_WHOLE_STATIC_LIBRARIES := libpixelflinger_static -LOCAL_MODULE := libminui - -# This used to compare against values in double-quotes (which are just -# ordinary characters in this context). Strip double-quotes from the -# value so that either will work. - -ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBA_8888) - LOCAL_CFLAGS += -DRECOVERY_RGBA -endif -ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBX_8888) - LOCAL_CFLAGS += -DRECOVERY_RGBX -endif -ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888) - LOCAL_CFLAGS += -DRECOVERY_BGRA -endif - -ifneq ($(TARGET_RECOVERY_OVERSCAN_PERCENT),) - LOCAL_CFLAGS += -DOVERSCAN_PERCENT=$(TARGET_RECOVERY_OVERSCAN_PERCENT) -else - LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0 -endif - -ifneq ($(TW_BRIGHTNESS_PATH),) - LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=\"$(TW_BRIGHTNESS_PATH)\" -endif -ifneq ($(TW_MAX_BRIGHTNESS),) - LOCAL_CFLAGS += -DTW_MAX_BRIGHTNESS=$(TW_MAX_BRIGHTNESS) -else - LOCAL_CFLAGS += -DTW_MAX_BRIGHTNESS=255 -endif -ifneq ($(TW_NO_SCREEN_BLANK),) - LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK -endif -ifneq ($(BOARD_USE_CUSTOM_RECOVERY_FONT),) - LOCAL_CFLAGS += -DBOARD_USE_CUSTOM_RECOVERY_FONT=$(BOARD_USE_CUSTOM_RECOVERY_FONT) -endif -include $(BUILD_STATIC_LIBRARY) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := graphics_overlay.c events.c resources.c -ifneq ($(BOARD_CUSTOM_GRAPHICS),) - LOCAL_SRC_FILES += $(BOARD_CUSTOM_GRAPHICS) -else - LOCAL_SRC_FILES += graphics.c -endif - -ifeq ($(TW_TARGET_USES_QCOM_BSP), true) - LOCAL_CFLAGS += -DMSM_BSP - ifeq ($(TARGET_PREBUILT_KERNEL),) - LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr - LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include - else - ifeq ($(TARGET_CUSTOM_KERNEL_HEADERS),) - LOCAL_C_INCLUDES += $(commands_recovery_local_path)/minui/include - else - LOCAL_C_INCLUDES += $(TARGET_CUSTOM_KERNEL_HEADERS) - endif - endif -else - LOCAL_C_INCLUDES += $(commands_recovery_local_path)/minui/include -endif - -LOCAL_C_INCLUDES +=\ - external/libpng\ - external/zlib - -LOCAL_MODULE := libminui - -LOCAL_ARM_MODE:= arm -LOCAL_SHARED_LIBRARIES := libpng libpixelflinger -# This used to compare against values in double-quotes (which are just -# ordinary characters in this context). Strip double-quotes from the -# value so that either will work. - -ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBX_8888) - LOCAL_CFLAGS += -DRECOVERY_RGBX -endif -ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888) - LOCAL_CFLAGS += -DRECOVERY_BGRA -endif - -ifneq ($(TARGET_RECOVERY_OVERSCAN_PERCENT),) - LOCAL_CFLAGS += -DOVERSCAN_PERCENT=$(TARGET_RECOVERY_OVERSCAN_PERCENT) -else - LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0 -endif - -ifneq ($(TW_BRIGHTNESS_PATH),) - LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=\"$(TW_BRIGHTNESS_PATH)\" -endif -ifneq ($(TW_MAX_BRIGHTNESS),) - LOCAL_CFLAGS += -DTW_MAX_BRIGHTNESS=$(TW_MAX_BRIGHTNESS) -else - LOCAL_CFLAGS += -DTW_MAX_BRIGHTNESS=255 -endif -ifneq ($(TW_NO_SCREEN_BLANK),) - LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK -endif -ifneq ($(BOARD_USE_CUSTOM_RECOVERY_FONT),) - LOCAL_CFLAGS += -DBOARD_USE_CUSTOM_RECOVERY_FONT=$(BOARD_USE_CUSTOM_RECOVERY_FONT) -endif - -LOCAL_CFLAGS += -DFASTMMI_FEATURE - -include $(BUILD_SHARED_LIBRARY) diff --git a/minui21/events.c b/minui21/events.c deleted file mode 100644 index b8cf15ab..00000000 --- a/minui21/events.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include - -#include "minui.h" - -#define MAX_DEVICES 16 -#define MAX_MISC_FDS 16 - -#define BITS_PER_LONG (sizeof(unsigned long) * 8) -#define BITS_TO_LONGS(x) (((x) + BITS_PER_LONG - 1) / BITS_PER_LONG) - -#define test_bit(bit, array) \ - ((array)[(bit)/BITS_PER_LONG] & (1 << ((bit) % BITS_PER_LONG))) - -struct fd_info { - int fd; - ev_callback cb; - void *data; -}; - -static int epollfd; -static struct epoll_event polledevents[MAX_DEVICES + MAX_MISC_FDS]; -static int npolledevents; - -static struct fd_info ev_fdinfo[MAX_DEVICES + MAX_MISC_FDS]; - -static unsigned ev_count = 0; -static unsigned ev_dev_count = 0; -static unsigned ev_misc_count = 0; - -int ev_init(ev_callback input_cb, void *data) -{ - DIR *dir; - struct dirent *de; - int fd; - struct epoll_event ev; - bool epollctlfail = false; - - epollfd = epoll_create(MAX_DEVICES + MAX_MISC_FDS); - if (epollfd == -1) - return -1; - - dir = opendir("/dev/input"); - if(dir != 0) { - while((de = readdir(dir))) { - unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; - -// fprintf(stderr,"/dev/input/%s\n", de->d_name); - if(strncmp(de->d_name,"event",5)) continue; - fd = openat(dirfd(dir), de->d_name, O_RDONLY); - if(fd < 0) continue; - - /* read the evbits of the input device */ - if (ioctl(fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits) < 0) { - close(fd); - continue; - } - - /* TODO: add ability to specify event masks. For now, just assume - * that only EV_KEY and EV_REL event types are ever needed. */ - if (!test_bit(EV_KEY, ev_bits) && !test_bit(EV_REL, ev_bits)) { - close(fd); - continue; - } - -#ifdef EPOLLWAKEUP - ev.events = EPOLLIN | EPOLLWAKEUP; -#else - ev.events = EPOLLIN; -#endif - ev.data.ptr = (void *)&ev_fdinfo[ev_count]; - if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev)) { - close(fd); - epollctlfail = true; - continue; - } - - ev_fdinfo[ev_count].fd = fd; - ev_fdinfo[ev_count].cb = input_cb; - ev_fdinfo[ev_count].data = data; - ev_count++; - ev_dev_count++; - if(ev_dev_count == MAX_DEVICES) break; - } - } - - if (epollctlfail && !ev_count) { - close(epollfd); - epollfd = -1; - return -1; - } - - return 0; -} - -int ev_add_fd(int fd, ev_callback cb, void *data) -{ - struct epoll_event ev; - int ret; - - if (ev_misc_count == MAX_MISC_FDS || cb == NULL) - return -1; - -#ifdef EPOLLWAKEUP - ev.events = EPOLLIN | EPOLLWAKEUP; -#else - ev.events = EPOLLIN; -#endif - ev.data.ptr = (void *)&ev_fdinfo[ev_count]; - ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev); - if (!ret) { - ev_fdinfo[ev_count].fd = fd; - ev_fdinfo[ev_count].cb = cb; - ev_fdinfo[ev_count].data = data; - ev_count++; - ev_misc_count++; - } - - return ret; -} - -int ev_get_epollfd(void) -{ - return epollfd; -} - -void ev_exit(void) -{ - while (ev_count > 0) { - close(ev_fdinfo[--ev_count].fd); - } - ev_misc_count = 0; - ev_dev_count = 0; - close(epollfd); -} - -int ev_wait(int timeout) -{ - npolledevents = epoll_wait(epollfd, polledevents, ev_count, timeout); - if (npolledevents <= 0) - return -1; - return 0; -} - -void ev_dispatch(void) -{ - int n; - int ret; - - for (n = 0; n < npolledevents; n++) { - struct fd_info *fdi = polledevents[n].data.ptr; - ev_callback cb = fdi->cb; - if (cb) - cb(fdi->fd, polledevents[n].events, fdi->data); - } -} - -int ev_get_input(int fd, uint32_t epevents, struct input_event *ev) -{ - int r; - - if (epevents & EPOLLIN) { - r = read(fd, ev, sizeof(*ev)); - if (r == sizeof(*ev)) - return 0; - } - return -1; -} - -int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data) -{ - unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; - unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; - unsigned i; - int ret; - - for (i = 0; i < ev_dev_count; i++) { - int code; - - memset(key_bits, 0, sizeof(key_bits)); - memset(ev_bits, 0, sizeof(ev_bits)); - - ret = ioctl(ev_fdinfo[i].fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits); - if (ret < 0 || !test_bit(EV_KEY, ev_bits)) - continue; - - ret = ioctl(ev_fdinfo[i].fd, EVIOCGKEY(sizeof(key_bits)), key_bits); - if (ret < 0) - continue; - - for (code = 0; code <= KEY_MAX; code++) { - if (test_bit(code, key_bits)) - set_key_cb(code, 1, data); - } - } - - return 0; -} diff --git a/minui21/font_10x18.h b/minui21/font_10x18.h deleted file mode 100644 index 7f96465c..00000000 --- a/minui21/font_10x18.h +++ /dev/null @@ -1,214 +0,0 @@ -struct { - unsigned width; - unsigned height; - unsigned cwidth; - unsigned cheight; - unsigned char rundata[]; -} font = { - .width = 960, - .height = 18, - .cwidth = 10, - .cheight = 18, - .rundata = { -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x55,0x82,0x06,0x82,0x02,0x82,0x10,0x82, -0x11,0x83,0x08,0x82,0x0a,0x82,0x04,0x82,0x46,0x82,0x08,0x82,0x07,0x84,0x06, -0x84,0x0a,0x81,0x03,0x88,0x04,0x84,0x04,0x88,0x04,0x84,0x06,0x84,0x1e,0x81, -0x0e,0x81,0x0a,0x84,0x06,0x84,0x07,0x82,0x05,0x85,0x07,0x84,0x04,0x86,0x04, -0x88,0x02,0x88,0x04,0x84,0x04,0x82,0x04,0x82,0x02,0x88,0x05,0x86,0x01,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x04,0x84,0x04, -0x86,0x06,0x84,0x04,0x86,0x06,0x84,0x04,0x88,0x02,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02, -0x88,0x03,0x86,0x0e,0x86,0x06,0x82,0x11,0x82,0x10,0x82,0x18,0x82,0x0f,0x84, -0x0d,0x82,0x1c,0x82,0x09,0x84,0x7f,0x16,0x84,0x05,0x82,0x05,0x84,0x07,0x83, -0x02,0x82,0x19,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x01,0x82,0x03,0x86,0x04, -0x83,0x02,0x82,0x03,0x82,0x01,0x82,0x07,0x82,0x09,0x82,0x06,0x82,0x3e,0x82, -0x04,0x84,0x06,0x83,0x06,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x03, -0x82,0x09,0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82, -0x1c,0x82,0x0e,0x82,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x05,0x84,0x04, -0x82,0x02,0x82,0x05,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82, -0x09,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x04, -0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x03,0x82,0x02,0x82, -0x03,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x02, -0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x03,0x82,0x08,0x82,0x0c, -0x82,0x05,0x84,0x11,0x82,0x0f,0x82,0x18,0x82,0x0e,0x82,0x02,0x82,0x0c,0x82, -0x1c,0x82,0x0b,0x82,0x7f,0x15,0x82,0x08,0x82,0x08,0x82,0x05,0x82,0x01,0x82, -0x01,0x82,0x19,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x01,0x82,0x02,0x82,0x01, -0x82,0x01,0x82,0x02,0x82,0x01,0x82,0x01,0x82,0x03,0x82,0x01,0x82,0x07,0x82, -0x08,0x82,0x08,0x82,0x3d,0x82,0x03,0x82,0x02,0x82,0x04,0x84,0x05,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x06,0x83,0x03,0x82,0x08,0x82,0x04,0x81,0x09,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x1a,0x82,0x10,0x82,0x06,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x83, -0x02,0x83,0x02,0x83,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x08,0x82,0x0c,0x82,0x04,0x82,0x02,0x82, -0x11,0x82,0x0e,0x82,0x18,0x82,0x0e,0x82,0x02,0x82,0x0c,0x82,0x0b,0x82,0x0b, -0x82,0x02,0x82,0x0b,0x82,0x4d,0x82,0x45,0x82,0x08,0x82,0x08,0x82,0x05,0x82, -0x02,0x83,0x1a,0x82,0x07,0x81,0x02,0x81,0x07,0x82,0x01,0x82,0x02,0x82,0x01, -0x82,0x05,0x82,0x01,0x84,0x04,0x82,0x01,0x82,0x07,0x82,0x08,0x82,0x08,0x82, -0x06,0x82,0x02,0x82,0x06,0x82,0x28,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x01, -0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x84,0x03,0x82,0x08,0x82, -0x0d,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x19,0x82,0x12,0x82,0x05, -0x82,0x04,0x82,0x02,0x82,0x02,0x84,0x03,0x82,0x02,0x82,0x03,0x82,0x03,0x82, -0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x04, -0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x83,0x02,0x83, -0x02,0x84,0x02,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x0b,0x82,0x05,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08, -0x82,0x04,0x82,0x09,0x82,0x0b,0x82,0x03,0x82,0x04,0x82,0x20,0x82,0x18,0x82, -0x0e,0x82,0x10,0x82,0x0b,0x82,0x0b,0x82,0x02,0x82,0x0b,0x82,0x4d,0x82,0x45, -0x82,0x08,0x82,0x08,0x82,0x26,0x82,0x10,0x88,0x01,0x82,0x01,0x82,0x06,0x83, -0x01,0x82,0x04,0x84,0x08,0x81,0x08,0x82,0x0a,0x82,0x05,0x82,0x02,0x82,0x06, -0x82,0x28,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x08,0x82,0x04,0x82, -0x01,0x82,0x03,0x82,0x08,0x82,0x0d,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x18,0x82,0x06,0x88,0x06,0x82,0x04,0x82,0x04,0x82,0x02,0x82,0x01,0x85, -0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x04,0x82,0x02, -0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82, -0x02,0x82,0x04,0x82,0x08,0x88,0x02,0x84,0x02,0x82,0x02,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x0b,0x82, -0x05,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x04,0x84,0x06, -0x84,0x08,0x82,0x05,0x82,0x09,0x82,0x0b,0x82,0x2b,0x82,0x18,0x82,0x0e,0x82, -0x10,0x82,0x1c,0x82,0x0b,0x82,0x4d,0x82,0x45,0x82,0x08,0x82,0x08,0x82,0x26, -0x82,0x11,0x82,0x01,0x82,0x03,0x82,0x01,0x82,0x09,0x82,0x06,0x82,0x12,0x82, -0x0a,0x82,0x06,0x84,0x07,0x82,0x27,0x82,0x04,0x82,0x04,0x82,0x05,0x82,0x0b, -0x82,0x07,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x01,0x83,0x04,0x82,0x01,0x83, -0x08,0x82,0x05,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x05,0x83,0x07,0x83,0x05, -0x82,0x16,0x82,0x08,0x82,0x03,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82, -0x02,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08, -0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82, -0x08,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82, -0x0a,0x82,0x05,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01, -0x82,0x04,0x84,0x06,0x84,0x08,0x82,0x05,0x82,0x0a,0x82,0x0a,0x82,0x23,0x85, -0x03,0x82,0x01,0x83,0x06,0x85,0x05,0x83,0x01,0x82,0x04,0x84,0x04,0x86,0x05, -0x85,0x01,0x81,0x02,0x82,0x01,0x83,0x05,0x84,0x09,0x84,0x02,0x82,0x03,0x82, -0x06,0x82,0x05,0x81,0x01,0x82,0x01,0x82,0x03,0x82,0x01,0x83,0x06,0x84,0x04, -0x82,0x01,0x83,0x06,0x83,0x01,0x82,0x02,0x82,0x01,0x84,0x04,0x86,0x03,0x86, -0x04,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x03,0x87,0x05,0x82,0x08,0x82,0x08,0x82,0x26,0x82, -0x11,0x82,0x01,0x82,0x04,0x86,0x07,0x82,0x05,0x83,0x12,0x82,0x0a,0x82,0x04, -0x88,0x02,0x88,0x0c,0x88,0x10,0x82,0x04,0x82,0x04,0x82,0x05,0x82,0x0a,0x82, -0x06,0x83,0x04,0x82,0x03,0x82,0x03,0x83,0x02,0x82,0x03,0x83,0x02,0x82,0x07, -0x82,0x06,0x84,0x05,0x82,0x02,0x83,0x05,0x83,0x07,0x83,0x04,0x82,0x18,0x82, -0x06,0x82,0x04,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x86,0x04, -0x82,0x08,0x82,0x04,0x82,0x02,0x86,0x04,0x86,0x04,0x82,0x02,0x84,0x02,0x88, -0x05,0x82,0x0a,0x82,0x03,0x85,0x05,0x82,0x08,0x82,0x01,0x82,0x01,0x82,0x02, -0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82, -0x04,0x82,0x02,0x82,0x03,0x82,0x05,0x84,0x07,0x82,0x05,0x82,0x04,0x82,0x03, -0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01,0x82,0x05,0x82,0x08,0x82,0x08,0x82, -0x06,0x82,0x0a,0x82,0x0a,0x82,0x22,0x82,0x03,0x82,0x02,0x83,0x02,0x82,0x04, -0x82,0x03,0x82,0x03,0x82,0x02,0x83,0x03,0x82,0x02,0x82,0x05,0x82,0x06,0x82, -0x03,0x83,0x02,0x83,0x02,0x82,0x06,0x82,0x0b,0x82,0x02,0x82,0x02,0x82,0x07, -0x82,0x05,0x88,0x02,0x83,0x02,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02,0x82, -0x04,0x82,0x02,0x83,0x03,0x83,0x02,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x06, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82, -0x03,0x82,0x04,0x82,0x08,0x82,0x02,0x84,0x09,0x82,0x09,0x84,0x23,0x82,0x11, -0x82,0x01,0x82,0x06,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x01,0x82,0x11,0x82, -0x0a,0x82,0x06,0x84,0x07,0x82,0x26,0x82,0x05,0x82,0x04,0x82,0x05,0x82,0x08, -0x83,0x09,0x82,0x03,0x82,0x03,0x82,0x09,0x82,0x02,0x82,0x04,0x82,0x05,0x82, -0x06,0x82,0x02,0x82,0x05,0x83,0x01,0x82,0x17,0x82,0x16,0x82,0x06,0x82,0x05, -0x82,0x01,0x82,0x01,0x82,0x02,0x88,0x02,0x82,0x03,0x82,0x03,0x82,0x08,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, -0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x01,0x82,0x01,0x82, -0x02,0x82,0x02,0x84,0x02,0x82,0x04,0x82,0x02,0x86,0x04,0x82,0x04,0x82,0x02, -0x86,0x09,0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x82, -0x01,0x82,0x04,0x84,0x07,0x82,0x07,0x82,0x07,0x82,0x0b,0x82,0x09,0x82,0x27, -0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x04,0x82,0x06,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02, -0x82,0x01,0x82,0x08,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x07, -0x82,0x0a,0x82,0x06,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x04,0x82, -0x04,0x84,0x04,0x82,0x04,0x82,0x07,0x82,0x06,0x82,0x08,0x82,0x08,0x82,0x26, -0x82,0x0f,0x88,0x05,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x02,0x82,0x01,0x82, -0x0d,0x82,0x0a,0x82,0x05,0x82,0x02,0x82,0x06,0x82,0x26,0x82,0x05,0x82,0x04, -0x82,0x05,0x82,0x07,0x82,0x0c,0x82,0x02,0x88,0x08,0x82,0x02,0x82,0x04,0x82, -0x05,0x82,0x05,0x82,0x04,0x82,0x08,0x82,0x18,0x82,0x14,0x82,0x07,0x82,0x05, -0x82,0x01,0x84,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, -0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x08,0x82,0x01,0x82,0x01,0x82, -0x02,0x82,0x02,0x84,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02, -0x82,0x02,0x82,0x0a,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x82, -0x01,0x82,0x01,0x82,0x04,0x84,0x07,0x82,0x07,0x82,0x07,0x82,0x0b,0x82,0x09, -0x82,0x22,0x87,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x88, -0x04,0x82,0x06,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02, -0x84,0x09,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x08,0x86,0x05, -0x82,0x06,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x01,0x82,0x01,0x82, -0x05,0x82,0x05,0x82,0x04,0x82,0x06,0x82,0x07,0x82,0x08,0x82,0x08,0x82,0x26, -0x82,0x10,0x82,0x01,0x82,0x07,0x82,0x01,0x82,0x04,0x82,0x01,0x83,0x02,0x82, -0x03,0x83,0x0f,0x82,0x08,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x25,0x82,0x07, -0x82,0x02,0x82,0x06,0x82,0x06,0x82,0x07,0x82,0x04,0x82,0x07,0x82,0x09,0x82, -0x02,0x82,0x04,0x82,0x04,0x82,0x06,0x82,0x04,0x82,0x08,0x82,0x19,0x82,0x05, -0x88,0x05,0x82,0x08,0x82,0x05,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x08,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82,0x03,0x82,0x03,0x82,0x03,0x82, -0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02,0x82,0x04,0x82,0x02, -0x82,0x08,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x03,0x82,0x09,0x82,0x05,0x82, -0x05,0x82,0x04,0x82,0x04,0x84,0x04,0x83,0x02,0x83,0x03,0x82,0x02,0x82,0x06, -0x82,0x06,0x82,0x08,0x82,0x0c,0x82,0x08,0x82,0x21,0x82,0x04,0x82,0x02,0x82, -0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x0a,0x82,0x06,0x82,0x03, -0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x85,0x08,0x82,0x05,0x82, -0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x0d,0x82,0x04,0x82,0x06,0x82,0x04,0x82, -0x04,0x84,0x04,0x82,0x01,0x82,0x01,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x05, -0x82,0x08,0x82,0x08,0x82,0x08,0x82,0x38,0x82,0x01,0x82,0x04,0x82,0x01,0x82, -0x01,0x82,0x04,0x84,0x01,0x82,0x01,0x82,0x03,0x82,0x10,0x82,0x08,0x82,0x30, -0x83,0x06,0x82,0x07,0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x08,0x82,0x04,0x82, -0x07,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x06,0x82,0x04, -0x82,0x03,0x81,0x04,0x82,0x1a,0x82,0x10,0x82,0x10,0x82,0x08,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08, -0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x82,0x03,0x82, -0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x03,0x83,0x02, -0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x02,0x84,0x02,0x82,0x03,0x82,0x03,0x82, -0x04,0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x05,0x82,0x05,0x83,0x02,0x83,0x03, -0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x09,0x82,0x0c,0x82,0x08,0x82,0x21,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x0a, -0x82,0x07,0x85,0x04,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x82,0x02,0x82, -0x07,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x0d,0x82,0x04,0x82, -0x06,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x82,0x01,0x82,0x04,0x84,0x04, -0x82,0x04,0x82,0x04,0x82,0x09,0x82,0x08,0x82,0x08,0x82,0x26,0x82,0x10,0x82, -0x01,0x82,0x05,0x86,0x04,0x82,0x01,0x82,0x01,0x82,0x01,0x83,0x01,0x84,0x10, -0x82,0x06,0x82,0x1d,0x83,0x11,0x83,0x05,0x82,0x09,0x84,0x07,0x82,0x05,0x82, -0x09,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04, -0x82,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x06,0x83,0x07,0x83,0x09,0x82, -0x0e,0x82,0x0a,0x82,0x06,0x82,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x03, -0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x08,0x82,0x09,0x82, -0x02,0x83,0x02,0x82,0x04,0x82,0x05,0x82,0x06,0x82,0x01,0x82,0x04,0x82,0x04, -0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82, -0x03,0x82,0x09,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x06, -0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x05,0x82,0x05,0x82,0x09,0x82,0x0d,0x82,0x07,0x82,0x21,0x82,0x04,0x82,0x02, -0x83,0x02,0x82,0x04,0x82,0x03,0x82,0x03,0x82,0x02,0x83,0x03,0x82,0x03,0x82, -0x04,0x82,0x06,0x82,0x08,0x82,0x04,0x82,0x05,0x82,0x0b,0x82,0x02,0x82,0x03, -0x82,0x06,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x03,0x82, -0x02,0x82,0x03,0x83,0x02,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x07,0x82,0x04, -0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x02,0x83,0x05,0x82,0x05,0x88,0x03,0x82, -0x02,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x0a,0x82,0x08,0x82,0x08,0x82,0x26, -0x82,0x1c,0x82,0x06,0x82,0x02,0x83,0x03,0x84,0x02,0x82,0x10,0x82,0x04,0x82, -0x1e,0x83,0x11,0x83,0x05,0x82,0x0a,0x82,0x05,0x88,0x02,0x88,0x04,0x84,0x09, -0x82,0x05,0x84,0x06,0x84,0x05,0x82,0x09,0x84,0x06,0x84,0x07,0x83,0x07,0x83, -0x0a,0x81,0x0e,0x81,0x0b,0x82,0x07,0x85,0x03,0x82,0x04,0x82,0x02,0x86,0x06, -0x84,0x04,0x86,0x04,0x88,0x02,0x82,0x0a,0x84,0x01,0x81,0x02,0x82,0x04,0x82, -0x02,0x88,0x04,0x83,0x05,0x82,0x04,0x82,0x02,0x88,0x02,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x0a,0x85,0x03,0x82,0x04,0x82,0x04,0x84, -0x07,0x82,0x07,0x84,0x07,0x82,0x05,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05, -0x82,0x05,0x88,0x03,0x86,0x09,0x82,0x03,0x86,0x22,0x85,0x01,0x81,0x02,0x82, -0x01,0x83,0x06,0x85,0x05,0x83,0x01,0x82,0x04,0x85,0x05,0x82,0x07,0x86,0x03, -0x82,0x04,0x82,0x02,0x88,0x08,0x82,0x02,0x82,0x04,0x82,0x02,0x88,0x02,0x82, -0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x83,0x06, -0x83,0x01,0x82,0x03,0x82,0x08,0x86,0x06,0x84,0x05,0x83,0x01,0x82,0x05,0x82, -0x06,0x82,0x02,0x82,0x03,0x82,0x04,0x82,0x04,0x83,0x01,0x82,0x03,0x87,0x06, -0x84,0x05,0x82,0x05,0x84,0x7f,0x15,0x83,0x7f,0x14,0x83,0x7f,0x5e,0x82,0x7f, -0x05,0x89,0x47,0x82,0x04,0x82,0x17,0x82,0x03,0x82,0x34,0x82,0x0e,0x82,0x4e, -0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0a,0x82,0x04,0x82,0x17,0x82,0x03,0x82, -0x34,0x82,0x0e,0x82,0x48,0x82,0x04,0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0a, -0x82,0x04,0x82,0x17,0x82,0x03,0x82,0x34,0x82,0x0e,0x82,0x49,0x82,0x02,0x82, -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0c,0x86,0x19,0x85,0x35,0x82,0x0e,0x82,0x4a, -0x84,0x3f, -0x00, - } -}; diff --git a/minui21/font_7x16.h b/minui21/font_7x16.h deleted file mode 100644 index 0f72b538..00000000 --- a/minui21/font_7x16.h +++ /dev/null @@ -1,15 +0,0 @@ -struct { - unsigned width; - unsigned height; - unsigned cwidth; - unsigned cheight; - unsigned char rundata[]; -} font = { - .width = 668, - .height = 16, - .cwidth = 7, - .cheight = 16, - .rundata = { -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7e,0x82,0x03,0x82,0x7f,0x7f,0x5f,0x82,0x0b,0x82,0x14,0x81,0x0b,0x81,0x11,0x81,0x0c,0x82,0x09,0x81,0x08,0x81,0x07,0x81,0x03,0x81,0x06,0x83,0x68,0x83,0x04,0x81,0x04,0x83,0x17,0x81,0x05,0x81,0x01,0x81,0x0c,0x81,0x04,0x82,0x07,0x83,0x04,0x81,0x07,0x81,0x05,0x81,0x06,0x81,0x25,0x81,0x02,0x84,0x02,0x83,0x05,0x84,0x03,0x84,0x05,0x82,0x02,0x85,0x04,0x83,0x02,0x86,0x02,0x84,0x03,0x84,0x27,0x83,0x0b,0x82,0x03,0x85,0x04,0x83,0x02,0x84,0x03,0x86,0x01,0x86,0x03,0x83,0x02,0x81,0x04,0x81,0x01,0x85,0x04,0x83,0x02,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x82,0x03,0x81,0x02,0x84,0x02,0x85,0x03,0x84,0x02,0x85,0x03,0x84,0x01,0x87,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x82,0x05,0x81,0x01,0x81,0x04,0x82,0x05,0x81,0x01,0x86,0x03,0x81,0x04,0x81,0x08,0x81,0x05,0x82,0x0e,0x81,0x0a,0x81,0x11,0x81,0x0b,0x81,0x0b,0x81,0x14,0x81,0x08,0x81,0x37,0x81,0x30,0x81,0x06,0x81,0x06,0x81,0x17,0x81,0x05,0x81,0x01,0x81,0x05,0x81,0x01,0x81,0x03,0x83,0x02,0x81,0x02,0x81,0x05,0x81,0x07,0x81,0x07,0x81,0x05,0x81,0x04,0x81,0x01,0x81,0x01,0x81,0x22,0x81,0x03,0x81,0x02,0x81,0x04,0x81,0x04,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x04,0x82,0x02,0x81,0x07,0x81,0x03,0x81,0x05,0x82,0x01,0x81,0x04,0x81,0x01,0x82,0x02,0x81,0x26,0x81,0x03,0x81,0x03,0x83,0x04,0x82,0x03,0x81,0x04,0x81,0x02,0x81,0x03,0x81,0x01,0x81,0x03,0x81,0x02,0x81,0x06,0x81,0x07,0x81,0x03,0x81,0x01,0x81,0x04,0x81,0x03,0x81,0x08,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x06,0x82,0x02,0x82,0x01,0x82,0x03,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x04,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x01,0x81,0x04,0x82,0x02,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x03,0x81,0x06,0x82,0x03,0x81,0x05,0x81,0x07,0x81,0x04,0x81,0x02,0x81,0x18,0x81,0x11,0x81,0x0b,0x81,0x0b,0x81,0x14,0x81,0x08,0x81,0x37,0x81,0x30,0x81,0x06,0x81,0x06,0x81,0x17,0x81,0x05,0x81,0x01,0x81,0x04,0x81,0x02,0x81,0x02,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x02,0x81,0x05,0x81,0x07,0x81,0x06,0x81,0x07,0x81,0x04,0x83,0x05,0x81,0x1d,0x81,0x02,0x81,0x04,0x81,0x03,0x81,0x09,0x81,0x06,0x81,0x03,0x81,0x01,0x81,0x02,0x81,0x06,0x81,0x0a,0x81,0x02,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x14,0x81,0x08,0x81,0x0b,0x81,0x02,0x81,0x02,0x82,0x03,0x82,0x03,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x06,0x81,0x06,0x81,0x04,0x81,0x03,0x81,0x08,0x81,0x02,0x81,0x02,0x81,0x03,0x81,0x06,0x82,0x02,0x82,0x01,0x81,0x01,0x81,0x02,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x08,0x81,0x04,0x81,0x04,0x81,0x02,0x81,0x02,0x81,0x01,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x03,0x81,0x01,0x81,0x07,0x81,0x04,0x81,0x05,0x81,0x07,0x81,0x03,0x81,0x04,0x81,0x11,0x83,0x03,0x84,0x04,0x83,0x04,0x84,0x03,0x83,0x03,0x85,0x03,0x84,0x02,0x81,0x01,0x82,0x03,0x83,0x05,0x83,0x03,0x81,0x03,0x81,0x04,0x81,0x04,0x85,0x02,0x81,0x01,0x82,0x04,0x83,0x03,0x84,0x04,0x84,0x03,0x84,0x03,0x83,0x03,0x85,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x01,0x81,0x05,0x81,0x01,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x85,0x04,0x81,0x06,0x81,0x06,0x81,0x17,0x81,0x0b,0x86,0x01,0x81,0x01,0x81,0x04,0x82,0x02,0x81,0x03,0x82,0x0d,0x81,0x07,0x81,0x04,0x83,0x05,0x81,0x1c,0x81,0x03,0x81,0x04,0x81,0x03,0x81,0x09,0x81,0x06,0x81,0x02,0x82,0x01,0x81,0x02,0x85,0x02,0x81,0x01,0x83,0x06,0x81,0x02,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x03,0x81,0x06,0x81,0x06,0x83,0x0a,0x83,0x06,0x82,0x02,0x81,0x04,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x06,0x81,0x06,0x81,0x04,0x81,0x03,0x81,0x08,0x81,0x02,0x81,0x01,0x81,0x04,0x81,0x06,0x81,0x01,0x82,0x01,0x81,0x01,0x81,0x01,0x81,0x02,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x01,0x82,0x07,0x81,0x04,0x81,0x04,0x81,0x02,0x81,0x02,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x03,0x82,0x04,0x81,0x01,0x81,0x06,0x81,0x05,0x81,0x06,0x81,0x06,0x81,0x19,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x82,0x05,0x81,0x03,0x81,0x02,0x82,0x02,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x02,0x82,0x02,0x81,0x04,0x81,0x07,0x81,0x03,0x81,0x02,0x81,0x05,0x81,0x04,0x81,0x01,0x81,0x01,0x81,0x02,0x82,0x02,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x03,0x82,0x02,0x81,0x01,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x01,0x81,0x05,0x81,0x02,0x81,0x01,0x81,0x03,0x81,0x03,0x81,0x06,0x81,0x04,0x81,0x06,0x81,0x06,0x81,0x17,0x81,0x0c,0x81,0x01,0x81,0x03,0x83,0x06,0x82,0x04,0x82,0x0d,0x81,0x07,0x81,0x03,0x81,0x01,0x81,0x01,0x81,0x04,0x81,0x1c,0x81,0x03,0x81,0x02,0x81,0x01,0x81,0x03,0x81,0x08,0x81,0x04,0x83,0x03,0x81,0x02,0x81,0x06,0x82,0x01,0x82,0x02,0x82,0x04,0x81,0x04,0x84,0x02,0x81,0x03,0x82,0x03,0x81,0x06,0x81,0x04,0x82,0x05,0x86,0x05,0x82,0x03,0x82,0x03,0x81,0x02,0x83,0x02,0x81,0x02,0x81,0x02,0x85,0x02,0x81,0x06,0x81,0x04,0x81,0x01,0x86,0x01,0x86,0x01,0x81,0x03,0x82,0x01,0x86,0x03,0x81,0x08,0x81,0x02,0x83,0x04,0x81,0x06,0x81,0x01,0x82,0x01,0x81,0x01,0x81,0x01,0x82,0x01,0x81,0x01,0x81,0x04,0x81,0x01,0x85,0x02,0x81,0x04,0x81,0x01,0x85,0x03,0x84,0x04,0x81,0x04,0x81,0x04,0x81,0x02,0x81,0x02,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x03,0x82,0x05,0x81,0x06,0x82,0x05,0x81,0x06,0x81,0x06,0x81,0x1d,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x06,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x04,0x81,0x07,0x81,0x03,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x01,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x03,0x81,0x05,0x81,0x08,0x81,0x04,0x81,0x03,0x81,0x03,0x81,0x01,0x81,0x03,0x81,0x01,0x81,0x01,0x81,0x03,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x03,0x82,0x07,0x81,0x07,0x82,0x02,0x83,0x10,0x81,0x0c,0x81,0x01,0x81,0x05,0x83,0x02,0x82,0x01,0x82,0x02,0x81,0x02,0x81,0x01,0x81,0x0a,0x81,0x07,0x81,0x05,0x81,0x03,0x87,0x09,0x83,0x0c,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x07,0x81,0x08,0x81,0x01,0x81,0x03,0x81,0x07,0x81,0x01,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x04,0x81,0x02,0x83,0x01,0x81,0x0f,0x82,0x10,0x82,0x03,0x81,0x04,0x81,0x01,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x02,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x03,0x81,0x08,0x81,0x02,0x81,0x02,0x81,0x03,0x81,0x06,0x81,0x01,0x82,0x01,0x81,0x01,0x81,0x02,0x81,0x01,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x03,0x81,0x07,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x02,0x81,0x02,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x03,0x82,0x05,0x81,0x06,0x81,0x06,0x81,0x07,0x81,0x05,0x81,0x1a,0x84,0x02,0x81,0x03,0x81,0x02,0x81,0x06,0x81,0x03,0x81,0x02,0x85,0x04,0x81,0x04,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x04,0x81,0x07,0x81,0x03,0x82,0x07,0x81,0x04,0x81,0x01,0x81,0x01,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x03,0x81,0x06,0x83,0x05,0x81,0x04,0x81,0x03,0x81,0x03,0x81,0x01,0x81,0x03,0x81,0x01,0x81,0x01,0x81,0x04,0x81,0x05,0x81,0x01,0x81,0x05,0x81,0x06,0x81,0x06,0x81,0x06,0x81,0x07,0x83,0x18,0x86,0x04,0x81,0x01,0x81,0x04,0x81,0x02,0x81,0x01,0x81,0x02,0x83,0x0a,0x81,0x07,0x81,0x0c,0x81,0x1b,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x06,0x81,0x09,0x81,0x01,0x86,0x06,0x81,0x01,0x81,0x04,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x06,0x81,0x11,0x83,0x02,0x86,0x02,0x83,0x0a,0x81,0x01,0x81,0x02,0x81,0x02,0x84,0x02,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x03,0x81,0x08,0x81,0x02,0x81,0x02,0x82,0x02,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x02,0x81,0x01,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x06,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x03,0x82,0x03,0x82,0x01,0x82,0x03,0x81,0x02,0x81,0x04,0x81,0x05,0x81,0x07,0x81,0x07,0x81,0x05,0x81,0x19,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x06,0x81,0x03,0x81,0x02,0x81,0x08,0x81,0x04,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x04,0x81,0x07,0x81,0x03,0x81,0x01,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x01,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x03,0x81,0x09,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x03,0x81,0x01,0x81,0x03,0x82,0x01,0x82,0x03,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x07,0x81,0x06,0x81,0x06,0x81,0x17,0x81,0x0b,0x81,0x02,0x81,0x03,0x81,0x01,0x81,0x01,0x81,0x04,0x81,0x02,0x81,0x01,0x82,0x02,0x81,0x0c,0x81,0x05,0x81,0x0d,0x81,0x06,0x81,0x0d,0x81,0x05,0x81,0x06,0x81,0x02,0x81,0x04,0x81,0x05,0x81,0x05,0x81,0x04,0x81,0x05,0x81,0x02,0x81,0x03,0x82,0x02,0x81,0x02,0x82,0x03,0x81,0x04,0x81,0x04,0x81,0x01,0x81,0x03,0x81,0x04,0x81,0x06,0x81,0x09,0x81,0x08,0x81,0x08,0x81,0x04,0x81,0x02,0x83,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x02,0x81,0x03,0x81,0x01,0x81,0x03,0x81,0x02,0x81,0x06,0x81,0x07,0x81,0x03,0x81,0x01,0x81,0x04,0x81,0x03,0x81,0x04,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x06,0x81,0x04,0x81,0x01,0x81,0x03,0x82,0x02,0x81,0x02,0x81,0x02,0x81,0x07,0x81,0x02,0x82,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x03,0x82,0x03,0x81,0x03,0x81,0x03,0x81,0x02,0x81,0x04,0x81,0x04,0x82,0x07,0x81,0x08,0x81,0x04,0x81,0x19,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x82,0x05,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x04,0x81,0x07,0x81,0x03,0x81,0x02,0x81,0x05,0x81,0x04,0x81,0x01,0x81,0x01,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x03,0x81,0x05,0x81,0x03,0x81,0x04,0x81,0x04,0x81,0x03,0x81,0x04,0x81,0x05,0x81,0x01,0x81,0x04,0x81,0x01,0x81,0x04,0x82,0x04,0x81,0x08,0x81,0x06,0x81,0x06,0x81,0x17,0x81,0x0b,0x81,0x01,0x81,0x05,0x83,0x06,0x82,0x03,0x83,0x01,0x81,0x0b,0x81,0x05,0x81,0x0d,0x81,0x06,0x81,0x0d,0x81,0x05,0x81,0x06,0x84,0x02,0x85,0x02,0x86,0x02,0x84,0x06,0x81,0x03,0x84,0x03,0x84,0x03,0x81,0x06,0x84,0x03,0x83,0x05,0x81,0x06,0x81,0x1b,0x81,0x04,0x82,0x05,0x81,0x04,0x81,0x01,0x85,0x04,0x83,0x02,0x84,0x03,0x86,0x01,0x81,0x08,0x83,0x02,0x81,0x04,0x81,0x01,0x85,0x03,0x83,0x03,0x81,0x04,0x81,0x01,0x86,0x01,0x81,0x04,0x81,0x01,0x81,0x03,0x82,0x02,0x84,0x02,0x81,0x07,0x84,0x02,0x81,0x05,0x81,0x01,0x84,0x04,0x81,0x05,0x84,0x04,0x82,0x03,0x81,0x03,0x81,0x02,0x81,0x04,0x81,0x03,0x81,0x04,0x86,0x03,0x81,0x08,0x81,0x04,0x81,0x1a,0x84,0x02,0x84,0x04,0x83,0x04,0x84,0x03,0x83,0x05,0x81,0x05,0x84,0x02,0x81,0x03,0x81,0x02,0x85,0x05,0x81,0x03,0x81,0x03,0x81,0x05,0x82,0x02,0x81,0x01,0x81,0x01,0x81,0x02,0x81,0x03,0x81,0x03,0x83,0x03,0x84,0x04,0x84,0x03,0x81,0x06,0x83,0x05,0x83,0x03,0x84,0x04,0x81,0x05,0x81,0x01,0x81,0x03,0x81,0x03,0x81,0x04,0x81,0x04,0x85,0x04,0x81,0x06,0x81,0x06,0x81,0x2c,0x81,0x1c,0x82,0x03,0x82,0x13,0x81,0x13,0x81,0x54,0x81,0x22,0x81,0x79,0x81,0x43,0x82,0x08,0x81,0x02,0x82,0x47,0x81,0x13,0x81,0x26,0x81,0x0a,0x81,0x35,0x81,0x0d,0x83,0x04,0x81,0x04,0x83,0x2c,0x81,0x7f,0x44,0x83,0x76,0x81,0x7f,0x17,0x81,0x02,0x81,0x13,0x81,0x26,0x81,0x0a,0x81,0x34,0x81,0x15,0x81,0x7f,0x7f,0x7f,0x50,0x87,0x34,0x82,0x12,0x82,0x27,0x81,0x0a,0x81,0x33,0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x4b,0x00,0x49,0x48,0x44,0x52,0x00,0x00,0x00,0x00,0x49,0x44,0x41,0x54,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0x00,0x00,0x00,0x00,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x62,0x4b,0x47,0x44,0x00,0x00,0x00,0x00,0x63,0x48,0x52,0x4d,0x00,0x00,0x00,0x00,0x67,0x41,0x4d,0x41,0x00,0x00,0x00,0x00,0x68,0x49,0x53,0x54,0x00,0x00,0x00,0x00,0x69,0x43,0x43,0x50,0x00,0x00,0x00,0x00,0x69,0x54,0x58,0x74,0x00,0x00,0x00,0x00,0x6f,0x46,0x46,0x73,0x00,0x00,0x00,0x00,0x70,0x43,0x41,0x4c,0x00,0x00,0x00,0x00,0x73,0x43,0x41,0x4c,0x00,0x00,0x00,0x00,0x70,0x48,0x59,0x73,0x00,0x00,0x00,0x00,0x73,0x42,0x49,0x54,0x00,0x00,0x00,0x00,0x73,0x50,0x4c,0x54,0x00,0x00,0x00,0x00,0x73,0x52,0x47,0x42,0x00,0x00,0x00,0x00,0x74,0x45,0x58,0x74,0x00,0x00,0x00,0x00,0x74,0x49,0x4d,0x45,0x00,0x00,0x00,0x00,0x74,0x52,0x4e,0x53,0x00,0x00,0x00,0x00,0x7a,0x54,0x58,0x74,0x00, - } -}; diff --git a/minui21/graphics.c b/minui21/graphics.c deleted file mode 100644 index 580af297..00000000 --- a/minui21/graphics.c +++ /dev/null @@ -1,522 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#ifdef BOARD_USE_CUSTOM_RECOVERY_FONT -#include BOARD_USE_CUSTOM_RECOVERY_FONT -#else -#include "font_10x18.h" -#endif - -#include "minui.h" - -#if defined(RECOVERY_BGRA) -#define PIXEL_FORMAT GGL_PIXEL_FORMAT_BGRA_8888 -#define PIXEL_SIZE 4 -#elif defined(RECOVERY_RGBA) -#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGBA_8888 -#define PIXEL_SIZE 4 -#elif defined(RECOVERY_RGBX) -#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGBX_8888 -#define PIXEL_SIZE 4 -#else -#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGB_565 -#define PIXEL_SIZE 2 -#endif - -#define NUM_BUFFERS 2 - -typedef struct { - GGLSurface* texture; - unsigned cwidth; - unsigned cheight; -} GRFont; - -static GRFont *gr_font = 0; -static GGLContext *gr_context = 0; -static GGLSurface gr_font_texture; -static GGLSurface gr_framebuffer[NUM_BUFFERS]; -static GGLSurface gr_mem_surface; -static unsigned gr_active_fb = 0; -static unsigned double_buffering = 0; -static int overscan_percent = OVERSCAN_PERCENT; -static int overscan_offset_x = 0; -static int overscan_offset_y = 0; - -static int gr_fb_fd = -1; -static int gr_vt_fd = -1; - -static struct fb_var_screeninfo vi; -static struct fb_fix_screeninfo fi; - -static bool has_overlay = false; - -bool target_has_overlay(char *version); -int free_ion_mem(void); -int alloc_ion_mem(unsigned int size); -int allocate_overlay(int fd, GGLSurface gr_fb[]); -int free_overlay(int fd); -int overlay_display_frame(int fd, GGLubyte* data, size_t size); - -static int get_framebuffer(GGLSurface *fb) -{ - int fd; - void *bits; - - fd = open("/dev/graphics/fb0", O_RDWR); - if (fd < 0) { - perror("cannot open fb0"); - return -1; - } - - if (ioctl(fd, FBIOGET_VSCREENINFO, &vi) < 0) { - perror("failed to get fb0 info"); - close(fd); - return -1; - } - - vi.bits_per_pixel = PIXEL_SIZE * 8; - if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_BGRA_8888) { - vi.red.offset = 8; - vi.red.length = 8; - vi.green.offset = 16; - vi.green.length = 8; - vi.blue.offset = 24; - vi.blue.length = 8; - vi.transp.offset = 0; - vi.transp.length = 8; - } else if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_RGBA_8888) { - vi.red.offset = 0; - vi.red.length = 8; - vi.green.offset = 8; - vi.green.length = 8; - vi.blue.offset = 16; - vi.blue.length = 8; - vi.transp.offset = 24; - vi.transp.length = 8; - } else if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_RGBX_8888) { - vi.red.offset = 24; - vi.red.length = 8; - vi.green.offset = 16; - vi.green.length = 8; - vi.blue.offset = 8; - vi.blue.length = 8; - vi.transp.offset = 0; - vi.transp.length = 8; - } else { /* RGB565*/ - vi.red.offset = 11; - vi.red.length = 5; - vi.green.offset = 5; - vi.green.length = 6; - vi.blue.offset = 0; - vi.blue.length = 5; - vi.transp.offset = 0; - vi.transp.length = 0; - } - if (ioctl(fd, FBIOPUT_VSCREENINFO, &vi) < 0) { - perror("failed to put fb0 info"); - close(fd); - return -1; - } - - if (ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) { - perror("failed to get fb0 info"); - close(fd); - return -1; - } - - has_overlay = target_has_overlay(fi.id); - - if (!has_overlay) { - bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (bits == MAP_FAILED) { - perror("failed to mmap framebuffer"); - close(fd); - return -1; - } - } - - overscan_offset_x = vi.xres * overscan_percent / 100; - overscan_offset_y = vi.yres * overscan_percent / 100; - - fb->version = sizeof(*fb); - fb->width = vi.xres; - fb->height = vi.yres; - fb->stride = fi.line_length/PIXEL_SIZE; - fb->format = PIXEL_FORMAT; - if (!has_overlay) { - fb->data = bits; - memset(fb->data, 0, vi.yres * fi.line_length); - } - - fb++; - - /* check if we can use double buffering */ - if (vi.yres * fi.line_length * 2 > fi.smem_len) - return fd; - - double_buffering = 1; - - fb->version = sizeof(*fb); - fb->width = vi.xres; - fb->height = vi.yres; - fb->stride = fi.line_length/PIXEL_SIZE; - fb->format = PIXEL_FORMAT; - if (!has_overlay) { - fb->data = (void*) (((unsigned long) bits) + vi.yres * fi.line_length); - memset(fb->data, 0, vi.yres * fi.line_length); - } - - return fd; -} - -static void get_memory_surface(GGLSurface* ms) { - ms->version = sizeof(*ms); - ms->width = vi.xres; - ms->height = vi.yres; - ms->stride = fi.line_length/PIXEL_SIZE; - ms->data = malloc(fi.line_length * vi.yres); - ms->format = PIXEL_FORMAT; -} - -static void set_active_framebuffer(unsigned n) -{ - if (n > 1 || !double_buffering) return; - vi.yres_virtual = vi.yres * NUM_BUFFERS; - vi.yoffset = n * vi.yres; - vi.bits_per_pixel = PIXEL_SIZE * 8; - if (ioctl(gr_fb_fd, FBIOPUT_VSCREENINFO, &vi) < 0) { - perror("active fb swap failed"); - } -} - -void gr_flip(void) -{ - if (-EINVAL == overlay_display_frame(gr_fb_fd, gr_mem_surface.data, - (fi.line_length * vi.yres))) { - GGLContext *gl = gr_context; - - /* swap front and back buffers */ - if (double_buffering) - gr_active_fb = (gr_active_fb + 1) & 1; - - /* copy data from the in-memory surface to the buffer we're about - * to make active. */ - memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data, - fi.line_length * vi.yres); - - /* inform the display driver */ - set_active_framebuffer(gr_active_fb); - } -} - -void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) -{ - GGLContext *gl = gr_context; - GGLint color[4]; - color[0] = ((r << 8) | r) + 1; - color[1] = ((g << 8) | g) + 1; - color[2] = ((b << 8) | b) + 1; - color[3] = ((a << 8) | a) + 1; - gl->color4xv(gl, color); -} - -int gr_measure(const char *s) -{ - return gr_font->cwidth * strlen(s); -} - -void gr_font_size(int *x, int *y) -{ - *x = gr_font->cwidth; - *y = gr_font->cheight; -} - -int gr_text(int x, int y, const char *s, ...) -{ - return gr_text_impl(x, y, s, 0); -} - -int gr_text_impl(int x, int y, const char *s, int bold) -{ - GGLContext *gl = gr_context; - GRFont *font = gr_font; - unsigned off; - - if (!font->texture) return x; - - bold = bold && (font->texture->height != font->cheight); - - x += overscan_offset_x; - y += overscan_offset_y; - - gl->bindTexture(gl, font->texture); - gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); - gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); - gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); - gl->enable(gl, GGL_TEXTURE_2D); - - while((off = *s++)) { - off -= 32; - if (off < 96) { - gl->texCoord2i(gl, (off * font->cwidth) - x, - (bold ? font->cheight : 0) - y); - gl->recti(gl, x, y, x + font->cwidth, y + font->cheight); - } - x += font->cwidth; - } - - return x; -} - -void gr_texticon(int x, int y, gr_surface icon) { - if (gr_context == NULL || icon == NULL) { - return; - } - GGLContext* gl = gr_context; - - x += overscan_offset_x; - y += overscan_offset_y; - - gl->bindTexture(gl, (GGLSurface*) icon); - gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); - gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); - gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); - gl->enable(gl, GGL_TEXTURE_2D); - - int w = gr_get_width(icon); - int h = gr_get_height(icon); - - gl->texCoord2i(gl, -x, -y); - gl->recti(gl, x, y, x+gr_get_width(icon), y+gr_get_height(icon)); -} - -void gr_fill(int x1, int y1, int x2, int y2) -{ - x1 += overscan_offset_x; - y1 += overscan_offset_y; - - x2 += overscan_offset_x; - y2 += overscan_offset_y; - - GGLContext *gl = gr_context; - gl->disable(gl, GGL_TEXTURE_2D); - gl->recti(gl, x1, y1, x2, y2); -} - -void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) { - if (gr_context == NULL || source == NULL) { - return; - } - GGLContext *gl = gr_context; - - dx += overscan_offset_x; - dy += overscan_offset_y; - - gl->bindTexture(gl, (GGLSurface*) source); - gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); - gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); - gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE); - gl->enable(gl, GGL_TEXTURE_2D); - gl->texCoord2i(gl, sx - dx, sy - dy); - gl->recti(gl, dx, dy, dx + w, dy + h); -} - -unsigned int gr_get_width(gr_surface surface) { - if (surface == NULL) { - return 0; - } - return ((GGLSurface*) surface)->width; -} - -unsigned int gr_get_height(gr_surface surface) { - if (surface == NULL) { - return 0; - } - return ((GGLSurface*) surface)->height; -} - -static void gr_init_font(void) -{ - gr_font = calloc(sizeof(*gr_font), 1); - - int res = res_create_surface("font", (void**)&(gr_font->texture)); - if (res == 0) { - // The font image should be a 96x2 array of character images. The - // columns are the printable ASCII characters 0x20 - 0x7f. The - // top row is regular text; the bottom row is bold. - gr_font->cwidth = gr_font->texture->width / 96; - gr_font->cheight = gr_font->texture->height / 2; - } else { - printf("failed to read font: res=%d\n", res); - - // fall back to the compiled-in font. - gr_font->texture = malloc(sizeof(*gr_font->texture)); - gr_font->texture->width = font.width; - gr_font->texture->height = font.height; - gr_font->texture->stride = font.width; - - unsigned char* bits = malloc(font.width * font.height); - gr_font->texture->data = (void*) bits; - - unsigned char data; - unsigned char* in = font.rundata; - while((data = *in++)) { - memset(bits, (data & 0x80) ? 255 : 0, data & 0x7f); - bits += (data & 0x7f); - } - - gr_font->cwidth = font.cwidth; - gr_font->cheight = font.cheight; - } - - // interpret the grayscale as alpha - gr_font->texture->format = GGL_PIXEL_FORMAT_A_8; -} - -int gr_init(void) -{ - gglInit(&gr_context); - GGLContext *gl = gr_context; - - gr_init_font(); - gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC); - if (gr_vt_fd < 0) { - // This is non-fatal; post-Cupcake kernels don't have tty0. - perror("can't open /dev/tty0"); - } else if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) { - // However, if we do open tty0, we expect the ioctl to work. - perror("failed KDSETMODE to KD_GRAPHICS on tty0"); - gr_exit(); - return -1; - } - - gr_fb_fd = get_framebuffer(gr_framebuffer); - if (gr_fb_fd < 0) { - gr_exit(); - return -1; - } - - get_memory_surface(&gr_mem_surface); - - fprintf(stderr, "framebuffer: fd %d (%d x %d)\n", - gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height); - - /* start with 0 as front (displayed) and 1 as back (drawing) */ - gr_active_fb = 0; - if (!has_overlay) - set_active_framebuffer(0); - gl->colorBuffer(gl, &gr_mem_surface); - - gl->activeTexture(gl, 0); - gl->enable(gl, GGL_BLEND); - gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA); - - gr_fb_blank(true); - gr_fb_blank(false); - - if (!alloc_ion_mem(fi.line_length * vi.yres)) - allocate_overlay(gr_fb_fd, gr_framebuffer); - - return 0; -} - -void gr_exit(void) -{ - free_overlay(gr_fb_fd); - free_ion_mem(); - - close(gr_fb_fd); - gr_fb_fd = -1; - - free(gr_mem_surface.data); - - ioctl(gr_vt_fd, KDSETMODE, (void*) KD_TEXT); - close(gr_vt_fd); - gr_vt_fd = -1; -} - -int gr_fb_width(void) -{ - return gr_framebuffer[0].width - 2*overscan_offset_x; -} - -int gr_fb_height(void) -{ - return gr_framebuffer[0].height - 2*overscan_offset_y; -} - -gr_pixel *gr_fb_data(void) -{ - return (unsigned short *) gr_mem_surface.data; -} - -void gr_fb_blank(bool blank) -{ -#if defined(TW_NO_SCREEN_BLANK) && defined(TW_BRIGHTNESS_PATH) && defined(TW_MAX_BRIGHTNESS) - int fd; - char brightness[4]; - snprintf(brightness, 4, "%03d", TW_MAX_BRIGHTNESS/2); - - fd = open(TW_BRIGHTNESS_PATH, O_RDWR); - if (fd < 0) { - perror("cannot open LCD backlight"); - return; - } - write(fd, blank ? "000" : brightness, 3); - close(fd); -#else - int ret; - if (blank) - free_overlay(gr_fb_fd); - - ret = ioctl(gr_fb_fd, FBIOBLANK, blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK); - if (ret < 0) - perror("ioctl(): blank"); - - if (!blank) - allocate_overlay(gr_fb_fd, gr_framebuffer); -#endif -} - -void gr_get_memory_surface(gr_surface surface) -{ - get_memory_surface( (GGLSurface*) surface); -} - -// These are new graphics functions from 5.0 that were not available in -// 4.4 that are required by charger and healthd -void gr_clear() -{ - return; -} - diff --git a/minui21/graphics_overlay.c b/minui21/graphics_overlay.c deleted file mode 100644 index c42e9c18..00000000 --- a/minui21/graphics_overlay.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#ifdef MSM_BSP -#include -#include -#endif - -#include - -#include "minui.h" - -#define MDP_V4_0 400 - -#ifdef MSM_BSP -#define ALIGN(x, align) (((x) + ((align)-1)) & ~((align)-1)) - -typedef struct { - unsigned char *mem_buf; - int size; - int ion_fd; - int mem_fd; - struct ion_handle_data handle_data; -} memInfo; - -static int overlay_id = MSMFB_NEW_REQUEST; -static memInfo mem_info; - -static int map_mdp_pixel_format() -{ - int format = MDP_RGB_565; -#if defined(RECOVERY_BGRA) - format = MDP_BGRA_8888; -#elif defined(RECOVERY_RGBA) - format = MDP_RGBA_8888; -#elif defined(RECOVERY_RGBX) - format = MDP_RGBA_8888; -#endif - return format; -} - -static bool overlay_supported = false; - -bool target_has_overlay(char *version) -{ - int ret; - int mdp_version; - - if (strlen(version) >= 8) { - if(!strncmp(version, "msmfb", strlen("msmfb"))) { - char str_ver[4]; - memcpy(str_ver, version + strlen("msmfb"), 3); - str_ver[3] = '\0'; - mdp_version = atoi(str_ver); - if (mdp_version >= MDP_V4_0) { - overlay_supported = true; - } - } else if (!strncmp(version, "mdssfb", strlen("mdssfb"))) { - overlay_supported = true; - } - } - - return overlay_supported; -} - -int free_ion_mem(void) { - if (!overlay_supported) - return -EINVAL; - - int ret = 0; - - if (mem_info.mem_buf) - munmap(mem_info.mem_buf, mem_info.size); - - if (mem_info.ion_fd >= 0) { - ret = ioctl(mem_info.ion_fd, ION_IOC_FREE, &mem_info.handle_data); - if (ret < 0) - perror("free_mem failed "); - } - - if (mem_info.mem_fd >= 0) - close(mem_info.mem_fd); - if (mem_info.ion_fd >= 0) - close(mem_info.ion_fd); - - memset(&mem_info, 0, sizeof(mem_info)); - mem_info.mem_fd = -1; - mem_info.ion_fd = -1; - return 0; -} - -int alloc_ion_mem(unsigned int size) -{ - if (!overlay_supported) - return -EINVAL; - int result; - struct ion_fd_data fd_data; - struct ion_allocation_data ionAllocData; - - mem_info.ion_fd = open("/dev/ion", O_RDWR|O_DSYNC); - if (mem_info.ion_fd < 0) { - perror("ERROR: Can't open ion "); - return -errno; - } - - ionAllocData.flags = 0; - ionAllocData.len = size; - ionAllocData.align = sysconf(_SC_PAGESIZE); -#ifdef NEW_ION_HEAP - ionAllocData.heap_id_mask = -#else - ionAllocData.heap_mask = -#endif - ION_HEAP(ION_IOMMU_HEAP_ID) | - ION_HEAP(ION_SYSTEM_CONTIG_HEAP_ID); - - result = ioctl(mem_info.ion_fd, ION_IOC_ALLOC, &ionAllocData); - if(result){ - perror("ION_IOC_ALLOC Failed "); - close(mem_info.ion_fd); - return result; - } - - fd_data.handle = ionAllocData.handle; - mem_info.handle_data.handle = ionAllocData.handle; - result = ioctl(mem_info.ion_fd, ION_IOC_MAP, &fd_data); - if (result) { - perror("ION_IOC_MAP Failed "); - free_ion_mem(); - return result; - } - mem_info.mem_buf = (unsigned char *)mmap(NULL, size, PROT_READ | - PROT_WRITE, MAP_SHARED, fd_data.fd, 0); - mem_info.mem_fd = fd_data.fd; - - if (!mem_info.mem_buf) { - perror("ERROR: mem_buf MAP_FAILED "); - free_ion_mem(); - return -ENOMEM; - } - - return 0; -} - -int allocate_overlay(int fd, GGLSurface gr_fb[]) -{ - if (!overlay_supported) - return -EINVAL; - - struct mdp_overlay overlay; - int ret = 0; - - memset(&overlay, 0 , sizeof (struct mdp_overlay)); - - /* Fill Overlay Data */ - - overlay.src.width = ALIGN(gr_fb[0].width, 32); - overlay.src.height = gr_fb[0].height; - overlay.src.format = map_mdp_pixel_format(); - overlay.src_rect.w = gr_fb[0].width; - overlay.src_rect.h = gr_fb[0].height; - overlay.dst_rect.w = gr_fb[0].width; - overlay.dst_rect.h = gr_fb[0].height; - overlay.alpha = 0xFF; - overlay.transp_mask = MDP_TRANSP_NOP; - overlay.id = MSMFB_NEW_REQUEST; - ret = ioctl(fd, MSMFB_OVERLAY_SET, &overlay); - if (ret < 0) { - perror("Overlay Set Failed"); - return ret; - } - - overlay_id = overlay.id; - return 0; -} - -int free_overlay(int fd) -{ - if (!overlay_supported) - return -EINVAL; - - int ret = 0; - struct mdp_display_commit ext_commit; - - if (overlay_id != MSMFB_NEW_REQUEST) { - ret = ioctl(fd, MSMFB_OVERLAY_UNSET, &overlay_id); - if (ret) { - perror("Overlay Unset Failed"); - overlay_id = MSMFB_NEW_REQUEST; - return ret; - } - - memset(&ext_commit, 0, sizeof(struct mdp_display_commit)); - ext_commit.flags = MDP_DISPLAY_COMMIT_OVERLAY; - ext_commit.wait_for_finish = 1; - ret = ioctl(fd, MSMFB_DISPLAY_COMMIT, &ext_commit); - if (ret < 0) { - perror("ERROR: Clear MSMFB_DISPLAY_COMMIT failed!"); - overlay_id = MSMFB_NEW_REQUEST; - return ret; - } - - overlay_id = MSMFB_NEW_REQUEST; - } - return 0; -} - -int overlay_display_frame(int fd, GGLubyte* data, size_t size) -{ - if (!overlay_supported) - return -EINVAL; - int ret = 0; - struct msmfb_overlay_data ovdata; - struct mdp_display_commit ext_commit; - - if (overlay_id == MSMFB_NEW_REQUEST) { - perror("display_frame failed, no overlay\n"); - return 0; - } - - memcpy(mem_info.mem_buf, data, size); - - memset(&ovdata, 0, sizeof(struct msmfb_overlay_data)); - - ovdata.id = overlay_id; - ovdata.data.flags = 0; - ovdata.data.offset = 0; - ovdata.data.memory_id = mem_info.mem_fd; - ret = ioctl(fd, MSMFB_OVERLAY_PLAY, &ovdata); - if (ret < 0) { - perror("overlay_display_frame failed, overlay play Failed\n"); - return 0; - } - - memset(&ext_commit, 0, sizeof(struct mdp_display_commit)); - ext_commit.flags = MDP_DISPLAY_COMMIT_OVERLAY; - ext_commit.wait_for_finish = 1; - ret = ioctl(fd, MSMFB_DISPLAY_COMMIT, &ext_commit); - if (ret < 0) { - perror("overlay_display_frame failed, overlay commit Failed\n!"); - return 0; - } - - return 0; -} - -#else - -bool target_has_overlay(char *version) { - return false; -} - -int free_ion_mem(void) { - return -EINVAL; -} - -int alloc_ion_mem(unsigned int size) -{ - return -EINVAL; -} - -int allocate_overlay(int fd, GGLSurface gr_fb[]) -{ - return -EINVAL; -} - -int free_overlay(int fd) -{ - return -EINVAL; -} - -int overlay_display_frame(int fd, GGLubyte* data, size_t size) -{ - return -EINVAL; -} - -#endif //#ifdef MSM_BSP diff --git a/minui21/include/linux/msm_ion.h b/minui21/include/linux/msm_ion.h deleted file mode 100644 index 121a5a7a..00000000 --- a/minui21/include/linux/msm_ion.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef _LINUX_MSM_ION_H -#define _LINUX_MSM_ION_H - -#include - -/*enum msm_ion_heap_types { - ION_HEAP_TYPE_MSM_START = ION_HEAP_TYPE_CUSTOM + 1, - ION_HEAP_TYPE_IOMMU = ION_HEAP_TYPE_MSM_START, - ION_HEAP_TYPE_DMA, - ION_HEAP_TYPE_CP, - ION_HEAP_TYPE_SECURE_DMA, - ION_HEAP_TYPE_REMOVED, -};*/ - -/** - * These are the only ids that should be used for Ion heap ids. - * The ids listed are the order in which allocation will be attempted - * if specified. Don't swap the order of heap ids unless you know what - * you are doing! - * Id's are spaced by purpose to allow new Id's to be inserted in-between (for - * possible fallbacks) - */ - -enum ion_heap_ids { - INVALID_HEAP_ID = -1, - ION_CP_MM_HEAP_ID = 8, - ION_CP_MFC_HEAP_ID = 12, - ION_CP_WB_HEAP_ID = 16, /* 8660 only */ - ION_CAMERA_HEAP_ID = 20, /* 8660 only */ - ION_SYSTEM_CONTIG_HEAP_ID = 21, - ION_ADSP_HEAP_ID = 22, - ION_PIL1_HEAP_ID = 23, /* Currently used for other PIL images */ - ION_SF_HEAP_ID = 24, - ION_IOMMU_HEAP_ID = 25, - ION_PIL2_HEAP_ID = 26, /* Currently used for modem firmware images */ - ION_QSECOM_HEAP_ID = 27, - ION_AUDIO_HEAP_ID = 28, - - ION_MM_FIRMWARE_HEAP_ID = 29, - ION_SYSTEM_HEAP_ID = 30, - - ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ -}; - -/*enum ion_fixed_position { - NOT_FIXED, - FIXED_LOW, - FIXED_MIDDLE, - FIXED_HIGH, -};*/ - -/*enum cp_mem_usage { - VIDEO_BITSTREAM = 0x1, - VIDEO_PIXEL = 0x2, - VIDEO_NONPIXEL = 0x3, - MAX_USAGE = 0x4, - UNKNOWN = 0x7FFFFFFF, -};*/ - -#define ION_HEAP_CP_MASK (1 << ION_HEAP_TYPE_CP) -#define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) - -/** - * Flag to use when allocating to indicate that a heap is secure. - */ -#define ION_FLAG_SECURE (1 << ION_HEAP_ID_RESERVED) - -/** - * Flag for clients to force contiguous memort allocation - * - * Use of this flag is carefully monitored! - */ -#define ION_FLAG_FORCE_CONTIGUOUS (1 << 30) - -/* - * Used in conjunction with heap which pool memory to force an allocation - * to come from the page allocator directly instead of from the pool allocation - */ -#define ION_FLAG_POOL_FORCE_ALLOC (1 << 16) - -/** -* Deprecated! Please use the corresponding ION_FLAG_* -*/ -#define ION_SECURE ION_FLAG_SECURE -#define ION_FORCE_CONTIGUOUS ION_FLAG_FORCE_CONTIGUOUS - -/** - * Macro should be used with ion_heap_ids defined above. - */ -#define ION_HEAP(bit) (1 << (bit)) - -#define ION_ADSP_HEAP_NAME "adsp" -#define ION_VMALLOC_HEAP_NAME "vmalloc" -#define ION_KMALLOC_HEAP_NAME "kmalloc" -#define ION_AUDIO_HEAP_NAME "audio" -#define ION_SF_HEAP_NAME "sf" -#define ION_MM_HEAP_NAME "mm" -#define ION_CAMERA_HEAP_NAME "camera_preview" -#define ION_IOMMU_HEAP_NAME "iommu" -#define ION_MFC_HEAP_NAME "mfc" -#define ION_WB_HEAP_NAME "wb" -#define ION_MM_FIRMWARE_HEAP_NAME "mm_fw" -#define ION_PIL1_HEAP_NAME "pil_1" -#define ION_PIL2_HEAP_NAME "pil_2" -#define ION_QSECOM_HEAP_NAME "qsecom" - -#define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED) -#define ION_SET_UNCACHED(__cache) (__cache & ~ION_FLAG_CACHED) - -#define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED) - - -/* struct ion_flush_data - data passed to ion for flushing caches - * - * @handle: handle with data to flush - * @fd: fd to flush - * @vaddr: userspace virtual address mapped with mmap - * @offset: offset into the handle to flush - * @length: length of handle to flush - * - * Performs cache operations on the handle. If p is the start address - * of the handle, p + offset through p + offset + length will have - * the cache operations performed - */ -struct ion_flush_data { - struct ion_handle *handle; - int fd; - void *vaddr; - unsigned int offset; - unsigned int length; -}; - -#define ION_IOC_MSM_MAGIC 'M' - -/** - * DOC: ION_IOC_CLEAN_CACHES - clean the caches - * - * Clean the caches of the handle specified. - */ -#define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \ - struct ion_flush_data) -/** - * DOC: ION_IOC_INV_CACHES - invalidate the caches - * - * Invalidate the caches of the handle specified. - */ -#define ION_IOC_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 1, \ - struct ion_flush_data) -/** - * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches - * - * Clean and invalidate the caches of the handle specified. - */ -#define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \ - struct ion_flush_data) - -#endif diff --git a/minui21/include/linux/msm_mdp.h b/minui21/include/linux/msm_mdp.h deleted file mode 100644 index abdcd29e..00000000 --- a/minui21/include/linux/msm_mdp.h +++ /dev/null @@ -1,992 +0,0 @@ -/* include/linux/msm_mdp.h - * - * Copyright (C) 2007 Google Incorporated - * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#ifndef _MSM_MDP_H_ -#define _MSM_MDP_H_ - -#include -#include - -#define MSMFB_IOCTL_MAGIC 'm' -#define MSMFB_GRP_DISP _IOW(MSMFB_IOCTL_MAGIC, 1, unsigned int) -#define MSMFB_BLIT _IOW(MSMFB_IOCTL_MAGIC, 2, unsigned int) -#define MSMFB_SUSPEND_SW_REFRESHER _IOW(MSMFB_IOCTL_MAGIC, 128, unsigned int) -#define MSMFB_RESUME_SW_REFRESHER _IOW(MSMFB_IOCTL_MAGIC, 129, unsigned int) -#define MSMFB_CURSOR _IOW(MSMFB_IOCTL_MAGIC, 130, struct fb_cursor) -#define MSMFB_SET_LUT _IOW(MSMFB_IOCTL_MAGIC, 131, struct fb_cmap) -#define MSMFB_HISTOGRAM _IOWR(MSMFB_IOCTL_MAGIC, 132, struct mdp_histogram_data) -/* new ioctls's for set/get ccs matrix */ -#define MSMFB_GET_CCS_MATRIX _IOWR(MSMFB_IOCTL_MAGIC, 133, struct mdp_ccs) -#define MSMFB_SET_CCS_MATRIX _IOW(MSMFB_IOCTL_MAGIC, 134, struct mdp_ccs) -#define MSMFB_OVERLAY_SET _IOWR(MSMFB_IOCTL_MAGIC, 135, \ - struct mdp_overlay) -#define MSMFB_OVERLAY_UNSET _IOW(MSMFB_IOCTL_MAGIC, 136, unsigned int) - -#define MSMFB_OVERLAY_PLAY _IOW(MSMFB_IOCTL_MAGIC, 137, \ - struct msmfb_overlay_data) -#define MSMFB_OVERLAY_QUEUE MSMFB_OVERLAY_PLAY - -#define MSMFB_GET_PAGE_PROTECTION _IOR(MSMFB_IOCTL_MAGIC, 138, \ - struct mdp_page_protection) -#define MSMFB_SET_PAGE_PROTECTION _IOW(MSMFB_IOCTL_MAGIC, 139, \ - struct mdp_page_protection) -#define MSMFB_OVERLAY_GET _IOR(MSMFB_IOCTL_MAGIC, 140, \ - struct mdp_overlay) -#define MSMFB_OVERLAY_PLAY_ENABLE _IOW(MSMFB_IOCTL_MAGIC, 141, unsigned int) -#define MSMFB_OVERLAY_BLT _IOWR(MSMFB_IOCTL_MAGIC, 142, \ - struct msmfb_overlay_blt) -#define MSMFB_OVERLAY_BLT_OFFSET _IOW(MSMFB_IOCTL_MAGIC, 143, unsigned int) -#define MSMFB_HISTOGRAM_START _IOR(MSMFB_IOCTL_MAGIC, 144, \ - struct mdp_histogram_start_req) -#define MSMFB_HISTOGRAM_STOP _IOR(MSMFB_IOCTL_MAGIC, 145, unsigned int) -#define MSMFB_NOTIFY_UPDATE _IOWR(MSMFB_IOCTL_MAGIC, 146, unsigned int) - -#define MSMFB_OVERLAY_3D _IOWR(MSMFB_IOCTL_MAGIC, 147, \ - struct msmfb_overlay_3d) - -#define MSMFB_MIXER_INFO _IOWR(MSMFB_IOCTL_MAGIC, 148, \ - struct msmfb_mixer_info_req) -#define MSMFB_OVERLAY_PLAY_WAIT _IOWR(MSMFB_IOCTL_MAGIC, 149, \ - struct msmfb_overlay_data) -#define MSMFB_WRITEBACK_INIT _IO(MSMFB_IOCTL_MAGIC, 150) -#define MSMFB_WRITEBACK_START _IO(MSMFB_IOCTL_MAGIC, 151) -#define MSMFB_WRITEBACK_STOP _IO(MSMFB_IOCTL_MAGIC, 152) -#define MSMFB_WRITEBACK_QUEUE_BUFFER _IOW(MSMFB_IOCTL_MAGIC, 153, \ - struct msmfb_data) -#define MSMFB_WRITEBACK_DEQUEUE_BUFFER _IOW(MSMFB_IOCTL_MAGIC, 154, \ - struct msmfb_data) -#define MSMFB_WRITEBACK_TERMINATE _IO(MSMFB_IOCTL_MAGIC, 155) -#define MSMFB_MDP_PP _IOWR(MSMFB_IOCTL_MAGIC, 156, struct msmfb_mdp_pp) -#define MSMFB_OVERLAY_VSYNC_CTRL _IOW(MSMFB_IOCTL_MAGIC, 160, unsigned int) -#define MSMFB_VSYNC_CTRL _IOW(MSMFB_IOCTL_MAGIC, 161, unsigned int) -#define MSMFB_BUFFER_SYNC _IOW(MSMFB_IOCTL_MAGIC, 162, struct mdp_buf_sync) -#define MSMFB_OVERLAY_COMMIT _IO(MSMFB_IOCTL_MAGIC, 163) -#define MSMFB_DISPLAY_COMMIT _IOW(MSMFB_IOCTL_MAGIC, 164, \ - struct mdp_display_commit) -#define MSMFB_METADATA_SET _IOW(MSMFB_IOCTL_MAGIC, 165, struct msmfb_metadata) -#define MSMFB_METADATA_GET _IOW(MSMFB_IOCTL_MAGIC, 166, struct msmfb_metadata) -#define MSMFB_WRITEBACK_SET_MIRRORING_HINT _IOW(MSMFB_IOCTL_MAGIC, 167, \ - unsigned int) -#define MSMFB_ASYNC_BLIT _IOW(MSMFB_IOCTL_MAGIC, 168, unsigned int) - -#define FB_TYPE_3D_PANEL 0x10101010 -#define MDP_IMGTYPE2_START 0x10000 -#define MSMFB_DRIVER_VERSION 0xF9E8D701 - -enum { - NOTIFY_UPDATE_START, - NOTIFY_UPDATE_STOP, - NOTIFY_UPDATE_POWER_OFF, -}; - -enum { - NOTIFY_TYPE_NO_UPDATE, - NOTIFY_TYPE_SUSPEND, - NOTIFY_TYPE_UPDATE, -}; - -enum { - MDP_RGB_565, /* RGB 565 planer */ - MDP_XRGB_8888, /* RGB 888 padded */ - MDP_Y_CBCR_H2V2, /* Y and CbCr, pseudo planer w/ Cb is in MSB */ - MDP_Y_CBCR_H2V2_ADRENO, - MDP_ARGB_8888, /* ARGB 888 */ - MDP_RGB_888, /* RGB 888 planer */ - MDP_Y_CRCB_H2V2, /* Y and CrCb, pseudo planer w/ Cr is in MSB */ - MDP_YCRYCB_H2V1, /* YCrYCb interleave */ - MDP_CBYCRY_H2V1, /* CbYCrY interleave */ - MDP_Y_CRCB_H2V1, /* Y and CrCb, pseduo planer w/ Cr is in MSB */ - MDP_Y_CBCR_H2V1, /* Y and CrCb, pseduo planer w/ Cr is in MSB */ - MDP_Y_CRCB_H1V2, - MDP_Y_CBCR_H1V2, - MDP_RGBA_8888, /* ARGB 888 */ - MDP_BGRA_8888, /* ABGR 888 */ - MDP_RGBX_8888, /* RGBX 888 */ - MDP_Y_CRCB_H2V2_TILE, /* Y and CrCb, pseudo planer tile */ - MDP_Y_CBCR_H2V2_TILE, /* Y and CbCr, pseudo planer tile */ - MDP_Y_CR_CB_H2V2, /* Y, Cr and Cb, planar */ - MDP_Y_CR_CB_GH2V2, /* Y, Cr and Cb, planar aligned to Android YV12 */ - MDP_Y_CB_CR_H2V2, /* Y, Cb and Cr, planar */ - MDP_Y_CRCB_H1V1, /* Y and CrCb, pseduo planer w/ Cr is in MSB */ - MDP_Y_CBCR_H1V1, /* Y and CbCr, pseduo planer w/ Cb is in MSB */ - MDP_YCRCB_H1V1, /* YCrCb interleave */ - MDP_YCBCR_H1V1, /* YCbCr interleave */ - MDP_BGR_565, /* BGR 565 planer */ - MDP_BGR_888, /* BGR 888 */ - MDP_Y_CBCR_H2V2_VENUS, - MDP_BGRX_8888, /* BGRX 8888 */ - MDP_RGBA_8888_TILE, /* RGBA 8888 in tile format */ - MDP_ARGB_8888_TILE, /* ARGB 8888 in tile format */ - MDP_ABGR_8888_TILE, /* ABGR 8888 in tile format */ - MDP_BGRA_8888_TILE, /* BGRA 8888 in tile format */ - MDP_RGBX_8888_TILE, /* RGBX 8888 in tile format */ - MDP_XRGB_8888_TILE, /* XRGB 8888 in tile format */ - MDP_XBGR_8888_TILE, /* XBGR 8888 in tile format */ - MDP_BGRX_8888_TILE, /* BGRX 8888 in tile format */ - MDP_YCBYCR_H2V1, /* YCbYCr interleave */ - MDP_IMGTYPE_LIMIT, - MDP_RGB_BORDERFILL, /* border fill pipe */ - MDP_FB_FORMAT = MDP_IMGTYPE2_START, /* framebuffer format */ - MDP_IMGTYPE_LIMIT2 /* Non valid image type after this enum */ -}; - -enum { - PMEM_IMG, - FB_IMG, -}; - -enum { - HSIC_HUE = 0, - HSIC_SAT, - HSIC_INT, - HSIC_CON, - NUM_HSIC_PARAM, -}; - -#define MDSS_MDP_ROT_ONLY 0x80 -#define MDSS_MDP_RIGHT_MIXER 0x100 -#define MDSS_MDP_DUAL_PIPE 0x200 - -/* mdp_blit_req flag values */ -#define MDP_ROT_NOP 0 -#define MDP_FLIP_LR 0x1 -#define MDP_FLIP_UD 0x2 -#define MDP_ROT_90 0x4 -#define MDP_ROT_180 (MDP_FLIP_UD|MDP_FLIP_LR) -#define MDP_ROT_270 (MDP_ROT_90|MDP_FLIP_UD|MDP_FLIP_LR) -#define MDP_DITHER 0x8 -#define MDP_BLUR 0x10 -#define MDP_BLEND_FG_PREMULT 0x20000 -#define MDP_IS_FG 0x40000 -#define MDP_SOLID_FILL 0x0000100 -#define MDP_DEINTERLACE 0x80000000 -#define MDP_SHARPENING 0x40000000 -#define MDP_NO_DMA_BARRIER_START 0x20000000 -#define MDP_NO_DMA_BARRIER_END 0x10000000 -#define MDP_NO_BLIT 0x08000000 -#define MDP_BLIT_WITH_DMA_BARRIERS 0x000 -#define MDP_BLIT_WITH_NO_DMA_BARRIERS \ - (MDP_NO_DMA_BARRIER_START | MDP_NO_DMA_BARRIER_END) -#define MDP_BLIT_SRC_GEM 0x04000000 -#define MDP_BLIT_DST_GEM 0x02000000 -#define MDP_BLIT_NON_CACHED 0x01000000 -#define MDP_OV_PIPE_SHARE 0x00800000 -#define MDP_DEINTERLACE_ODD 0x00400000 -#define MDP_OV_PLAY_NOWAIT 0x00200000 -#define MDP_SOURCE_ROTATED_90 0x00100000 -#define MDP_OVERLAY_PP_CFG_EN 0x00080000 -#define MDP_BACKEND_COMPOSITION 0x00040000 -#define MDP_BORDERFILL_SUPPORTED 0x00010000 -#define MDP_SECURE_OVERLAY_SESSION 0x00008000 -#define MDP_SECURE_DISPLAY_OVERLAY_SESSION 0x00002000 -#define MDP_OV_PIPE_FORCE_DMA 0x00004000 -#define MDP_MEMORY_ID_TYPE_FB 0x00001000 -#define MDP_BWC_EN 0x00000400 -#define MDP_DECIMATION_EN 0x00000800 -#define MDP_TRANSP_NOP 0xffffffff -#define MDP_ALPHA_NOP 0xff - -#define MDP_FB_PAGE_PROTECTION_NONCACHED (0) -#define MDP_FB_PAGE_PROTECTION_WRITECOMBINE (1) -#define MDP_FB_PAGE_PROTECTION_WRITETHROUGHCACHE (2) -#define MDP_FB_PAGE_PROTECTION_WRITEBACKCACHE (3) -#define MDP_FB_PAGE_PROTECTION_WRITEBACKWACACHE (4) -/* Sentinel: Don't use! */ -#define MDP_FB_PAGE_PROTECTION_INVALID (5) -/* Count of the number of MDP_FB_PAGE_PROTECTION_... values. */ -#define MDP_NUM_FB_PAGE_PROTECTION_VALUES (5) - -struct mdp_rect { - uint32_t x; - uint32_t y; - uint32_t w; - uint32_t h; -}; - -struct mdp_img { - uint32_t width; - uint32_t height; - uint32_t format; - uint32_t offset; - int memory_id; /* the file descriptor */ - uint32_t priv; -}; - -/* - * {3x3} + {3} ccs matrix - */ - -#define MDP_CCS_RGB2YUV 0 -#define MDP_CCS_YUV2RGB 1 - -#define MDP_CCS_SIZE 9 -#define MDP_BV_SIZE 3 - -struct mdp_ccs { - int direction; /* MDP_CCS_RGB2YUV or YUV2RGB */ - uint16_t ccs[MDP_CCS_SIZE]; /* 3x3 color coefficients */ - uint16_t bv[MDP_BV_SIZE]; /* 1x3 bias vector */ -}; - -struct mdp_csc { - int id; - uint32_t csc_mv[9]; - uint32_t csc_pre_bv[3]; - uint32_t csc_post_bv[3]; - uint32_t csc_pre_lv[6]; - uint32_t csc_post_lv[6]; -}; - -/* The version of the mdp_blit_req structure so that - * user applications can selectively decide which functionality - * to include - */ - -#define MDP_BLIT_REQ_VERSION 2 - -struct color { - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t alpha; -}; - -struct mdp_blit_req { - struct mdp_img src; - struct mdp_img dst; - struct mdp_rect src_rect; - struct mdp_rect dst_rect; - struct color const_color; - uint32_t alpha; - uint32_t transp_mask; - uint32_t flags; - int sharpening_strength; /* -127 <--> 127, default 64 */ -}; - -struct mdp_blit_req_list { - uint32_t count; - struct mdp_blit_req req[]; -}; - -#define MSMFB_DATA_VERSION 2 - -struct msmfb_data { - uint32_t offset; - int memory_id; - int id; - uint32_t flags; - uint32_t priv; - uint32_t iova; -}; - -#define MSMFB_NEW_REQUEST -1 - -struct msmfb_overlay_data { - uint32_t id; - struct msmfb_data data; - uint32_t version_key; - struct msmfb_data plane1_data; - struct msmfb_data plane2_data; - struct msmfb_data dst_data; -}; - -struct msmfb_img { - uint32_t width; - uint32_t height; - uint32_t format; -}; - -#define MSMFB_WRITEBACK_DEQUEUE_BLOCKING 0x1 -struct msmfb_writeback_data { - struct msmfb_data buf_info; - struct msmfb_img img; -}; - -#define MDP_PP_OPS_ENABLE 0x1 -#define MDP_PP_OPS_READ 0x2 -#define MDP_PP_OPS_WRITE 0x4 -#define MDP_PP_OPS_DISABLE 0x8 -#define MDP_PP_IGC_FLAG_ROM0 0x10 -#define MDP_PP_IGC_FLAG_ROM1 0x20 - -#define MDSS_PP_DSPP_CFG 0x000 -#define MDSS_PP_SSPP_CFG 0x100 -#define MDSS_PP_LM_CFG 0x200 -#define MDSS_PP_WB_CFG 0x300 - -#define MDSS_PP_ARG_MASK 0x3C00 -#define MDSS_PP_ARG_NUM 4 -#define MDSS_PP_ARG_SHIFT 10 -#define MDSS_PP_LOCATION_MASK 0x0300 -#define MDSS_PP_LOGICAL_MASK 0x00FF - -#define MDSS_PP_ADD_ARG(var, arg) ((var) | (0x1 << (MDSS_PP_ARG_SHIFT + (arg)))) -#define PP_ARG(x, var) ((var) & (0x1 << (MDSS_PP_ARG_SHIFT + (x)))) -#define PP_LOCAT(var) ((var) & MDSS_PP_LOCATION_MASK) -#define PP_BLOCK(var) ((var) & MDSS_PP_LOGICAL_MASK) - - -struct mdp_qseed_cfg { - uint32_t table_num; - uint32_t ops; - uint32_t len; - uint32_t *data; -}; - -struct mdp_sharp_cfg { - uint32_t flags; - uint32_t strength; - uint32_t edge_thr; - uint32_t smooth_thr; - uint32_t noise_thr; -}; - -struct mdp_qseed_cfg_data { - uint32_t block; - struct mdp_qseed_cfg qseed_data; -}; - -#define MDP_OVERLAY_PP_CSC_CFG 0x1 -#define MDP_OVERLAY_PP_QSEED_CFG 0x2 -#define MDP_OVERLAY_PP_PA_CFG 0x4 -#define MDP_OVERLAY_PP_IGC_CFG 0x8 -#define MDP_OVERLAY_PP_SHARP_CFG 0x10 -#define MDP_OVERLAY_PP_HIST_CFG 0x20 -#define MDP_OVERLAY_PP_HIST_LUT_CFG 0x40 - -#define MDP_CSC_FLAG_ENABLE 0x1 -#define MDP_CSC_FLAG_YUV_IN 0x2 -#define MDP_CSC_FLAG_YUV_OUT 0x4 - -struct mdp_csc_cfg { - /* flags for enable CSC, toggling RGB,YUV input/output */ - uint32_t flags; - uint32_t csc_mv[9]; - uint32_t csc_pre_bv[3]; - uint32_t csc_post_bv[3]; - uint32_t csc_pre_lv[6]; - uint32_t csc_post_lv[6]; -}; - -struct mdp_csc_cfg_data { - uint32_t block; - struct mdp_csc_cfg csc_data; -}; - -struct mdp_pa_cfg { - uint32_t flags; - uint32_t hue_adj; - uint32_t sat_adj; - uint32_t val_adj; - uint32_t cont_adj; -}; - -struct mdp_igc_lut_data { - uint32_t block; - uint32_t len, ops; - uint32_t *c0_c1_data; - uint32_t *c2_data; -}; - -struct mdp_histogram_cfg { - uint32_t ops; - uint32_t block; - uint8_t frame_cnt; - uint8_t bit_mask; - uint16_t num_bins; -}; - -struct mdp_hist_lut_data { - uint32_t block; - uint32_t ops; - uint32_t len; - uint32_t *data; -}; - -struct mdp_overlay_pp_params { - uint32_t config_ops; - struct mdp_csc_cfg csc_cfg; - struct mdp_qseed_cfg qseed_cfg[2]; - struct mdp_pa_cfg pa_cfg; - struct mdp_igc_lut_data igc_cfg; - struct mdp_sharp_cfg sharp_cfg; - struct mdp_histogram_cfg hist_cfg; - struct mdp_hist_lut_data hist_lut_cfg; -}; - -/** - * enum mdss_mdp_blend_op - Different blend operations set by userspace - * - * @BLEND_OP_NOT_DEFINED: No blend operation defined for the layer. - * @BLEND_OP_OPAQUE: Apply a constant blend operation. The layer - * would appear opaque in case fg plane alpha is - * 0xff. - * @BLEND_OP_PREMULTIPLIED: Apply source over blend rule. Layer already has - * alpha pre-multiplication done. If fg plane alpha - * is less than 0xff, apply modulation as well. This - * operation is intended on layers having alpha - * channel. - * @BLEND_OP_COVERAGE: Apply source over blend rule. Layer is not alpha - * pre-multiplied. Apply pre-multiplication. If fg - * plane alpha is less than 0xff, apply modulation as - * well. - * @BLEND_OP_MAX: Used to track maximum blend operation possible by - * mdp. - */ -enum mdss_mdp_blend_op { - BLEND_OP_NOT_DEFINED = 0, - BLEND_OP_OPAQUE, - BLEND_OP_PREMULTIPLIED, - BLEND_OP_COVERAGE, - BLEND_OP_MAX, -}; - -#define MAX_PLANES 4 -struct mdp_scale_data { - uint8_t enable_pxl_ext; - - int init_phase_x[MAX_PLANES]; - int phase_step_x[MAX_PLANES]; - int init_phase_y[MAX_PLANES]; - int phase_step_y[MAX_PLANES]; - - int num_ext_pxls_left[MAX_PLANES]; - int num_ext_pxls_right[MAX_PLANES]; - int num_ext_pxls_top[MAX_PLANES]; - int num_ext_pxls_btm[MAX_PLANES]; - - int left_ftch[MAX_PLANES]; - int left_rpt[MAX_PLANES]; - int right_ftch[MAX_PLANES]; - int right_rpt[MAX_PLANES]; - - int top_rpt[MAX_PLANES]; - int btm_rpt[MAX_PLANES]; - int top_ftch[MAX_PLANES]; - int btm_ftch[MAX_PLANES]; - - uint32_t roi_w[MAX_PLANES]; -}; - -/** - * struct mdp_overlay - overlay surface structure - * @src: Source image information (width, height, format). - * @src_rect: Source crop rectangle, portion of image that will be fetched. - * This should always be within boundaries of source image. - * @dst_rect: Destination rectangle, the position and size of image on screen. - * This should always be within panel boundaries. - * @z_order: Blending stage to occupy in display, if multiple layers are - * present, highest z_order usually means the top most visible - * layer. The range acceptable is from 0-3 to support blending - * up to 4 layers. - * @is_fg: This flag is used to disable blending of any layers with z_order - * less than this overlay. It means that any layers with z_order - * less than this layer will not be blended and will be replaced - * by the background border color. - * @alpha: Used to set plane opacity. The range can be from 0-255, where - * 0 means completely transparent and 255 means fully opaque. - * @transp_mask: Color used as color key for transparency. Any pixel in fetched - * image matching this color will be transparent when blending. - * The color should be in same format as the source image format. - * @flags: This is used to customize operation of overlay. See MDP flags - * for more information. - * @user_data: DEPRECATED* Used to store user application specific information. - * @bg_color: Solid color used to fill the overlay surface when no source - * buffer is provided. - * @horz_deci: Horizontal decimation value, this indicates the amount of pixels - * dropped for each pixel that is fetched from a line. The value - * given should be power of two of decimation amount. - * 0: no decimation - * 1: decimate by 2 (drop 1 pixel for each pixel fetched) - * 2: decimate by 4 (drop 3 pixels for each pixel fetched) - * 3: decimate by 8 (drop 7 pixels for each pixel fetched) - * 4: decimate by 16 (drop 15 pixels for each pixel fetched) - * @vert_deci: Vertical decimation value, this indicates the amount of lines - * dropped for each line that is fetched from overlay. The value - * given should be power of two of decimation amount. - * 0: no decimation - * 1: decimation by 2 (drop 1 line for each line fetched) - * 2: decimation by 4 (drop 3 lines for each line fetched) - * 3: decimation by 8 (drop 7 lines for each line fetched) - * 4: decimation by 16 (drop 15 lines for each line fetched) - * @overlay_pp_cfg: Overlay post processing configuration, for more information - * see struct mdp_overlay_pp_params. - */ -struct mdp_overlay { - struct msmfb_img src; - struct mdp_rect src_rect; - struct mdp_rect dst_rect; - uint32_t z_order; /* stage number */ - uint32_t is_fg; /* control alpha & transp */ - uint32_t alpha; - uint32_t blend_op; - uint32_t transp_mask; - uint32_t flags; - uint32_t id; - uint32_t user_data[6]; - uint32_t bg_color; - uint8_t horz_deci; - uint8_t vert_deci; - struct mdp_overlay_pp_params overlay_pp_cfg; - struct mdp_scale_data scale; -}; - -struct msmfb_overlay_3d { - uint32_t is_3d; - uint32_t width; - uint32_t height; -}; - - -struct msmfb_overlay_blt { - uint32_t enable; - uint32_t offset; - uint32_t width; - uint32_t height; - uint32_t bpp; -}; - -struct mdp_histogram { - uint32_t frame_cnt; - uint32_t bin_cnt; - uint32_t *r; - uint32_t *g; - uint32_t *b; -}; - -enum { - DISPLAY_MISR_EDP, - DISPLAY_MISR_DSI0, - DISPLAY_MISR_DSI1, - DISPLAY_MISR_HDMI, - DISPLAY_MISR_LCDC, - DISPLAY_MISR_ATV, - DISPLAY_MISR_DSI_CMD, - DISPLAY_MISR_MAX -}; - -enum { - MISR_OP_NONE, - MISR_OP_SFM, - MISR_OP_MFM, - MISR_OP_BM, - MISR_OP_MAX -}; - -struct mdp_misr { - uint32_t block_id; - uint32_t frame_count; - uint32_t crc_op_mode; - uint32_t crc_value[32]; -}; - -/* - - mdp_block_type defines the identifiers for pipes in MDP 4.3 and up - - MDP_BLOCK_RESERVED is provided for backward compatibility and is - deprecated. It corresponds to DMA_P. So MDP_BLOCK_DMA_P should be used - instead. - - MDP_LOGICAL_BLOCK_DISP_0 identifies the display pipe which fb0 uses, - same for others. - -*/ - -enum { - MDP_BLOCK_RESERVED = 0, - MDP_BLOCK_OVERLAY_0, - MDP_BLOCK_OVERLAY_1, - MDP_BLOCK_VG_1, - MDP_BLOCK_VG_2, - MDP_BLOCK_RGB_1, - MDP_BLOCK_RGB_2, - MDP_BLOCK_DMA_P, - MDP_BLOCK_DMA_S, - MDP_BLOCK_DMA_E, - MDP_BLOCK_OVERLAY_2, - MDP_LOGICAL_BLOCK_DISP_0 = 0x10, - MDP_LOGICAL_BLOCK_DISP_1, - MDP_LOGICAL_BLOCK_DISP_2, - MDP_BLOCK_MAX, -}; - -/* - * mdp_histogram_start_req is used to provide the parameters for - * histogram start request - */ - -struct mdp_histogram_start_req { - uint32_t block; - uint8_t frame_cnt; - uint8_t bit_mask; - uint16_t num_bins; -}; - -/* - * mdp_histogram_data is used to return the histogram data, once - * the histogram is done/stopped/cance - */ - -struct mdp_histogram_data { - uint32_t block; - uint32_t bin_cnt; - uint32_t *c0; - uint32_t *c1; - uint32_t *c2; - uint32_t *extra_info; -}; - -struct mdp_pcc_coeff { - uint32_t c, r, g, b, rr, gg, bb, rg, gb, rb, rgb_0, rgb_1; -}; - -struct mdp_pcc_cfg_data { - uint32_t block; - uint32_t ops; - struct mdp_pcc_coeff r, g, b; -}; - -#define MDP_GAMUT_TABLE_NUM 8 - -enum { - mdp_lut_igc, - mdp_lut_pgc, - mdp_lut_hist, - mdp_lut_max, -}; - -struct mdp_ar_gc_lut_data { - uint32_t x_start; - uint32_t slope; - uint32_t offset; -}; - -struct mdp_pgc_lut_data { - uint32_t block; - uint32_t flags; - uint8_t num_r_stages; - uint8_t num_g_stages; - uint8_t num_b_stages; - struct mdp_ar_gc_lut_data *r_data; - struct mdp_ar_gc_lut_data *g_data; - struct mdp_ar_gc_lut_data *b_data; -}; - - -struct mdp_lut_cfg_data { - uint32_t lut_type; - union { - struct mdp_igc_lut_data igc_lut_data; - struct mdp_pgc_lut_data pgc_lut_data; - struct mdp_hist_lut_data hist_lut_data; - } data; -}; - -struct mdp_bl_scale_data { - uint32_t min_lvl; - uint32_t scale; -}; - -struct mdp_pa_cfg_data { - uint32_t block; - struct mdp_pa_cfg pa_data; -}; - -struct mdp_dither_cfg_data { - uint32_t block; - uint32_t flags; - uint32_t g_y_depth; - uint32_t r_cr_depth; - uint32_t b_cb_depth; -}; - -struct mdp_gamut_cfg_data { - uint32_t block; - uint32_t flags; - uint32_t gamut_first; - uint32_t tbl_size[MDP_GAMUT_TABLE_NUM]; - uint16_t *r_tbl[MDP_GAMUT_TABLE_NUM]; - uint16_t *g_tbl[MDP_GAMUT_TABLE_NUM]; - uint16_t *b_tbl[MDP_GAMUT_TABLE_NUM]; -}; - -struct mdp_calib_config_data { - uint32_t ops; - uint32_t addr; - uint32_t data; -}; - -struct mdp_calib_config_buffer { - uint32_t ops; - uint32_t size; - uint32_t *buffer; -}; - -struct mdp_calib_dcm_state { - uint32_t ops; - uint32_t dcm_state; -}; - -enum { - DCM_UNINIT, - DCM_UNBLANK, - DCM_ENTER, - DCM_EXIT, - DCM_BLANK, -}; - -#define MDSS_MAX_BL_BRIGHTNESS 255 -#define AD_BL_LIN_LEN (MDSS_MAX_BL_BRIGHTNESS + 1) - -#define MDSS_AD_MODE_AUTO_BL 0x0 -#define MDSS_AD_MODE_AUTO_STR 0x1 -#define MDSS_AD_MODE_TARG_STR 0x3 -#define MDSS_AD_MODE_MAN_STR 0x7 -#define MDSS_AD_MODE_CALIB 0xF - -#define MDP_PP_AD_INIT 0x10 -#define MDP_PP_AD_CFG 0x20 - -struct mdss_ad_init { - uint32_t asym_lut[33]; - uint32_t color_corr_lut[33]; - uint8_t i_control[2]; - uint16_t black_lvl; - uint16_t white_lvl; - uint8_t var; - uint8_t limit_ampl; - uint8_t i_dither; - uint8_t slope_max; - uint8_t slope_min; - uint8_t dither_ctl; - uint8_t format; - uint8_t auto_size; - uint16_t frame_w; - uint16_t frame_h; - uint8_t logo_v; - uint8_t logo_h; - uint32_t bl_lin_len; - uint32_t *bl_lin; - uint32_t *bl_lin_inv; -}; - -#define MDSS_AD_BL_CTRL_MODE_EN 1 -#define MDSS_AD_BL_CTRL_MODE_DIS 0 -struct mdss_ad_cfg { - uint32_t mode; - uint32_t al_calib_lut[33]; - uint16_t backlight_min; - uint16_t backlight_max; - uint16_t backlight_scale; - uint16_t amb_light_min; - uint16_t filter[2]; - uint16_t calib[4]; - uint8_t strength_limit; - uint8_t t_filter_recursion; - uint16_t stab_itr; - uint32_t bl_ctrl_mode; -}; - -/* ops uses standard MDP_PP_* flags */ -struct mdss_ad_init_cfg { - uint32_t ops; - union { - struct mdss_ad_init init; - struct mdss_ad_cfg cfg; - } params; -}; - -/* mode uses MDSS_AD_MODE_* flags */ -struct mdss_ad_input { - uint32_t mode; - union { - uint32_t amb_light; - uint32_t strength; - uint32_t calib_bl; - } in; - uint32_t output; -}; - -#define MDSS_CALIB_MODE_BL 0x1 -struct mdss_calib_cfg { - uint32_t ops; - uint32_t calib_mask; -}; - -enum { - mdp_op_pcc_cfg, - mdp_op_csc_cfg, - mdp_op_lut_cfg, - mdp_op_qseed_cfg, - mdp_bl_scale_cfg, - mdp_op_pa_cfg, - mdp_op_dither_cfg, - mdp_op_gamut_cfg, - mdp_op_calib_cfg, - mdp_op_ad_cfg, - mdp_op_ad_input, - mdp_op_calib_mode, - mdp_op_calib_buffer, - mdp_op_calib_dcm_state, - mdp_op_max, -}; - -enum { - WB_FORMAT_NV12, - WB_FORMAT_RGB_565, - WB_FORMAT_RGB_888, - WB_FORMAT_xRGB_8888, - WB_FORMAT_ARGB_8888, - WB_FORMAT_BGRA_8888, - WB_FORMAT_BGRX_8888, - WB_FORMAT_ARGB_8888_INPUT_ALPHA /* Need to support */ -}; - -struct msmfb_mdp_pp { - uint32_t op; - union { - struct mdp_pcc_cfg_data pcc_cfg_data; - struct mdp_csc_cfg_data csc_cfg_data; - struct mdp_lut_cfg_data lut_cfg_data; - struct mdp_qseed_cfg_data qseed_cfg_data; - struct mdp_bl_scale_data bl_scale_data; - struct mdp_pa_cfg_data pa_cfg_data; - struct mdp_dither_cfg_data dither_cfg_data; - struct mdp_gamut_cfg_data gamut_cfg_data; - struct mdp_calib_config_data calib_cfg; - struct mdss_ad_init_cfg ad_init_cfg; - struct mdss_calib_cfg mdss_calib_cfg; - struct mdss_ad_input ad_input; - struct mdp_calib_config_buffer calib_buffer; - struct mdp_calib_dcm_state calib_dcm; - } data; -}; - -#define FB_METADATA_VIDEO_INFO_CODE_SUPPORT 1 -enum { - metadata_op_none, - metadata_op_base_blend, - metadata_op_frame_rate, - metadata_op_vic, - metadata_op_wb_format, - metadata_op_get_caps, - metadata_op_crc, - metadata_op_max -}; - -struct mdp_blend_cfg { - uint32_t is_premultiplied; -}; - -struct mdp_mixer_cfg { - uint32_t writeback_format; - uint32_t alpha; -}; - -struct mdss_hw_caps { - uint32_t mdp_rev; - uint8_t rgb_pipes; - uint8_t vig_pipes; - uint8_t dma_pipes; - uint32_t features; -}; - -struct msmfb_metadata { - uint32_t op; - uint32_t flags; - union { - struct mdp_misr misr_request; - struct mdp_blend_cfg blend_cfg; - struct mdp_mixer_cfg mixer_cfg; - uint32_t panel_frame_rate; - uint32_t video_info_code; - struct mdss_hw_caps caps; - } data; -}; - -#define MDP_MAX_FENCE_FD 32 -#define MDP_BUF_SYNC_FLAG_WAIT 1 - -struct mdp_buf_sync { - uint32_t flags; - uint32_t acq_fen_fd_cnt; - uint32_t session_id; - int *acq_fen_fd; - int *rel_fen_fd; -}; - -struct mdp_async_blit_req_list { - struct mdp_buf_sync sync; - uint32_t count; - struct mdp_blit_req req[]; -}; - -#define MDP_DISPLAY_COMMIT_OVERLAY 1 -struct mdp_buf_fence { - uint32_t flags; - uint32_t acq_fen_fd_cnt; - int acq_fen_fd[MDP_MAX_FENCE_FD]; - int rel_fen_fd[MDP_MAX_FENCE_FD]; -}; - - -struct mdp_display_commit { - uint32_t flags; - uint32_t wait_for_finish; - struct fb_var_screeninfo var; - struct mdp_buf_fence buf_fence; - struct mdp_rect roi; -}; - -struct mdp_page_protection { - uint32_t page_protection; -}; - - -struct mdp_mixer_info { - int pndx; - int pnum; - int ptype; - int mixer_num; - int z_order; -}; - -#define MAX_PIPE_PER_MIXER 4 - -struct msmfb_mixer_info_req { - int mixer_num; - int cnt; - struct mdp_mixer_info info[MAX_PIPE_PER_MIXER]; -}; - -enum { - DISPLAY_SUBSYSTEM_ID, - ROTATOR_SUBSYSTEM_ID, -}; - -enum { - MDP_IOMMU_DOMAIN_CP, - MDP_IOMMU_DOMAIN_NS, -}; - -enum { - MDP_WRITEBACK_MIRROR_OFF, - MDP_WRITEBACK_MIRROR_ON, - MDP_WRITEBACK_MIRROR_PAUSE, - MDP_WRITEBACK_MIRROR_RESUME, -}; - - -#endif /*_MSM_MDP_H_*/ diff --git a/minui21/minui.h b/minui21/minui.h deleted file mode 100644 index 4c629c1b..00000000 --- a/minui21/minui.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _MINUI_H_ -#define _MINUI_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* gr_surface; -typedef unsigned short gr_pixel; - -int gr_init(void); -void gr_exit(void); - -int gr_fb_width(void); -int gr_fb_height(void); -gr_pixel *gr_fb_data(void); -void gr_flip(void); -void gr_fb_blank(bool blank); - -void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void gr_fill(int x1, int y1, int x2, int y2); - -// system/core/charger uses different gr_print signatures in diferent -// Android versions, either with or without int bold. -int gr_text(int x, int y, const char *s, ...); -int gr_text_impl(int x, int y, const char *s, int bold); - - void gr_texticon(int x, int y, gr_surface icon); -int gr_measure(const char *s); -void gr_font_size(int *x, int *y); -void gr_get_memory_surface(gr_surface); - -void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); -unsigned int gr_get_width(gr_surface surface); -unsigned int gr_get_height(gr_surface surface); - -// input event structure, include for the definition. -// see http://www.mjmwired.net/kernel/Documentation/input/ for info. -struct input_event; - -typedef int (*ev_callback)(int fd, uint32_t epevents, void *data); -typedef int (*ev_set_key_callback)(int code, int value, void *data); - -int ev_init(ev_callback input_cb, void *data); -void ev_exit(void); -int ev_add_fd(int fd, ev_callback cb, void *data); -int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data); - -/* timeout has the same semantics as for poll - * 0 : don't block - * < 0 : block forever - * > 0 : block for 'timeout' milliseconds - */ -int ev_wait(int timeout); - -int ev_get_input(int fd, uint32_t epevents, struct input_event *ev); -void ev_dispatch(void); -int ev_get_epollfd(void); - -// Resources - -// Returns 0 if no error, else negative. -int res_create_surface(const char* name, gr_surface* pSurface); - -// Load an array of display surfaces from a single PNG image. The PNG -// should have a 'Frames' text chunk whose value is the number of -// frames this image represents. The pixel data itself is interlaced -// by row. -int res_create_multi_display_surface(const char* name, - int* frames, gr_surface** pSurface); - -int res_create_localized_surface(const char* name, gr_surface* pSurface); -void res_free_surface(gr_surface surface); -static inline int res_create_display_surface(const char* name, gr_surface* pSurface) { - return res_create_surface(name, pSurface); -} - -// These are new graphics functions from 5.0 that were not available in -// 4.4 that are required by charger and healthd -void gr_clear(); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/minui21/mkfont.c b/minui21/mkfont.c deleted file mode 100644 index 61a5edeb..00000000 --- a/minui21/mkfont.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include - -int main(int argc, char *argv) -{ - unsigned n; - unsigned char *x; - unsigned m; - unsigned run_val; - unsigned run_count; - - n = gimp_image.width * gimp_image.height; - m = 0; - x = gimp_image.pixel_data; - - printf("struct {\n"); - printf(" unsigned width;\n"); - printf(" unsigned height;\n"); - printf(" unsigned cwidth;\n"); - printf(" unsigned cheight;\n"); - printf(" unsigned char rundata[];\n"); - printf("} font = {\n"); - printf(" .width = %d,\n .height = %d,\n .cwidth = %d,\n .cheight = %d,\n", gimp_image.width, gimp_image.height, - gimp_image.width / 96, gimp_image.height); - printf(" .rundata = {\n"); - - run_val = (*x ? 0 : 255); - run_count = 1; - n--; - x+=3; - - while(n-- > 0) { - unsigned val = (*x ? 0 : 255); - x+=3; - if((val == run_val) && (run_count < 127)) { - run_count++; - } else { -eject: - printf("0x%02x,",run_count | (run_val ? 0x80 : 0x00)); - run_val = val; - run_count = 1; - m += 5; - if(m >= 75) { - printf("\n"); - m = 0; - } - } - } - printf("0x%02x,",run_count | (run_val ? 0x80 : 0x00)); - printf("\n0x00,"); - printf("\n"); - printf(" }\n};\n"); - return 0; -} diff --git a/minui21/resources.c b/minui21/resources.c deleted file mode 100644 index ed25e45a..00000000 --- a/minui21/resources.c +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#include "minui.h" - -#ifdef FASTMMI_FEATURE -char *locale = NULL; -#else -extern char* locale; -#endif - -// libpng gives "undefined reference to 'pow'" errors, and I have no -// idea how to convince the build system to link with -lm. We don't -// need this functionality (it's used for gamma adjustment) so provide -// a dummy implementation to satisfy the linker. -double pow(double x, double y) { - return x * y; -} - -#define SURFACE_DATA_ALIGNMENT 8 - -static GGLSurface* malloc_surface(size_t data_size) { - unsigned char* temp = malloc(sizeof(GGLSurface) + data_size + SURFACE_DATA_ALIGNMENT); - if (temp == NULL) return NULL; - GGLSurface* surface = (GGLSurface*) temp; - surface->data = temp + sizeof(GGLSurface) + - (SURFACE_DATA_ALIGNMENT - (sizeof(GGLSurface) % SURFACE_DATA_ALIGNMENT)); - return surface; -} - -static int open_png(const char* name, png_structp* png_ptr, png_infop* info_ptr, - png_uint_32* width, png_uint_32* height, png_byte* channels) { - char resPath[256]; - unsigned char header[8]; - int result = 0; - - snprintf(resPath, sizeof(resPath)-1, "/res/images/%s.png", name); - resPath[sizeof(resPath)-1] = '\0'; - FILE* fp = fopen(resPath, "rb"); - if (fp == NULL) { - result = -1; - goto exit; - } - - size_t bytesRead = fread(header, 1, sizeof(header), fp); - if (bytesRead != sizeof(header)) { - result = -2; - goto exit; - } - - if (png_sig_cmp(header, 0, sizeof(header))) { - result = -3; - goto exit; - } - - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!*png_ptr) { - result = -4; - goto exit; - } - - *info_ptr = png_create_info_struct(*png_ptr); - if (!*info_ptr) { - result = -5; - goto exit; - } - - if (setjmp(png_jmpbuf(*png_ptr))) { - result = -6; - goto exit; - } - - png_init_io(*png_ptr, fp); - png_set_sig_bytes(*png_ptr, sizeof(header)); - png_read_info(*png_ptr, *info_ptr); - - int color_type, bit_depth; - png_get_IHDR(*png_ptr, *info_ptr, width, height, &bit_depth, - &color_type, NULL, NULL, NULL); - - *channels = png_get_channels(*png_ptr, *info_ptr); - - if (bit_depth == 8 && *channels == 3 && color_type == PNG_COLOR_TYPE_RGB) { - // 8-bit RGB images: great, nothing to do. - } else if (bit_depth <= 8 && *channels == 1 && color_type == PNG_COLOR_TYPE_GRAY) { - // 1-, 2-, 4-, or 8-bit gray images: expand to 8-bit gray. - png_set_expand_gray_1_2_4_to_8(*png_ptr); - } else if (bit_depth <= 8 && *channels == 1 && color_type == PNG_COLOR_TYPE_PALETTE) { - // paletted images: expand to 8-bit RGB. Note that we DON'T - // currently expand the tRNS chunk (if any) to an alpha - // channel, because minui doesn't support alpha channels in - // general. - png_set_palette_to_rgb(*png_ptr); - *channels = 3; - } else { - fprintf(stderr, "minui doesn't support PNG depth %d channels %d color_type %d\n", - bit_depth, *channels, color_type); - result = -7; - goto exit; - } - - return result; - - exit: - if (result < 0) { - png_destroy_read_struct(png_ptr, info_ptr, NULL); - } - if (fp != NULL) { - fclose(fp); - } - - return result; -} - -// "display" surfaces are transformed into the framebuffer's required -// pixel format (currently only RGBX is supported) at load time, so -// gr_blit() can be nothing more than a memcpy() for each row. The -// next two functions are the only ones that know anything about the -// framebuffer pixel format; they need to be modified if the -// framebuffer format changes (but nothing else should). - -// Allocate and return a gr_surface sufficient for storing an image of -// the indicated size in the framebuffer pixel format. -static GGLSurface* init_display_surface(png_uint_32 width, png_uint_32 height) { - GGLSurface* surface; - - surface = (GGLSurface*) malloc_surface(width * height * 4); - if (surface == NULL) return NULL; - - surface->version = sizeof(GGLSurface); - surface->width = width; - surface->height = height; - surface->stride = width; - - return surface; -} - -// Copy 'input_row' to 'output_row', transforming it to the -// framebuffer pixel format. The input format depends on the value of -// 'channels': -// -// 1 - input is 8-bit grayscale -// 3 - input is 24-bit RGB -// 4 - input is 32-bit RGBA/RGBX -// -// 'width' is the number of pixels in the row. -static void transform_rgb_to_draw(unsigned char* input_row, - unsigned char* output_row, - int channels, int width) { - int x; - unsigned char* ip = input_row; - unsigned char* op = output_row; - - switch (channels) { - case 1: - // expand gray level to RGBX - for (x = 0; x < width; ++x) { - *op++ = *ip; - *op++ = *ip; - *op++ = *ip; - *op++ = 0xff; - ip++; - } - break; - - case 3: - // expand RGBA to RGBX - for (x = 0; x < width; ++x) { - *op++ = *ip++; - *op++ = *ip++; - *op++ = *ip++; - *op++ = 0xff; - } - break; - - case 4: - // copy RGBA to RGBX - memcpy(output_row, input_row, width*4); - break; - } -} - -int res_create_surface(const char* name, gr_surface* pSurface) { - GGLSurface* surface = NULL; - int result = 0; - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - png_uint_32 width, height; - png_byte channels; - - *pSurface = NULL; - - result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels); - if (result < 0) return result; - - surface = init_display_surface(width, height); - if (surface == NULL) { - result = -8; - goto exit; - } - - unsigned char* p_row = malloc(width * 4); - unsigned int y; - for (y = 0; y < height; ++y) { - png_read_row(png_ptr, p_row, NULL); - transform_rgb_to_draw(p_row, surface->data + y * width * 4, channels, width); - } - free(p_row); - - if (channels == 3) - surface->format = GGL_PIXEL_FORMAT_RGBX_8888; - else - surface->format = GGL_PIXEL_FORMAT_RGBA_8888; - - *pSurface = (gr_surface) surface; - - exit: - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - if (result < 0 && surface != NULL) free(surface); - return result; -} - -int res_create_multi_display_surface(const char* name, int* frames, gr_surface** pSurface) { - gr_surface* surface = NULL; - int result = 0; - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - png_uint_32 width, height; - png_byte channels; - int i; - - *pSurface = NULL; - *frames = -1; - - result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels); - if (result < 0) return result; - - *frames = 1; - png_textp text; - int num_text; - if (png_get_text(png_ptr, info_ptr, &text, &num_text)) { - for (i = 0; i < num_text; ++i) { - if (text[i].key && strcmp(text[i].key, "Frames") == 0 && text[i].text) { - *frames = atoi(text[i].text); - break; - } - } - printf(" found frames = %d\n", *frames); - } - - if (height % *frames != 0) { - printf("bad height (%d) for frame count (%d)\n", height, *frames); - result = -9; - goto exit; - } - - surface = malloc(*frames * sizeof(GGLSurface)); - if (surface == NULL) { - result = -8; - goto exit; - } - for (i = 0; i < *frames; ++i) { - surface[i] = init_display_surface(width, height / *frames); - if (surface[i] == NULL) { - result = -8; - goto exit; - } - } - - unsigned char* p_row = malloc(width * 4); - unsigned int y; - for (y = 0; y < height; ++y) { - png_read_row(png_ptr, p_row, NULL); - int frame = y % *frames; - GGLSurface* p = (GGLSurface*) surface[frame]; - unsigned char* out_row = p->data + - (y / *frames) * width * 4; - transform_rgb_to_draw(p_row, out_row, channels, width); - } - free(p_row); - - for (i = 0; i < *frames; ++i) { - GGLSurface* p = (GGLSurface*) surface[i]; - if (channels == 3) - p->format = GGL_PIXEL_FORMAT_RGBX_8888; - else - p->format = GGL_PIXEL_FORMAT_RGBA_8888; - } - - *pSurface = (gr_surface*) surface; - -exit: - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - if (result < 0) { - if (surface) { - for (i = 0; i < *frames; ++i) { - if (surface[i]) free(surface[i]); - } - free(surface); - } - } - return result; -} - -static int matches_locale(const char* loc) { - if (locale == NULL) return 0; - - if (strcmp(loc, locale) == 0) return 1; - - // if loc does *not* have an underscore, and it matches the start - // of locale, and the next character in locale *is* an underscore, - // that's a match. For instance, loc == "en" matches locale == - // "en_US". - - int i; - for (i = 0; loc[i] != 0 && loc[i] != '_'; ++i); - if (loc[i] == '_') return 0; - - return (strncmp(locale, loc, i) == 0 && locale[i] == '_'); -} - -int res_create_localized_surface(const char* name, gr_surface* pSurface) { - char resPath[256]; - GGLSurface* surface = NULL; - int result = 0; - unsigned char header[8]; - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - - *pSurface = NULL; - - snprintf(resPath, sizeof(resPath)-1, "/res/images/%s.png", name); - resPath[sizeof(resPath)-1] = '\0'; - FILE* fp = fopen(resPath, "rb"); - if (fp == NULL) { - result = -1; - goto exit; - } - - size_t bytesRead = fread(header, 1, sizeof(header), fp); - if (bytesRead != sizeof(header)) { - result = -2; - goto exit; - } - - if (png_sig_cmp(header, 0, sizeof(header))) { - result = -3; - goto exit; - } - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) { - result = -4; - goto exit; - } - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - result = -5; - goto exit; - } - - if (setjmp(png_jmpbuf(png_ptr))) { - result = -6; - goto exit; - } - - png_init_io(png_ptr, fp); - png_set_sig_bytes(png_ptr, sizeof(header)); - png_read_info(png_ptr, info_ptr); - - int color_type, bit_depth; - size_t width, height; - - png_get_IHDR(png_ptr, info_ptr, width, height, &bit_depth, - &color_type, NULL, NULL, NULL); - - png_byte* channels = png_get_channels(png_ptr, info_ptr); - size_t stride = 4 * width; - - if (!(bit_depth == 8 && - (channels == 1 && color_type == PNG_COLOR_TYPE_GRAY))) { - return -7; - goto exit; - } - - unsigned char* row = malloc(width); - int y; - for (y = 0; y < height; ++y) { - png_read_row(png_ptr, row, NULL); - int w = (row[1] << 8) | row[0]; - int h = (row[3] << 8) | row[2]; - int len = row[4]; - char* loc = row+5; - - if (y+1+h >= height || matches_locale(loc)) { - printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y); - - surface = malloc(sizeof(GGLSurface)); - if (surface == NULL) { - result = -8; - goto exit; - } - unsigned char* pData = malloc(w*h); - - surface->version = sizeof(GGLSurface); - surface->width = w; - surface->height = h; - surface->stride = w; /* Yes, pixels, not bytes */ - surface->data = pData; - surface->format = GGL_PIXEL_FORMAT_A_8; - - int i; - for (i = 0; i < h; ++i, ++y) { - png_read_row(png_ptr, row, NULL); - memcpy(pData + i*w, row, w); - } - - *pSurface = (gr_surface) surface; - break; - } else { - int i; - for (i = 0; i < h; ++i, ++y) { - png_read_row(png_ptr, row, NULL); - } - } - } - -exit: - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - if (fp != NULL) { - fclose(fp); - } - if (result < 0) { - if (surface) { - free(surface); - } - } - return result; -} - -void res_free_surface(gr_surface surface) { - GGLSurface* pSurface = (GGLSurface*) surface; - if (pSurface) { - free(pSurface); - } -} diff --git a/minui21/roboto_10x18.h b/minui21/roboto_10x18.h deleted file mode 100644 index 3119c81c..00000000 --- a/minui21/roboto_10x18.h +++ /dev/null @@ -1,197 +0,0 @@ -struct { - unsigned width; - unsigned height; - unsigned cwidth; - unsigned cheight; - unsigned char rundata[]; -} font = { - .width = 960, - .height = 18, - .cwidth = 10, - .cheight = 18, - .rundata = { -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x3b,0x81,0x29,0x81,0x06,0x81,0x3f,0x81,0x7f,0x7f,0x7f,0x37,0x83,0x05,0x81, -0x0a,0x83,0x7f,0x7f,0x2f,0x81,0x0e,0x81,0x29,0x82,0x07,0x81,0x01,0x82,0x07, -0x81,0x02,0x81,0x05,0x83,0x05,0x82,0x0a,0x82,0x09,0x82,0x09,0x81,0x08,0x81, -0x3e,0x81,0x05,0x84,0x06,0x84,0x06,0x83,0x06,0x84,0x09,0x82,0x05,0x85,0x06, -0x84,0x04,0x87,0x04,0x84,0x07,0x84,0x39,0x83,0x06,0x84,0x07,0x81,0x06,0x86, -0x06,0x84,0x04,0x86,0x04,0x87,0x04,0x87,0x04,0x84,0x04,0x82,0x04,0x82,0x03, -0x86,0x08,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x07,0x82,0x05,0x82,0x02,0x82, -0x05,0x81,0x04,0x84,0x04,0x86,0x06,0x84,0x04,0x86,0x06,0x84,0x04,0x88,0x02, -0x82,0x05,0x81,0x01,0x82,0x06,0x81,0x01,0x81,0x07,0x81,0x02,0x81,0x05,0x82, -0x02,0x82,0x04,0x82,0x02,0x87,0x06,0x81,0x07,0x82,0x0b,0x81,0x08,0x81,0x12, -0x82,0x10,0x82,0x18,0x82,0x10,0x83,0x0d,0x82,0x0b,0x82,0x08,0x82,0x06,0x82, -0x09,0x83,0x4c,0x82,0x48,0x81,0x07,0x82,0x07,0x81,0x28,0x82,0x07,0x81,0x01, -0x82,0x07,0x81,0x02,0x81,0x04,0x82,0x01,0x82,0x03,0x81,0x02,0x81,0x08,0x81, -0x02,0x81,0x08,0x82,0x08,0x82,0x08,0x82,0x3c,0x82,0x04,0x82,0x02,0x82,0x04, -0x85,0x05,0x82,0x01,0x82,0x04,0x82,0x02,0x82,0x07,0x83,0x05,0x85,0x05,0x82, -0x02,0x81,0x09,0x82,0x03,0x82,0x02,0x82,0x05,0x82,0x02,0x82,0x37,0x82,0x01, -0x82,0x04,0x81,0x03,0x82,0x06,0x82,0x05,0x82,0x03,0x82,0x04,0x83,0x01,0x82, -0x03,0x82,0x03,0x82,0x03,0x82,0x09,0x82,0x08,0x82,0x02,0x82,0x03,0x82,0x04, -0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x03,0x82,0x03,0x82,0x07,0x82,0x05,0x82, -0x02,0x82,0x05,0x81,0x03,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x02, -0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x05,0x81, -0x02,0x81,0x05,0x82,0x01,0x81,0x07,0x81,0x02,0x82,0x04,0x81,0x03,0x82,0x04, -0x82,0x07,0x82,0x06,0x81,0x08,0x81,0x0b,0x81,0x07,0x82,0x13,0x81,0x10,0x82, -0x18,0x82,0x0f,0x84,0x0d,0x82,0x1d,0x82,0x0a,0x82,0x4c,0x82,0x47,0x82,0x07, -0x82,0x07,0x82,0x27,0x82,0x07,0x81,0x01,0x82,0x06,0x81,0x02,0x81,0x04,0x82, -0x03,0x82,0x02,0x81,0x02,0x81,0x02,0x81,0x04,0x82,0x02,0x82,0x08,0x81,0x08, -0x81,0x0a,0x81,0x12,0x82,0x28,0x81,0x05,0x81,0x04,0x81,0x07,0x82,0x04,0x82, -0x03,0x82,0x03,0x81,0x04,0x81,0x07,0x83,0x05,0x81,0x08,0x82,0x0c,0x82,0x04, -0x81,0x04,0x82,0x04,0x81,0x04,0x81,0x36,0x82,0x03,0x81,0x03,0x81,0x05,0x82, -0x04,0x83,0x05,0x82,0x04,0x81,0x03,0x83,0x03,0x82,0x02,0x82,0x04,0x82,0x02, -0x82,0x09,0x82,0x07,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x0a,0x82, -0x03,0x82,0x02,0x82,0x04,0x82,0x07,0x83,0x03,0x83,0x02,0x83,0x04,0x81,0x02, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x81, -0x03,0x82,0x04,0x81,0x06,0x82,0x05,0x82,0x05,0x81,0x02,0x81,0x05,0x82,0x01, -0x82,0x02,0x81,0x02,0x82,0x03,0x82,0x02,0x82,0x04,0x81,0x03,0x82,0x08,0x81, -0x07,0x81,0x08,0x81,0x0b,0x81,0x07,0x83,0x13,0x81,0x0f,0x82,0x18,0x82,0x0e, -0x82,0x10,0x82,0x1d,0x82,0x0a,0x82,0x4c,0x82,0x47,0x81,0x08,0x82,0x08,0x81, -0x27,0x82,0x07,0x81,0x01,0x81,0x05,0x88,0x02,0x82,0x07,0x81,0x02,0x81,0x01, -0x82,0x05,0x81,0x02,0x81,0x08,0x81,0x08,0x82,0x0a,0x82,0x07,0x81,0x09,0x82, -0x27,0x82,0x04,0x82,0x04,0x82,0x06,0x82,0x0a,0x81,0x08,0x81,0x06,0x81,0x01, -0x82,0x05,0x81,0x08,0x82,0x0c,0x81,0x05,0x81,0x04,0x82,0x04,0x81,0x04,0x81, -0x05,0x82,0x08,0x82,0x2a,0x81,0x03,0x81,0x02,0x81,0x03,0x81,0x04,0x81,0x01, -0x82,0x04,0x82,0x04,0x81,0x03,0x82,0x04,0x82,0x02,0x82,0x05,0x81,0x02,0x82, -0x09,0x82,0x07,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03, -0x82,0x02,0x81,0x05,0x82,0x07,0x83,0x03,0x83,0x02,0x84,0x03,0x81,0x02,0x82, -0x05,0x81,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02, -0x82,0x0b,0x82,0x05,0x82,0x05,0x81,0x02,0x82,0x04,0x81,0x03,0x81,0x02,0x82, -0x01,0x82,0x04,0x81,0x01,0x82,0x05,0x82,0x01,0x82,0x08,0x82,0x07,0x81,0x08, -0x82,0x0a,0x81,0x06,0x82,0x01,0x81,0x1a,0x85,0x04,0x82,0x01,0x83,0x06,0x84, -0x06,0x83,0x01,0x82,0x04,0x84,0x06,0x82,0x07,0x85,0x04,0x82,0x01,0x83,0x06, -0x83,0x08,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x05,0x81,0x01,0x82,0x01,0x82, -0x03,0x82,0x01,0x84,0x05,0x84,0x04,0x82,0x01,0x83,0x06,0x83,0x01,0x82,0x03, -0x82,0x01,0x84,0x04,0x84,0x04,0x86,0x04,0x82,0x04,0x82,0x02,0x82,0x04,0x81, -0x02,0x82,0x06,0x81,0x02,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x03,0x86,0x07, -0x81,0x08,0x82,0x08,0x81,0x27,0x82,0x11,0x81,0x02,0x81,0x05,0x82,0x06,0x84, -0x01,0x81,0x06,0x83,0x12,0x82,0x0a,0x82,0x05,0x81,0x01,0x81,0x01,0x81,0x07, -0x82,0x27,0x81,0x05,0x82,0x04,0x82,0x06,0x82,0x09,0x82,0x07,0x82,0x05,0x82, -0x01,0x82,0x04,0x85,0x05,0x81,0x01,0x83,0x08,0x82,0x06,0x81,0x02,0x82,0x05, -0x81,0x04,0x81,0x05,0x82,0x08,0x82,0x0a,0x83,0x04,0x86,0x04,0x82,0x0c,0x82, -0x02,0x81,0x02,0x81,0x01,0x81,0x02,0x81,0x04,0x81,0x01,0x82,0x04,0x82,0x03, -0x82,0x03,0x82,0x08,0x82,0x05,0x81,0x02,0x82,0x09,0x82,0x07,0x81,0x09,0x82, -0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x01,0x82,0x05,0x82,0x07,0x84,0x02, -0x83,0x02,0x82,0x01,0x81,0x03,0x81,0x02,0x82,0x05,0x81,0x02,0x82,0x04,0x82, -0x02,0x81,0x06,0x81,0x02,0x82,0x03,0x82,0x04,0x82,0x0a,0x82,0x05,0x82,0x05, -0x81,0x03,0x81,0x03,0x82,0x03,0x81,0x01,0x81,0x01,0x81,0x01,0x81,0x05,0x83, -0x07,0x84,0x07,0x82,0x08,0x81,0x09,0x81,0x0a,0x81,0x06,0x81,0x02,0x81,0x19, -0x82,0x02,0x83,0x03,0x83,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x83, -0x03,0x82,0x02,0x82,0x04,0x85,0x04,0x83,0x01,0x83,0x03,0x83,0x02,0x82,0x06, -0x82,0x08,0x82,0x06,0x82,0x02,0x81,0x07,0x82,0x05,0x82,0x01,0x82,0x01,0x82, -0x02,0x83,0x03,0x82,0x03,0x82,0x02,0x82,0x03,0x83,0x02,0x82,0x04,0x82,0x02, -0x83,0x03,0x83,0x03,0x81,0x03,0x82,0x02,0x82,0x04,0x82,0x07,0x82,0x04,0x82, -0x03,0x81,0x03,0x82,0x02,0x82,0x02,0x82,0x02,0x81,0x03,0x82,0x02,0x81,0x05, -0x81,0x04,0x82,0x07,0x81,0x08,0x81,0x08,0x82,0x08,0x81,0x27,0x82,0x11,0x81, -0x02,0x81,0x06,0x83,0x08,0x81,0x07,0x82,0x13,0x82,0x0a,0x82,0x05,0x85,0x04, -0x88,0x23,0x82,0x05,0x82,0x04,0x82,0x06,0x82,0x08,0x82,0x06,0x83,0x06,0x81, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x07,0x81,0x08,0x83,0x06, -0x82,0x02,0x82,0x19,0x83,0x11,0x83,0x09,0x82,0x03,0x81,0x01,0x81,0x02,0x81, -0x02,0x81,0x03,0x82,0x02,0x81,0x04,0x86,0x04,0x82,0x08,0x82,0x05,0x81,0x02, -0x86,0x05,0x86,0x03,0x81,0x09,0x88,0x05,0x82,0x0a,0x82,0x03,0x84,0x06,0x82, -0x07,0x82,0x01,0x81,0x01,0x81,0x01,0x82,0x02,0x82,0x01,0x82,0x02,0x81,0x02, -0x82,0x05,0x81,0x02,0x82,0x03,0x82,0x03,0x81,0x06,0x81,0x02,0x86,0x06,0x83, -0x08,0x82,0x05,0x82,0x05,0x81,0x03,0x82,0x02,0x81,0x04,0x81,0x01,0x81,0x01, -0x81,0x01,0x81,0x06,0x82,0x08,0x82,0x08,0x81,0x09,0x81,0x09,0x82,0x09,0x81, -0x06,0x81,0x02,0x82,0x1d,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x81,0x03, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x04,0x82,0x06,0x82,0x03,0x82,0x03,0x82, -0x04,0x82,0x05,0x82,0x08,0x82,0x06,0x82,0x01,0x81,0x08,0x82,0x05,0x82,0x01, -0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x03,0x82,0x08,0x81,0x09,0x82,0x07,0x82,0x04,0x82,0x03, -0x82,0x02,0x81,0x04,0x81,0x02,0x82,0x02,0x81,0x04,0x81,0x01,0x82,0x05,0x82, -0x02,0x82,0x07,0x82,0x08,0x81,0x08,0x82,0x08,0x81,0x07,0x83,0x03,0x81,0x19, -0x82,0x11,0x81,0x02,0x81,0x08,0x82,0x07,0x81,0x01,0x82,0x03,0x82,0x01,0x81, -0x02,0x82,0x0e,0x81,0x0c,0x81,0x06,0x82,0x06,0x88,0x0d,0x86,0x10,0x81,0x06, -0x82,0x04,0x82,0x06,0x82,0x07,0x82,0x09,0x82,0x04,0x82,0x02,0x82,0x09,0x82, -0x03,0x81,0x04,0x82,0x05,0x82,0x06,0x82,0x03,0x81,0x06,0x85,0x18,0x82,0x15, -0x83,0x06,0x82,0x04,0x81,0x01,0x81,0x02,0x81,0x02,0x81,0x03,0x81,0x03,0x82, -0x03,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x05,0x81,0x02,0x82,0x09,0x82,0x07, -0x81,0x03,0x84,0x02,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x01,0x82, -0x05,0x82,0x07,0x82,0x01,0x81,0x01,0x81,0x01,0x82,0x02,0x82,0x02,0x82,0x01, -0x81,0x02,0x82,0x05,0x81,0x02,0x86,0x04,0x81,0x06,0x81,0x02,0x82,0x03,0x82, -0x07,0x82,0x07,0x82,0x05,0x82,0x05,0x81,0x03,0x82,0x02,0x81,0x04,0x83,0x01, -0x83,0x05,0x83,0x08,0x82,0x07,0x82,0x09,0x81,0x0a,0x81,0x09,0x81,0x25,0x85, -0x03,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x88,0x04,0x82,0x06, -0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x08,0x82,0x06,0x84,0x08,0x82, -0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x08,0x83,0x07,0x82,0x07,0x82, -0x04,0x82,0x04,0x81,0x02,0x81,0x04,0x81,0x02,0x82,0x02,0x81,0x05,0x82,0x06, -0x82,0x02,0x82,0x06,0x82,0x07,0x82,0x09,0x82,0x09,0x82,0x04,0x82,0x01,0x82, -0x01,0x82,0x2a,0x87,0x08,0x82,0x05,0x81,0x01,0x81,0x02,0x81,0x02,0x81,0x02, -0x82,0x01,0x82,0x0e,0x81,0x0c,0x81,0x05,0x82,0x01,0x82,0x07,0x82,0x26,0x81, -0x06,0x82,0x04,0x82,0x06,0x82,0x06,0x82,0x0b,0x82,0x03,0x87,0x08,0x82,0x03, -0x81,0x04,0x82,0x05,0x82,0x06,0x81,0x04,0x82,0x09,0x81,0x18,0x82,0x08,0x86, -0x08,0x82,0x06,0x82,0x04,0x81,0x01,0x81,0x02,0x81,0x02,0x81,0x03,0x86,0x03, -0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x05,0x81,0x02,0x82,0x09,0x82,0x07,0x82, -0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x0a,0x82,0x03,0x82,0x02,0x82,0x04, -0x82,0x07,0x82,0x01,0x83,0x01,0x82,0x02,0x82,0x03,0x81,0x01,0x81,0x02,0x82, -0x05,0x81,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x81,0x08,0x82,0x06, -0x82,0x05,0x82,0x05,0x81,0x04,0x81,0x01,0x82,0x05,0x82,0x02,0x82,0x05,0x81, -0x01,0x82,0x07,0x82,0x06,0x82,0x0a,0x81,0x0a,0x81,0x09,0x81,0x24,0x82,0x02, -0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x0a,0x82, -0x06,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82,0x08,0x82,0x06,0x84,0x08, -0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x0b,0x83,0x04,0x82,0x07, -0x82,0x04,0x82,0x04,0x81,0x01,0x82,0x04,0x81,0x01,0x81,0x01,0x81,0x01,0x82, -0x05,0x82,0x07,0x81,0x02,0x82,0x06,0x81,0x0a,0x81,0x08,0x82,0x08,0x81,0x06, -0x81,0x03,0x83,0x2c,0x81,0x02,0x81,0x05,0x81,0x04,0x82,0x04,0x81,0x02,0x81, -0x02,0x81,0x01,0x82,0x03,0x83,0x0f,0x82,0x0a,0x82,0x11,0x82,0x25,0x82,0x07, -0x81,0x04,0x81,0x07,0x82,0x05,0x82,0x07,0x81,0x04,0x82,0x03,0x87,0x03,0x81, -0x04,0x82,0x03,0x81,0x04,0x82,0x05,0x81,0x07,0x81,0x04,0x82,0x08,0x82,0x19, -0x84,0x10,0x83,0x0e,0x81,0x01,0x81,0x02,0x81,0x01,0x82,0x02,0x82,0x04,0x81, -0x03,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x09, -0x82,0x07,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x05,0x82,0x05,0x81,0x04,0x82, -0x03,0x82,0x03,0x81,0x04,0x82,0x07,0x82,0x02,0x81,0x02,0x82,0x02,0x82,0x03, -0x83,0x02,0x82,0x04,0x82,0x02,0x82,0x08,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x02,0x81,0x05,0x81,0x06,0x82,0x05,0x83,0x03,0x82,0x04,0x83,0x06,0x82,0x02, -0x82,0x04,0x82,0x02,0x81,0x07,0x82,0x06,0x81,0x0b,0x81,0x0a,0x82,0x08,0x81, -0x23,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x04,0x81,0x03,0x82,0x04, -0x82,0x02,0x82,0x0a,0x82,0x06,0x82,0x03,0x82,0x03,0x82,0x04,0x82,0x05,0x82, -0x08,0x82,0x06,0x82,0x01,0x82,0x07,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x04,0x82, -0x03,0x82,0x0d,0x81,0x04,0x82,0x07,0x82,0x03,0x83,0x04,0x83,0x06,0x82,0x02, -0x82,0x05,0x81,0x01,0x82,0x06,0x84,0x06,0x81,0x0b,0x81,0x08,0x82,0x08,0x81, -0x27,0x82,0x10,0x81,0x02,0x81,0x05,0x82,0x02,0x83,0x04,0x81,0x02,0x81,0x02, -0x81,0x02,0x81,0x04,0x82,0x0f,0x82,0x0a,0x82,0x11,0x82,0x07,0x82,0x12,0x82, -0x08,0x81,0x08,0x82,0x02,0x82,0x07,0x82,0x05,0x81,0x08,0x82,0x03,0x81,0x08, -0x82,0x04,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x06,0x81,0x07,0x82,0x02,0x82, -0x08,0x82,0x06,0x82,0x08,0x82,0x0b,0x82,0x0e,0x82,0x0a,0x82,0x04,0x81,0x01, -0x83,0x01,0x82,0x03,0x81,0x05,0x82,0x02,0x82,0x04,0x82,0x03,0x83,0x01,0x82, -0x03,0x82,0x03,0x82,0x03,0x82,0x09,0x82,0x08,0x82,0x03,0x82,0x02,0x82,0x04, -0x82,0x05,0x82,0x05,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x03,0x82,0x07,0x82, -0x05,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03,0x82,0x09,0x82,0x02, -0x82,0x03,0x82,0x04,0x82,0x02,0x82,0x03,0x82,0x06,0x82,0x06,0x82,0x03,0x82, -0x05,0x82,0x06,0x82,0x02,0x81,0x04,0x82,0x03,0x82,0x06,0x82,0x05,0x82,0x0b, -0x81,0x0b,0x81,0x08,0x81,0x23,0x82,0x02,0x83,0x03,0x83,0x02,0x82,0x04,0x82, -0x02,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x03,0x82,0x04,0x82,0x06,0x83,0x01, -0x83,0x03,0x82,0x04,0x82,0x05,0x82,0x08,0x82,0x06,0x82,0x02,0x82,0x06,0x82, -0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x03, -0x83,0x02,0x82,0x04,0x82,0x02,0x83,0x03,0x82,0x08,0x82,0x02,0x82,0x04,0x82, -0x03,0x81,0x03,0x83,0x01,0x84,0x05,0x82,0x06,0x82,0x02,0x82,0x04,0x82,0x02, -0x81,0x07,0x83,0x05,0x82,0x0b,0x81,0x08,0x82,0x08,0x81,0x27,0x82,0x10,0x81, -0x02,0x81,0x06,0x85,0x09,0x82,0x04,0x84,0x01,0x82,0x0f,0x81,0x0a,0x81,0x1b, -0x82,0x12,0x82,0x08,0x81,0x09,0x84,0x08,0x82,0x04,0x87,0x04,0x84,0x09,0x82, -0x05,0x84,0x06,0x84,0x07,0x81,0x08,0x84,0x06,0x84,0x07,0x82,0x08,0x82,0x27, -0x82,0x04,0x82,0x09,0x81,0x06,0x81,0x02,0x87,0x05,0x84,0x04,0x86,0x04,0x87, -0x04,0x82,0x09,0x85,0x03,0x82,0x04,0x82,0x03,0x86,0x04,0x84,0x05,0x82,0x04, -0x82,0x02,0x87,0x02,0x82,0x05,0x82,0x02,0x82,0x05,0x81,0x04,0x84,0x04,0x82, -0x0a,0x86,0x02,0x82,0x04,0x82,0x03,0x85,0x07,0x82,0x07,0x85,0x06,0x82,0x06, -0x82,0x02,0x81,0x04,0x82,0x04,0x82,0x05,0x82,0x05,0x87,0x06,0x81,0x0b,0x82, -0x07,0x81,0x23,0x84,0x01,0x82,0x03,0x82,0x01,0x83,0x06,0x84,0x06,0x83,0x01, -0x82,0x04,0x85,0x05,0x82,0x07,0x83,0x01,0x82,0x03,0x82,0x04,0x82,0x03,0x86, -0x06,0x82,0x06,0x82,0x03,0x81,0x04,0x86,0x03,0x82,0x01,0x82,0x01,0x82,0x02, -0x82,0x04,0x82,0x04,0x84,0x04,0x82,0x01,0x83,0x06,0x83,0x01,0x82,0x03,0x82, -0x09,0x84,0x06,0x84,0x05,0x84,0x01,0x82,0x05,0x82,0x06,0x81,0x03,0x82,0x03, -0x82,0x03,0x82,0x07,0x82,0x05,0x86,0x07,0x81,0x08,0x82,0x08,0x81,0x45,0x81, -0x27,0x81,0x0a,0x81,0x1c,0x81,0x1b,0x82,0x78,0x81,0x2e,0x82,0x7f,0x30,0x82, -0x5e,0x81,0x0c,0x81,0x07,0x81,0x0f,0x88,0x4d,0x82,0x1a,0x82,0x37,0x82,0x0e, -0x82,0x4b,0x82,0x13,0x82,0x07,0x82,0x07,0x82,0x45,0x81,0x28,0x81,0x08,0x81, -0x1c,0x81,0x1c,0x81,0x78,0x81,0x30,0x84,0x7f,0x7f,0x0e,0x83,0x0a,0x81,0x05, -0x83,0x64,0x82,0x1a,0x82,0x37,0x82,0x0e,0x82,0x4b,0x82,0x14,0x81,0x07,0x82, -0x07,0x81,0x70,0x81,0x06,0x81,0x7f,0x7f,0x7f,0x7f,0x6e,0x85,0x1a,0x82,0x38, -0x82,0x0e,0x82,0x4a,0x82,0x16,0x81,0x0e,0x81,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x62, -0x00, - } -}; diff --git a/minui21/roboto_15x24.h b/minui21/roboto_15x24.h deleted file mode 100644 index 7271d74b..00000000 --- a/minui21/roboto_15x24.h +++ /dev/null @@ -1,281 +0,0 @@ -struct { - unsigned width; - unsigned height; - unsigned cwidth; - unsigned cheight; - unsigned char rundata[]; -} font = { - .width = 1440, - .height = 24, - .cwidth = 15, - .cheight = 24, - .rundata = { -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x6e,0x81,0x3e,0x81, -0x07,0x81,0x7f,0x7f,0x7f,0x7f,0x7f,0x76,0x84,0x17,0x84,0x7f,0x7f,0x7f,0x7f, -0x4c,0x81,0x3d,0x82,0x07,0x82,0x5f,0x81,0x7f,0x7f,0x7f,0x7f,0x7f,0x15,0x84, -0x07,0x82,0x0e,0x84,0x45,0x82,0x24,0x82,0x1a,0x83,0x16,0x82,0x10,0x82,0x0e, -0x82,0x0a,0x82,0x0d,0x84,0x7f,0x62,0x82,0x0b,0x82,0x0b,0x82,0x3b,0x82,0x0c, -0x82,0x02,0x82,0x0a,0x82,0x03,0x81,0x0a,0x84,0x08,0x83,0x0e,0x84,0x0b,0x82, -0x10,0x82,0x09,0x82,0x5e,0x81,0x09,0x84,0x0b,0x84,0x0b,0x84,0x0b,0x84,0x0e, -0x83,0x08,0x88,0x09,0x84,0x07,0x8a,0x08,0x84,0x0b,0x84,0x56,0x84,0x1c,0x82, -0x08,0x87,0x0b,0x85,0x07,0x87,0x09,0x89,0x06,0x8a,0x07,0x85,0x06,0x82,0x08, -0x82,0x06,0x86,0x0f,0x82,0x06,0x82,0x07,0x82,0x04,0x82,0x0a,0x83,0x09,0x82, -0x03,0x82,0x08,0x82,0x06,0x85,0x07,0x87,0x0b,0x85,0x07,0x87,0x0c,0x84,0x06, -0x8d,0x03,0x82,0x07,0x82,0x02,0x83,0x08,0x83,0x01,0x82,0x0a,0x82,0x02,0x82, -0x08,0x82,0x03,0x82,0x08,0x82,0x04,0x8b,0x09,0x82,0x09,0x82,0x10,0x82,0x0d, -0x81,0x1d,0x82,0x18,0x82,0x24,0x82,0x19,0x84,0x16,0x82,0x10,0x82,0x0e,0x82, -0x0a,0x82,0x0d,0x84,0x7f,0x61,0x82,0x0c,0x82,0x0c,0x82,0x3a,0x82,0x0c,0x82, -0x02,0x82,0x0a,0x82,0x03,0x81,0x08,0x87,0x06,0x82,0x01,0x82,0x0c,0x86,0x0a, -0x82,0x0f,0x82,0x0b,0x82,0x5c,0x82,0x08,0x87,0x07,0x86,0x0a,0x87,0x08,0x87, -0x0c,0x83,0x08,0x88,0x07,0x87,0x06,0x8a,0x07,0x87,0x07,0x87,0x54,0x87,0x08, -0x86,0x0c,0x82,0x08,0x89,0x07,0x88,0x06,0x89,0x07,0x89,0x06,0x8a,0x05,0x88, -0x05,0x82,0x08,0x82,0x06,0x86,0x0f,0x82,0x06,0x82,0x06,0x82,0x05,0x82,0x0a, -0x83,0x08,0x83,0x03,0x83,0x07,0x82,0x04,0x88,0x06,0x89,0x07,0x88,0x06,0x89, -0x08,0x88,0x04,0x8d,0x03,0x82,0x07,0x82,0x03,0x82,0x08,0x82,0x02,0x82,0x04, -0x81,0x05,0x82,0x03,0x82,0x06,0x82,0x04,0x82,0x07,0x83,0x04,0x8b,0x09,0x82, -0x0a,0x82,0x0f,0x82,0x0c,0x83,0x1d,0x82,0x17,0x82,0x24,0x82,0x18,0x83,0x18, -0x82,0x2c,0x82,0x0f,0x82,0x7f,0x60,0x83,0x0c,0x82,0x0d,0x82,0x39,0x82,0x0c, -0x82,0x02,0x82,0x0a,0x82,0x02,0x82,0x07,0x83,0x03,0x83,0x04,0x82,0x03,0x81, -0x04,0x81,0x06,0x83,0x03,0x82,0x09,0x82,0x0f,0x82,0x0b,0x82,0x5c,0x82,0x07, -0x82,0x04,0x82,0x0a,0x83,0x09,0x82,0x04,0x83,0x06,0x82,0x04,0x83,0x0a,0x84, -0x08,0x82,0x0d,0x82,0x13,0x82,0x06,0x82,0x04,0x83,0x06,0x82,0x04,0x82,0x52, -0x82,0x04,0x82,0x07,0x82,0x05,0x82,0x09,0x84,0x07,0x82,0x05,0x83,0x06,0x82, -0x05,0x82,0x05,0x82,0x05,0x83,0x06,0x82,0x0d,0x82,0x0d,0x82,0x05,0x82,0x04, -0x82,0x08,0x82,0x08,0x82,0x11,0x82,0x06,0x82,0x05,0x82,0x06,0x82,0x0a,0x83, -0x08,0x83,0x03,0x83,0x07,0x82,0x04,0x82,0x05,0x82,0x05,0x82,0x06,0x82,0x06, -0x82,0x05,0x82,0x05,0x82,0x05,0x83,0x06,0x83,0x04,0x83,0x08,0x83,0x08,0x82, -0x07,0x82,0x03,0x82,0x08,0x82,0x02,0x82,0x03,0x83,0x04,0x82,0x03,0x83,0x04, -0x83,0x05,0x82,0x06,0x82,0x0d,0x82,0x0a,0x82,0x0a,0x82,0x0f,0x82,0x0c,0x83, -0x1e,0x81,0x17,0x82,0x24,0x82,0x18,0x82,0x19,0x82,0x2c,0x82,0x0f,0x82,0x74, -0x82,0x69,0x82,0x0d,0x82,0x0d,0x82,0x39,0x82,0x0c,0x82,0x02,0x82,0x0a,0x82, -0x02,0x82,0x07,0x82,0x05,0x82,0x04,0x82,0x03,0x82,0x02,0x82,0x06,0x82,0x04, -0x82,0x09,0x82,0x0e,0x82,0x0d,0x82,0x1c,0x82,0x3c,0x82,0x08,0x82,0x05,0x82, -0x09,0x83,0x09,0x82,0x05,0x82,0x05,0x83,0x05,0x82,0x09,0x85,0x07,0x82,0x0d, -0x82,0x13,0x82,0x07,0x82,0x05,0x82,0x05,0x82,0x05,0x83,0x51,0x82,0x04,0x82, -0x06,0x82,0x07,0x82,0x08,0x84,0x07,0x82,0x06,0x82,0x05,0x82,0x07,0x82,0x04, -0x82,0x06,0x83,0x05,0x82,0x0d,0x82,0x0c,0x82,0x07,0x82,0x03,0x82,0x08,0x82, -0x08,0x82,0x11,0x82,0x06,0x82,0x04,0x83,0x06,0x82,0x0a,0x84,0x06,0x84,0x03, -0x84,0x06,0x82,0x03,0x82,0x07,0x82,0x04,0x82,0x07,0x82,0x04,0x82,0x07,0x82, -0x04,0x82,0x06,0x82,0x06,0x82,0x06,0x82,0x08,0x83,0x08,0x82,0x07,0x82,0x03, -0x83,0x06,0x83,0x02,0x82,0x03,0x83,0x03,0x82,0x05,0x82,0x04,0x82,0x06,0x82, -0x05,0x83,0x0c,0x83,0x0a,0x82,0x0b,0x82,0x0e,0x82,0x0c,0x81,0x01,0x82,0x35, -0x82,0x24,0x82,0x18,0x82,0x19,0x82,0x2c,0x82,0x0f,0x82,0x74,0x82,0x69,0x82, -0x0d,0x82,0x0d,0x83,0x38,0x82,0x0c,0x82,0x02,0x81,0x0b,0x81,0x03,0x82,0x07, -0x82,0x05,0x82,0x04,0x82,0x03,0x82,0x02,0x81,0x07,0x82,0x04,0x82,0x09,0x82, -0x0e,0x82,0x0d,0x82,0x0d,0x82,0x0d,0x82,0x3c,0x82,0x07,0x82,0x06,0x82,0x09, -0x83,0x08,0x83,0x05,0x82,0x0d,0x82,0x09,0x85,0x07,0x82,0x0d,0x82,0x12,0x83, -0x07,0x82,0x05,0x82,0x05,0x82,0x06,0x82,0x57,0x83,0x04,0x82,0x09,0x81,0x08, -0x84,0x07,0x82,0x06,0x82,0x05,0x82,0x07,0x82,0x04,0x82,0x07,0x82,0x05,0x82, -0x0d,0x82,0x0c,0x82,0x07,0x82,0x03,0x82,0x08,0x82,0x08,0x82,0x11,0x82,0x06, -0x82,0x03,0x83,0x07,0x82,0x0a,0x84,0x06,0x84,0x03,0x85,0x05,0x82,0x03,0x82, -0x07,0x82,0x04,0x82,0x07,0x82,0x04,0x82,0x07,0x82,0x04,0x82,0x06,0x83,0x05, -0x82,0x06,0x82,0x08,0x83,0x08,0x82,0x07,0x82,0x04,0x82,0x06,0x82,0x03,0x82, -0x03,0x83,0x03,0x82,0x05,0x83,0x02,0x83,0x07,0x82,0x04,0x82,0x0d,0x82,0x0b, -0x82,0x0b,0x82,0x0e,0x82,0x0b,0x82,0x01,0x82,0x29,0x84,0x08,0x82,0x01,0x84, -0x0a,0x86,0x0a,0x83,0x02,0x82,0x08,0x84,0x0a,0x86,0x0a,0x83,0x02,0x82,0x06, -0x82,0x01,0x84,0x09,0x84,0x0e,0x82,0x0a,0x82,0x04,0x83,0x08,0x82,0x07,0x81, -0x02,0x83,0x03,0x83,0x05,0x81,0x02,0x84,0x0b,0x84,0x09,0x81,0x02,0x84,0x0a, -0x83,0x02,0x82,0x08,0x81,0x02,0x84,0x08,0x84,0x08,0x88,0x07,0x82,0x06,0x82, -0x05,0x82,0x06,0x82,0x03,0x82,0x03,0x82,0x05,0x82,0x04,0x82,0x05,0x82,0x04, -0x83,0x05,0x83,0x06,0x89,0x09,0x82,0x0d,0x82,0x0d,0x83,0x38,0x82,0x0c,0x82, -0x02,0x81,0x08,0x8b,0x05,0x82,0x0b,0x82,0x03,0x81,0x02,0x82,0x07,0x83,0x02, -0x82,0x0a,0x81,0x0f,0x82,0x0d,0x82,0x0d,0x82,0x0d,0x82,0x3c,0x82,0x07,0x82, -0x06,0x82,0x09,0x83,0x10,0x82,0x0d,0x82,0x08,0x82,0x01,0x83,0x07,0x82,0x0d, -0x82,0x12,0x82,0x08,0x82,0x05,0x82,0x05,0x82,0x06,0x82,0x08,0x82,0x0d,0x82, -0x13,0x81,0x06,0x89,0x06,0x81,0x14,0x82,0x05,0x81,0x04,0x84,0x02,0x82,0x06, -0x82,0x02,0x82,0x06,0x82,0x06,0x82,0x04,0x82,0x0e,0x82,0x07,0x82,0x05,0x82, -0x0d,0x82,0x0b,0x82,0x0d,0x82,0x08,0x82,0x08,0x82,0x11,0x82,0x06,0x82,0x03, -0x82,0x08,0x82,0x0a,0x82,0x01,0x82,0x05,0x84,0x03,0x82,0x01,0x82,0x05,0x82, -0x02,0x82,0x09,0x82,0x03,0x82,0x07,0x82,0x03,0x82,0x09,0x82,0x03,0x82,0x06, -0x83,0x05,0x82,0x10,0x83,0x08,0x82,0x07,0x82,0x04,0x82,0x06,0x82,0x03,0x82, -0x03,0x81,0x01,0x82,0x02,0x82,0x06,0x82,0x02,0x82,0x08,0x82,0x03,0x83,0x0c, -0x82,0x0c,0x82,0x0b,0x82,0x0e,0x82,0x0b,0x82,0x02,0x81,0x28,0x87,0x06,0x88, -0x08,0x88,0x08,0x88,0x07,0x86,0x09,0x86,0x09,0x88,0x06,0x88,0x08,0x84,0x0e, -0x82,0x0a,0x82,0x03,0x83,0x09,0x82,0x07,0x87,0x01,0x85,0x04,0x88,0x09,0x87, -0x07,0x81,0x01,0x86,0x08,0x88,0x08,0x87,0x06,0x87,0x07,0x88,0x07,0x82,0x06, -0x82,0x05,0x82,0x05,0x82,0x04,0x82,0x03,0x82,0x05,0x82,0x04,0x83,0x03,0x83, -0x05,0x82,0x05,0x82,0x07,0x89,0x09,0x82,0x0d,0x82,0x0d,0x83,0x38,0x82,0x1b, -0x82,0x03,0x81,0x08,0x83,0x0b,0x85,0x01,0x82,0x09,0x85,0x1a,0x83,0x0d,0x83, -0x09,0x81,0x02,0x82,0x01,0x81,0x0b,0x82,0x3b,0x82,0x08,0x82,0x06,0x82,0x09, -0x83,0x0f,0x82,0x0d,0x82,0x09,0x82,0x01,0x83,0x07,0x87,0x07,0x83,0x01,0x84, -0x0c,0x82,0x09,0x83,0x03,0x82,0x06,0x82,0x06,0x82,0x08,0x82,0x0d,0x82,0x11, -0x83,0x06,0x89,0x06,0x83,0x12,0x82,0x05,0x81,0x03,0x82,0x02,0x82,0x02,0x81, -0x06,0x82,0x02,0x82,0x06,0x82,0x05,0x82,0x05,0x82,0x0e,0x82,0x07,0x83,0x04, -0x82,0x0d,0x82,0x0b,0x82,0x0d,0x82,0x08,0x82,0x08,0x82,0x11,0x82,0x06,0x82, -0x02,0x82,0x09,0x82,0x0a,0x82,0x01,0x82,0x04,0x82,0x01,0x82,0x03,0x82,0x02, -0x82,0x04,0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x07,0x82,0x03,0x82,0x09,0x82, -0x03,0x82,0x06,0x82,0x06,0x83,0x0f,0x83,0x08,0x82,0x07,0x82,0x05,0x82,0x04, -0x82,0x05,0x81,0x02,0x82,0x01,0x82,0x02,0x82,0x07,0x84,0x0a,0x82,0x02,0x82, -0x0c,0x83,0x0c,0x82,0x0c,0x82,0x0d,0x82,0x0a,0x82,0x03,0x82,0x26,0x82,0x04, -0x82,0x06,0x83,0x03,0x83,0x07,0x82,0x05,0x82,0x06,0x82,0x04,0x83,0x06,0x82, -0x04,0x82,0x0a,0x82,0x0a,0x83,0x03,0x83,0x06,0x82,0x04,0x83,0x09,0x82,0x0e, -0x82,0x0a,0x82,0x03,0x82,0x0a,0x82,0x07,0x82,0x03,0x84,0x02,0x82,0x04,0x82, -0x04,0x83,0x07,0x82,0x04,0x83,0x06,0x82,0x04,0x83,0x06,0x82,0x04,0x83,0x08, -0x83,0x0a,0x82,0x04,0x82,0x08,0x82,0x0b,0x82,0x06,0x82,0x05,0x82,0x05,0x82, -0x04,0x82,0x03,0x83,0x03,0x82,0x06,0x82,0x03,0x82,0x06,0x82,0x05,0x82,0x0d, -0x82,0x0a,0x82,0x0d,0x82,0x0d,0x83,0x38,0x82,0x1b,0x82,0x02,0x82,0x09,0x85, -0x0e,0x81,0x0b,0x83,0x1b,0x82,0x0f,0x82,0x09,0x87,0x0b,0x82,0x3b,0x82,0x08, -0x82,0x06,0x82,0x09,0x83,0x0e,0x83,0x09,0x85,0x09,0x82,0x02,0x83,0x07,0x88, -0x06,0x89,0x0b,0x82,0x0a,0x86,0x07,0x82,0x06,0x82,0x27,0x85,0x17,0x84,0x0f, -0x82,0x05,0x82,0x03,0x81,0x03,0x82,0x02,0x81,0x06,0x82,0x02,0x82,0x06,0x88, -0x06,0x82,0x0e,0x82,0x07,0x83,0x04,0x88,0x07,0x88,0x05,0x82,0x0d,0x8c,0x08, -0x82,0x11,0x82,0x06,0x85,0x0a,0x82,0x0a,0x82,0x01,0x82,0x04,0x82,0x01,0x82, -0x03,0x82,0x02,0x82,0x04,0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x06,0x82,0x04, -0x82,0x09,0x82,0x03,0x82,0x04,0x83,0x08,0x85,0x0c,0x83,0x08,0x82,0x07,0x82, -0x05,0x82,0x04,0x82,0x05,0x82,0x01,0x82,0x01,0x82,0x02,0x81,0x08,0x84,0x0a, -0x86,0x0c,0x82,0x0d,0x82,0x0c,0x82,0x0d,0x82,0x0a,0x82,0x03,0x82,0x26,0x82, -0x04,0x83,0x05,0x82,0x05,0x82,0x06,0x83,0x05,0x82,0x05,0x83,0x05,0x82,0x05, -0x83,0x04,0x82,0x0a,0x82,0x0a,0x82,0x05,0x82,0x06,0x82,0x05,0x82,0x09,0x82, -0x0e,0x82,0x0a,0x82,0x02,0x82,0x0b,0x82,0x07,0x82,0x03,0x83,0x03,0x83,0x03, -0x82,0x05,0x82,0x06,0x83,0x05,0x82,0x06,0x82,0x05,0x82,0x05,0x83,0x05,0x82, -0x08,0x82,0x0b,0x82,0x04,0x82,0x08,0x82,0x0b,0x82,0x06,0x82,0x06,0x82,0x04, -0x82,0x04,0x82,0x02,0x84,0x03,0x82,0x07,0x82,0x01,0x82,0x07,0x83,0x03,0x83, -0x0c,0x83,0x0a,0x82,0x0d,0x82,0x0e,0x82,0x0a,0x82,0x2c,0x82,0x1b,0x82,0x02, -0x82,0x0b,0x85,0x0b,0x82,0x09,0x85,0x1b,0x82,0x0f,0x82,0x0b,0x83,0x09,0x8b, -0x36,0x81,0x09,0x82,0x06,0x82,0x09,0x83,0x0e,0x82,0x0a,0x86,0x07,0x82,0x03, -0x83,0x07,0x82,0x04,0x83,0x05,0x84,0x03,0x83,0x09,0x82,0x0b,0x87,0x07,0x82, -0x04,0x83,0x25,0x85,0x1b,0x85,0x0b,0x82,0x06,0x82,0x02,0x82,0x03,0x82,0x02, -0x81,0x05,0x82,0x04,0x82,0x05,0x8a,0x04,0x82,0x0e,0x82,0x07,0x83,0x04,0x88, -0x07,0x88,0x05,0x82,0x04,0x86,0x03,0x8c,0x08,0x82,0x11,0x82,0x06,0x86,0x09, -0x82,0x0a,0x82,0x02,0x82,0x02,0x82,0x02,0x82,0x03,0x82,0x03,0x82,0x03,0x82, -0x02,0x82,0x09,0x82,0x03,0x8a,0x04,0x82,0x09,0x82,0x03,0x89,0x0a,0x85,0x0a, -0x83,0x08,0x82,0x07,0x82,0x05,0x82,0x04,0x82,0x05,0x82,0x01,0x82,0x02,0x81, -0x01,0x82,0x09,0x82,0x0c,0x84,0x0c,0x82,0x0e,0x82,0x0d,0x82,0x0c,0x82,0x3d, -0x83,0x05,0x82,0x05,0x82,0x06,0x82,0x0d,0x82,0x06,0x82,0x05,0x82,0x06,0x82, -0x09,0x82,0x09,0x82,0x06,0x82,0x06,0x82,0x05,0x82,0x09,0x82,0x0e,0x82,0x0a, -0x82,0x01,0x83,0x0b,0x82,0x07,0x82,0x04,0x82,0x04,0x82,0x03,0x82,0x05,0x82, -0x06,0x82,0x06,0x82,0x06,0x82,0x05,0x82,0x05,0x82,0x06,0x82,0x08,0x82,0x0b, -0x82,0x0e,0x82,0x0b,0x82,0x06,0x82,0x06,0x82,0x03,0x82,0x06,0x82,0x01,0x82, -0x01,0x81,0x03,0x82,0x07,0x82,0x01,0x82,0x08,0x82,0x03,0x82,0x0c,0x83,0x09, -0x83,0x0e,0x82,0x0e,0x83,0x07,0x86,0x04,0x82,0x24,0x82,0x1b,0x81,0x03,0x82, -0x0d,0x84,0x0a,0x81,0x02,0x84,0x03,0x83,0x01,0x83,0x03,0x82,0x15,0x82,0x0f, -0x82,0x0b,0x84,0x08,0x8b,0x15,0x86,0x1a,0x82,0x09,0x82,0x06,0x82,0x09,0x83, -0x0d,0x82,0x0f,0x83,0x06,0x82,0x03,0x83,0x0e,0x82,0x05,0x83,0x05,0x82,0x09, -0x82,0x0a,0x82,0x04,0x83,0x06,0x89,0x24,0x83,0x21,0x84,0x08,0x82,0x07,0x81, -0x03,0x82,0x03,0x81,0x03,0x81,0x05,0x82,0x04,0x82,0x05,0x82,0x06,0x83,0x03, -0x82,0x0e,0x82,0x07,0x83,0x04,0x82,0x0d,0x82,0x0b,0x82,0x04,0x86,0x03,0x82, -0x08,0x82,0x08,0x82,0x11,0x82,0x06,0x82,0x02,0x82,0x09,0x82,0x0a,0x82,0x02, -0x82,0x02,0x82,0x02,0x82,0x03,0x82,0x03,0x83,0x02,0x82,0x02,0x82,0x09,0x82, -0x03,0x88,0x06,0x82,0x09,0x82,0x03,0x82,0x05,0x83,0x0c,0x84,0x08,0x83,0x08, -0x82,0x07,0x82,0x06,0x82,0x02,0x82,0x06,0x82,0x01,0x81,0x03,0x84,0x08,0x84, -0x0b,0x83,0x0c,0x83,0x0e,0x82,0x0d,0x82,0x0c,0x82,0x39,0x87,0x05,0x82,0x05, -0x82,0x06,0x82,0x0d,0x82,0x06,0x82,0x05,0x8a,0x09,0x82,0x09,0x82,0x06,0x82, -0x06,0x82,0x05,0x82,0x09,0x82,0x0e,0x82,0x0a,0x85,0x0c,0x82,0x07,0x82,0x04, -0x82,0x04,0x82,0x03,0x82,0x05,0x82,0x06,0x82,0x06,0x82,0x06,0x82,0x05,0x82, -0x05,0x82,0x06,0x82,0x08,0x82,0x0b,0x85,0x0b,0x82,0x0b,0x82,0x06,0x82,0x06, -0x82,0x03,0x82,0x06,0x82,0x01,0x82,0x01,0x82,0x02,0x82,0x08,0x83,0x09,0x82, -0x03,0x82,0x0c,0x82,0x0a,0x82,0x0f,0x82,0x0f,0x83,0x06,0x82,0x02,0x83,0x02, -0x82,0x25,0x82,0x18,0x8b,0x0d,0x82,0x09,0x82,0x01,0x82,0x02,0x82,0x02,0x82, -0x03,0x83,0x02,0x82,0x15,0x82,0x0f,0x82,0x0a,0x82,0x01,0x82,0x0c,0x82,0x3a, -0x82,0x09,0x82,0x06,0x82,0x09,0x83,0x0c,0x82,0x11,0x82,0x05,0x82,0x04,0x83, -0x0e,0x82,0x05,0x83,0x05,0x82,0x09,0x82,0x09,0x82,0x06,0x82,0x08,0x83,0x02, -0x82,0x24,0x83,0x0c,0x89,0x0d,0x83,0x08,0x82,0x07,0x81,0x03,0x82,0x03,0x81, -0x03,0x81,0x04,0x89,0x05,0x82,0x07,0x82,0x03,0x82,0x0e,0x82,0x07,0x82,0x05, -0x82,0x0d,0x82,0x0b,0x82,0x08,0x82,0x03,0x82,0x08,0x82,0x08,0x82,0x11,0x82, -0x06,0x82,0x03,0x82,0x08,0x82,0x0a,0x82,0x03,0x81,0x02,0x81,0x03,0x82,0x03, -0x82,0x04,0x82,0x02,0x82,0x02,0x82,0x09,0x82,0x03,0x82,0x0c,0x82,0x09,0x82, -0x03,0x82,0x06,0x82,0x0e,0x82,0x08,0x83,0x08,0x82,0x07,0x82,0x06,0x82,0x02, -0x82,0x06,0x84,0x03,0x84,0x07,0x86,0x0b,0x82,0x0c,0x82,0x0f,0x82,0x0d,0x82, -0x0c,0x82,0x37,0x89,0x05,0x82,0x05,0x82,0x06,0x82,0x0d,0x82,0x06,0x82,0x05, -0x8a,0x09,0x82,0x09,0x82,0x06,0x82,0x06,0x82,0x05,0x82,0x09,0x82,0x0e,0x82, -0x0a,0x85,0x0c,0x82,0x07,0x82,0x04,0x82,0x04,0x82,0x03,0x82,0x05,0x82,0x06, -0x82,0x06,0x82,0x06,0x82,0x05,0x82,0x05,0x82,0x06,0x82,0x08,0x82,0x0d,0x85, -0x09,0x82,0x0b,0x82,0x06,0x82,0x07,0x82,0x02,0x81,0x07,0x82,0x01,0x81,0x02, -0x82,0x01,0x82,0x09,0x83,0x0a,0x82,0x01,0x83,0x0b,0x82,0x0c,0x82,0x0e,0x82, -0x0e,0x82,0x07,0x82,0x04,0x86,0x3f,0x8b,0x05,0x82,0x06,0x82,0x08,0x82,0x02, -0x81,0x04,0x81,0x02,0x82,0x04,0x85,0x16,0x82,0x0f,0x82,0x0e,0x81,0x0c,0x82, -0x39,0x82,0x0a,0x82,0x06,0x82,0x09,0x83,0x0b,0x83,0x11,0x82,0x05,0x8b,0x0c, -0x82,0x06,0x82,0x05,0x82,0x08,0x83,0x09,0x82,0x06,0x82,0x0d,0x82,0x25,0x85, -0x09,0x89,0x0a,0x85,0x09,0x82,0x07,0x81,0x03,0x82,0x03,0x81,0x02,0x82,0x04, -0x8a,0x04,0x82,0x07,0x82,0x03,0x83,0x07,0x82,0x04,0x82,0x07,0x82,0x05,0x82, -0x0d,0x82,0x0b,0x83,0x07,0x82,0x03,0x82,0x08,0x82,0x08,0x82,0x11,0x82,0x06, -0x82,0x03,0x83,0x07,0x82,0x0a,0x82,0x03,0x84,0x03,0x82,0x03,0x82,0x05,0x82, -0x01,0x82,0x02,0x83,0x07,0x83,0x03,0x82,0x0c,0x83,0x07,0x83,0x03,0x82,0x06, -0x83,0x04,0x82,0x07,0x82,0x08,0x83,0x08,0x82,0x07,0x82,0x06,0x82,0x01,0x83, -0x07,0x83,0x03,0x84,0x07,0x82,0x02,0x82,0x0b,0x82,0x0b,0x82,0x10,0x82,0x0e, -0x82,0x0b,0x82,0x36,0x83,0x04,0x83,0x05,0x82,0x05,0x82,0x06,0x82,0x0d,0x82, -0x06,0x82,0x05,0x82,0x11,0x82,0x09,0x82,0x06,0x82,0x06,0x82,0x05,0x82,0x09, -0x82,0x0e,0x82,0x0a,0x82,0x02,0x82,0x0b,0x82,0x07,0x82,0x04,0x82,0x04,0x82, -0x03,0x82,0x05,0x82,0x06,0x82,0x06,0x82,0x06,0x82,0x05,0x82,0x05,0x82,0x06, -0x82,0x08,0x82,0x10,0x83,0x08,0x82,0x0b,0x82,0x06,0x82,0x07,0x82,0x01,0x82, -0x08,0x83,0x03,0x81,0x01,0x82,0x08,0x85,0x09,0x82,0x01,0x82,0x0b,0x83,0x0d, -0x82,0x0d,0x82,0x0e,0x82,0x0f,0x82,0x43,0x82,0x02,0x82,0x08,0x83,0x05,0x82, -0x08,0x81,0x03,0x81,0x04,0x81,0x02,0x82,0x05,0x84,0x16,0x82,0x0f,0x82,0x1b, -0x82,0x39,0x82,0x0a,0x83,0x05,0x82,0x09,0x83,0x0a,0x83,0x0a,0x82,0x06,0x82, -0x0b,0x83,0x07,0x82,0x05,0x82,0x06,0x82,0x05,0x82,0x08,0x82,0x0a,0x82,0x06, -0x82,0x0c,0x83,0x27,0x85,0x18,0x84,0x15,0x82,0x02,0x82,0x02,0x82,0x02,0x81, -0x05,0x82,0x06,0x82,0x04,0x82,0x07,0x82,0x04,0x82,0x07,0x82,0x04,0x82,0x06, -0x83,0x05,0x82,0x0d,0x82,0x0c,0x82,0x07,0x82,0x03,0x82,0x08,0x82,0x08,0x82, -0x0a,0x82,0x05,0x82,0x06,0x82,0x04,0x83,0x06,0x82,0x0a,0x82,0x03,0x84,0x03, -0x82,0x03,0x82,0x05,0x85,0x03,0x82,0x07,0x82,0x04,0x82,0x0d,0x82,0x05,0x81, -0x01,0x82,0x04,0x82,0x06,0x83,0x04,0x83,0x06,0x82,0x08,0x83,0x08,0x82,0x07, -0x82,0x07,0x84,0x08,0x83,0x04,0x82,0x07,0x82,0x04,0x82,0x0a,0x82,0x0a,0x83, -0x10,0x82,0x0e,0x82,0x0b,0x82,0x36,0x82,0x05,0x83,0x05,0x82,0x05,0x82,0x06, -0x83,0x05,0x82,0x05,0x82,0x06,0x82,0x05,0x83,0x10,0x82,0x09,0x83,0x05,0x82, -0x06,0x82,0x05,0x82,0x09,0x82,0x0e,0x82,0x0a,0x82,0x02,0x83,0x0a,0x82,0x07, -0x82,0x04,0x82,0x04,0x82,0x03,0x82,0x05,0x82,0x06,0x83,0x05,0x82,0x06,0x82, -0x05,0x82,0x05,0x82,0x06,0x82,0x08,0x82,0x0a,0x82,0x05,0x82,0x08,0x82,0x0b, -0x82,0x06,0x82,0x08,0x81,0x01,0x82,0x08,0x83,0x03,0x84,0x08,0x82,0x01,0x82, -0x09,0x82,0x01,0x82,0x0b,0x82,0x0e,0x82,0x0d,0x82,0x0d,0x83,0x54,0x82,0x02, -0x82,0x09,0x82,0x04,0x83,0x07,0x82,0x03,0x81,0x04,0x81,0x02,0x82,0x06,0x82, -0x18,0x82,0x0d,0x82,0x1c,0x82,0x39,0x81,0x0c,0x82,0x04,0x83,0x09,0x83,0x09, -0x83,0x0c,0x82,0x05,0x82,0x0b,0x83,0x07,0x82,0x04,0x83,0x06,0x83,0x04,0x82, -0x08,0x82,0x0a,0x83,0x05,0x82,0x0c,0x82,0x2b,0x83,0x15,0x84,0x18,0x81,0x03, -0x83,0x01,0x83,0x05,0x82,0x07,0x83,0x03,0x82,0x06,0x83,0x04,0x83,0x05,0x82, -0x05,0x82,0x06,0x82,0x06,0x82,0x0d,0x82,0x0c,0x83,0x06,0x82,0x03,0x82,0x08, -0x82,0x08,0x82,0x0a,0x82,0x05,0x82,0x06,0x82,0x05,0x83,0x05,0x82,0x0a,0x82, -0x04,0x82,0x04,0x82,0x03,0x82,0x06,0x84,0x03,0x83,0x05,0x83,0x04,0x82,0x0d, -0x83,0x05,0x83,0x04,0x82,0x06,0x83,0x05,0x82,0x06,0x82,0x08,0x83,0x08,0x83, -0x05,0x83,0x07,0x84,0x08,0x82,0x05,0x82,0x06,0x83,0x04,0x83,0x09,0x82,0x0a, -0x82,0x11,0x82,0x0e,0x82,0x0b,0x82,0x36,0x82,0x05,0x83,0x05,0x83,0x04,0x82, -0x07,0x82,0x05,0x82,0x06,0x82,0x04,0x83,0x06,0x82,0x10,0x82,0x0a,0x82,0x04, -0x83,0x06,0x82,0x05,0x82,0x09,0x82,0x0e,0x82,0x0a,0x82,0x03,0x82,0x0a,0x82, -0x07,0x82,0x04,0x82,0x04,0x82,0x03,0x82,0x05,0x82,0x07,0x82,0x04,0x83,0x06, -0x82,0x05,0x82,0x06,0x82,0x04,0x83,0x08,0x82,0x0a,0x83,0x04,0x82,0x08,0x82, -0x03,0x82,0x06,0x83,0x04,0x83,0x08,0x83,0x09,0x82,0x04,0x83,0x08,0x82,0x03, -0x82,0x09,0x83,0x0b,0x82,0x0f,0x82,0x0d,0x82,0x0d,0x83,0x38,0x82,0x1a,0x81, -0x03,0x82,0x09,0x88,0x08,0x81,0x04,0x82,0x02,0x82,0x03,0x83,0x02,0x85,0x17, -0x82,0x0d,0x82,0x29,0x82,0x1d,0x82,0x0c,0x82,0x0c,0x83,0x02,0x83,0x0a,0x83, -0x09,0x89,0x06,0x84,0x01,0x83,0x0c,0x83,0x07,0x84,0x01,0x83,0x08,0x83,0x01, -0x83,0x09,0x82,0x0b,0x84,0x01,0x83,0x07,0x82,0x02,0x84,0x09,0x82,0x0d,0x82, -0x13,0x81,0x15,0x82,0x10,0x82,0x08,0x81,0x0f,0x82,0x08,0x82,0x03,0x8a,0x06, -0x83,0x02,0x84,0x05,0x89,0x07,0x89,0x06,0x82,0x0d,0x84,0x02,0x84,0x03,0x82, -0x08,0x82,0x06,0x86,0x09,0x83,0x01,0x83,0x07,0x82,0x06,0x83,0x04,0x8a,0x02, -0x82,0x04,0x82,0x04,0x82,0x03,0x82,0x07,0x83,0x04,0x89,0x05,0x82,0x0e,0x8a, -0x04,0x82,0x07,0x82,0x05,0x84,0x02,0x83,0x09,0x83,0x09,0x84,0x01,0x84,0x08, -0x83,0x09,0x82,0x05,0x82,0x06,0x82,0x06,0x82,0x09,0x82,0x09,0x8b,0x09,0x82, -0x0f,0x82,0x0a,0x82,0x37,0x89,0x05,0x88,0x08,0x88,0x07,0x89,0x06,0x84,0x02, -0x82,0x0a,0x82,0x0a,0x89,0x06,0x82,0x05,0x82,0x06,0x88,0x0b,0x82,0x0a,0x82, -0x04,0x82,0x06,0x88,0x04,0x82,0x04,0x82,0x04,0x82,0x03,0x82,0x05,0x82,0x07, -0x84,0x01,0x83,0x07,0x84,0x01,0x83,0x07,0x83,0x02,0x84,0x08,0x82,0x0b,0x83, -0x02,0x83,0x08,0x87,0x06,0x8a,0x08,0x83,0x09,0x82,0x05,0x82,0x07,0x83,0x03, -0x83,0x08,0x83,0x0a,0x89,0x09,0x82,0x0d,0x82,0x0d,0x83,0x38,0x82,0x1a,0x81, -0x03,0x82,0x0a,0x86,0x0f,0x84,0x05,0x86,0x01,0x83,0x16,0x82,0x0d,0x82,0x29, -0x82,0x1d,0x82,0x0c,0x82,0x0d,0x86,0x0b,0x83,0x09,0x89,0x07,0x86,0x0d,0x83, -0x08,0x86,0x0a,0x85,0x0a,0x82,0x0c,0x86,0x08,0x86,0x0b,0x82,0x0d,0x82,0x3b, -0x82,0x09,0x81,0x0e,0x82,0x08,0x82,0x03,0x89,0x08,0x86,0x07,0x88,0x08,0x89, -0x06,0x82,0x0e,0x87,0x05,0x82,0x08,0x82,0x06,0x86,0x0a,0x85,0x08,0x82,0x07, -0x82,0x04,0x8a,0x02,0x82,0x0a,0x82,0x03,0x82,0x07,0x83,0x05,0x86,0x07,0x82, -0x0f,0x86,0x01,0x83,0x03,0x82,0x07,0x82,0x07,0x86,0x0a,0x83,0x0a,0x87,0x0a, -0x82,0x09,0x82,0x06,0x81,0x05,0x83,0x06,0x83,0x08,0x82,0x09,0x8b,0x09,0x82, -0x0f,0x82,0x0a,0x82,0x37,0x85,0x02,0x82,0x05,0x81,0x01,0x85,0x0b,0x85,0x09, -0x85,0x01,0x82,0x08,0x86,0x0a,0x82,0x0b,0x85,0x01,0x82,0x06,0x82,0x05,0x82, -0x06,0x88,0x0b,0x82,0x0a,0x82,0x04,0x83,0x05,0x88,0x04,0x82,0x04,0x82,0x04, -0x82,0x03,0x82,0x05,0x82,0x09,0x85,0x08,0x87,0x09,0x85,0x01,0x82,0x08,0x82, -0x0c,0x86,0x0a,0x84,0x09,0x86,0x01,0x82,0x09,0x82,0x0a,0x81,0x05,0x82,0x07, -0x82,0x05,0x82,0x08,0x83,0x0a,0x89,0x09,0x82,0x0d,0x82,0x0d,0x82,0x68,0x81, -0x3b,0x82,0x0b,0x82,0x2a,0x82,0x2a,0x82,0x7f,0x35,0x82,0x46,0x83,0x7f,0x7f, -0x08,0x82,0x7f,0x10,0x82,0x10,0x82,0x09,0x82,0x18,0x8a,0x76,0x82,0x28,0x82, -0x54,0x82,0x14,0x82,0x71,0x82,0x1d,0x82,0x0d,0x82,0x0d,0x82,0x68,0x81,0x3b, -0x82,0x0b,0x82,0x2a,0x82,0x2a,0x82,0x7f,0x35,0x82,0x48,0x86,0x7f,0x7f,0x7f, -0x15,0x84,0x0e,0x82,0x07,0x84,0x18,0x8a,0x76,0x82,0x28,0x82,0x54,0x82,0x14, -0x82,0x71,0x82,0x1d,0x83,0x0c,0x82,0x0d,0x82,0x7f,0x26,0x82,0x09,0x82,0x2b, -0x81,0x7f,0x62,0x81,0x7f,0x7f,0x7f,0x64,0x84,0x17,0x84,0x7f,0x12,0x82,0x04, -0x82,0x28,0x83,0x54,0x82,0x14,0x82,0x70,0x83,0x1e,0x83,0x0b,0x82,0x0c,0x82, -0x7f,0x28,0x82,0x07,0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x27,0x88,0x26, -0x84,0x55,0x82,0x14,0x82,0x6e,0x84,0x21,0x81,0x0b,0x82,0x0c,0x81,0x7f,0x2a, -0x81,0x07,0x81,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x2a,0x84,0x28,0x83,0x7f, -0x5d,0x83,0x64, -0x00, - } -}; diff --git a/minui21/roboto_23x41.h b/minui21/roboto_23x41.h deleted file mode 100644 index 6e7566ef..00000000 --- a/minui21/roboto_23x41.h +++ /dev/null @@ -1,461 +0,0 @@ -struct { - unsigned width; - unsigned height; - unsigned cwidth; - unsigned cheight; - unsigned char rundata[]; -} font = { - .width = 2208, - .height = 41, - .cwidth = 23, - .cheight = 41, - .rundata = { -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x7f,0x17,0x83,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x2e,0x83,0x60,0x82,0x0a,0x81,0x7f,0x7f, -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x0b,0x87,0x23,0x86,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x7f,0x05,0x83,0x5f,0x83,0x09,0x83,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x7f,0x0a,0x87,0x23,0x86,0x7f,0x7f,0x7f,0x7f,0x7f,0x39,0x82,0x26, -0x82,0x7f,0x21,0x83,0x5e,0x83,0x0b,0x83,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x09,0x87,0x23,0x86,0x40,0x84,0x27,0x83,0x37,0x83,0x27,0x86,0x20, -0x83,0x1a,0x83,0x17,0x83,0x0c,0x83,0x16,0x86,0x7f,0x7f,0x5a,0x85,0x10,0x83, -0x11,0x85,0x7f,0x1d,0x87,0x5c,0x83,0x0b,0x83,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x7f,0x09,0x83,0x2a,0x83,0x41,0x83,0x27,0x83,0x37,0x83,0x26,0x86, -0x21,0x83,0x1a,0x83,0x17,0x83,0x0c,0x83,0x16,0x86,0x7f,0x7f,0x59,0x84,0x12, -0x83,0x13,0x84,0x58,0x83,0x11,0x83,0x03,0x83,0x10,0x83,0x04,0x83,0x0a,0x8a, -0x0c,0x84,0x16,0x85,0x14,0x83,0x18,0x83,0x0d,0x83,0x7f,0x11,0x83,0x0d,0x86, -0x13,0x84,0x11,0x86,0x11,0x86,0x16,0x83,0x0d,0x8c,0x0e,0x86,0x0b,0x91,0x0c, -0x87,0x0f,0x86,0x7f,0x05,0x86,0x2a,0x83,0x0d,0x8c,0x10,0x87,0x0a,0x8c,0x0c, -0x90,0x07,0x90,0x0d,0x86,0x0a,0x83,0x0d,0x83,0x09,0x89,0x16,0x83,0x08,0x83, -0x0b,0x84,0x06,0x83,0x10,0x84,0x0e,0x84,0x03,0x83,0x0d,0x83,0x0a,0x86,0x0c, -0x8d,0x0f,0x86,0x0c,0x8c,0x10,0x87,0x09,0x94,0x04,0x83,0x0d,0x83,0x03,0x83, -0x0e,0x84,0x01,0x83,0x10,0x83,0x03,0x84,0x0b,0x84,0x03,0x84,0x0d,0x84,0x04, -0x92,0x0c,0x83,0x0e,0x83,0x19,0x83,0x14,0x83,0x2b,0x83,0x26,0x83,0x37,0x83, -0x25,0x87,0x21,0x83,0x1a,0x83,0x17,0x83,0x0c,0x83,0x19,0x83,0x7f,0x7f,0x59, -0x83,0x13,0x83,0x14,0x83,0x58,0x83,0x11,0x83,0x03,0x83,0x10,0x83,0x04,0x83, -0x09,0x8c,0x09,0x88,0x12,0x89,0x12,0x83,0x17,0x83,0x0f,0x83,0x7f,0x0f,0x83, -0x0c,0x8a,0x0e,0x87,0x0f,0x8a,0x0d,0x8a,0x13,0x84,0x0d,0x8c,0x0c,0x8a,0x09, -0x91,0x0a,0x8b,0x0b,0x8a,0x7f,0x01,0x8a,0x28,0x83,0x0d,0x8e,0x0c,0x8b,0x08, -0x8e,0x0a,0x90,0x07,0x90,0x0a,0x8c,0x07,0x83,0x0d,0x83,0x09,0x89,0x16,0x83, -0x08,0x83,0x0a,0x84,0x07,0x83,0x10,0x85,0x0d,0x84,0x03,0x84,0x0c,0x83,0x08, -0x8a,0x0a,0x8f,0x0b,0x8a,0x0a,0x8e,0x0c,0x8b,0x07,0x94,0x04,0x83,0x0d,0x83, -0x03,0x84,0x0d,0x84,0x01,0x83,0x08,0x81,0x07,0x83,0x03,0x84,0x0b,0x84,0x04, -0x84,0x0b,0x84,0x05,0x92,0x0c,0x83,0x0e,0x84,0x18,0x83,0x14,0x83,0x2b,0x84, -0x25,0x83,0x37,0x83,0x24,0x84,0x25,0x83,0x43,0x83,0x19,0x83,0x7f,0x33,0x83, -0x7f,0x22,0x84,0x13,0x83,0x14,0x83,0x58,0x83,0x11,0x83,0x03,0x83,0x10,0x83, -0x04,0x83,0x09,0x84,0x05,0x84,0x08,0x83,0x02,0x83,0x11,0x8b,0x11,0x83,0x17, -0x83,0x0f,0x83,0x7f,0x0f,0x83,0x0b,0x8c,0x0b,0x89,0x0e,0x8c,0x0b,0x8c,0x11, -0x85,0x0c,0x8d,0x0b,0x8b,0x09,0x91,0x09,0x8d,0x09,0x8c,0x7e,0x8c,0x0e,0x87, -0x11,0x85,0x0c,0x8f,0x0a,0x8e,0x06,0x8f,0x09,0x90,0x07,0x90,0x09,0x8e,0x06, -0x83,0x0d,0x83,0x0c,0x83,0x19,0x83,0x08,0x83,0x09,0x84,0x08,0x83,0x10,0x85, -0x0c,0x85,0x03,0x85,0x0b,0x83,0x06,0x8e,0x08,0x90,0x08,0x8e,0x08,0x8f,0x0a, -0x8d,0x06,0x94,0x04,0x83,0x0d,0x83,0x03,0x84,0x0d,0x83,0x02,0x83,0x08,0x81, -0x07,0x83,0x04,0x84,0x09,0x84,0x05,0x84,0x0b,0x84,0x05,0x92,0x0c,0x83,0x0f, -0x83,0x18,0x83,0x13,0x85,0x2b,0x83,0x25,0x83,0x37,0x83,0x24,0x83,0x26,0x83, -0x43,0x83,0x19,0x83,0x7f,0x33,0x83,0x7f,0x22,0x83,0x14,0x83,0x15,0x83,0x57, -0x83,0x11,0x83,0x03,0x83,0x10,0x82,0x05,0x83,0x08,0x84,0x07,0x83,0x07,0x83, -0x04,0x83,0x05,0x82,0x08,0x85,0x04,0x84,0x10,0x83,0x16,0x83,0x11,0x83,0x7f, -0x0e,0x83,0x0a,0x85,0x04,0x85,0x09,0x86,0x01,0x83,0x0d,0x84,0x05,0x84,0x0a, -0x84,0x05,0x84,0x11,0x85,0x0c,0x84,0x13,0x84,0x06,0x82,0x16,0x84,0x09,0x84, -0x05,0x84,0x08,0x85,0x04,0x85,0x7d,0x84,0x04,0x84,0x0c,0x8b,0x0f,0x85,0x0c, -0x83,0x08,0x85,0x08,0x85,0x06,0x84,0x06,0x83,0x08,0x85,0x08,0x83,0x14,0x83, -0x15,0x85,0x06,0x85,0x05,0x83,0x0d,0x83,0x0c,0x83,0x19,0x83,0x08,0x83,0x08, -0x84,0x09,0x83,0x10,0x86,0x0b,0x85,0x03,0x85,0x0b,0x83,0x05,0x85,0x06,0x85, -0x07,0x83,0x09,0x85,0x06,0x85,0x06,0x85,0x07,0x83,0x08,0x85,0x08,0x85,0x05, -0x85,0x0e,0x83,0x0c,0x83,0x0d,0x83,0x04,0x83,0x0c,0x84,0x02,0x83,0x07,0x82, -0x07,0x83,0x05,0x84,0x07,0x84,0x07,0x84,0x09,0x84,0x14,0x83,0x0d,0x83,0x0f, -0x83,0x18,0x83,0x13,0x85,0x53,0x83,0x37,0x83,0x24,0x83,0x26,0x83,0x43,0x83, -0x19,0x83,0x7f,0x33,0x83,0x7f,0x22,0x83,0x14,0x83,0x15,0x83,0x57,0x83,0x11, -0x83,0x03,0x83,0x10,0x82,0x05,0x82,0x09,0x83,0x08,0x84,0x06,0x83,0x04,0x83, -0x05,0x82,0x08,0x83,0x07,0x83,0x10,0x83,0x16,0x83,0x11,0x83,0x2c,0x83,0x5d, -0x83,0x0b,0x83,0x08,0x83,0x09,0x83,0x04,0x83,0x0d,0x83,0x07,0x84,0x08,0x84, -0x07,0x84,0x0f,0x86,0x0c,0x83,0x13,0x84,0x1e,0x84,0x09,0x84,0x07,0x84,0x07, -0x83,0x08,0x83,0x7c,0x84,0x06,0x84,0x0a,0x83,0x06,0x84,0x0e,0x86,0x0b,0x83, -0x0a,0x84,0x07,0x84,0x08,0x84,0x05,0x83,0x0a,0x84,0x07,0x83,0x14,0x83,0x15, -0x84,0x09,0x83,0x05,0x83,0x0d,0x83,0x0c,0x83,0x19,0x83,0x08,0x83,0x08,0x83, -0x0a,0x83,0x10,0x86,0x0b,0x85,0x03,0x86,0x0a,0x83,0x05,0x84,0x08,0x84,0x07, -0x83,0x0b,0x83,0x06,0x84,0x08,0x84,0x07,0x83,0x0a,0x84,0x06,0x84,0x09,0x83, -0x0e,0x83,0x0c,0x83,0x0d,0x83,0x04,0x84,0x0b,0x84,0x03,0x82,0x07,0x83,0x06, -0x82,0x06,0x84,0x07,0x84,0x08,0x83,0x09,0x84,0x13,0x84,0x0d,0x83,0x0f,0x84, -0x17,0x83,0x13,0x82,0x01,0x83,0x52,0x83,0x37,0x83,0x24,0x83,0x26,0x83,0x43, -0x83,0x19,0x83,0x7f,0x33,0x83,0x7f,0x22,0x83,0x14,0x83,0x15,0x83,0x57,0x83, -0x11,0x83,0x03,0x83,0x0f,0x83,0x04,0x83,0x09,0x83,0x09,0x83,0x06,0x83,0x04, -0x83,0x04,0x82,0x09,0x83,0x07,0x83,0x10,0x83,0x15,0x83,0x13,0x83,0x2b,0x83, -0x5d,0x83,0x0b,0x83,0x08,0x83,0x10,0x83,0x0c,0x83,0x09,0x83,0x08,0x83,0x09, -0x83,0x0f,0x86,0x0c,0x83,0x13,0x83,0x1e,0x84,0x0a,0x83,0x09,0x83,0x06,0x84, -0x08,0x83,0x7c,0x83,0x08,0x83,0x09,0x83,0x09,0x83,0x0c,0x87,0x0b,0x83,0x0b, -0x83,0x06,0x84,0x0a,0x84,0x04,0x83,0x0b,0x84,0x06,0x83,0x14,0x83,0x14,0x84, -0x0a,0x84,0x04,0x83,0x0d,0x83,0x0c,0x83,0x19,0x83,0x08,0x83,0x07,0x84,0x0a, -0x83,0x10,0x86,0x0a,0x86,0x03,0x87,0x09,0x83,0x04,0x84,0x0a,0x84,0x06,0x83, -0x0b,0x84,0x04,0x84,0x0a,0x84,0x06,0x83,0x0b,0x83,0x06,0x83,0x0a,0x84,0x0d, -0x83,0x0c,0x83,0x0d,0x83,0x04,0x84,0x0b,0x83,0x04,0x83,0x06,0x83,0x06,0x82, -0x07,0x84,0x05,0x84,0x09,0x84,0x07,0x84,0x13,0x84,0x0e,0x83,0x10,0x83,0x17, -0x83,0x12,0x83,0x01,0x83,0x52,0x83,0x37,0x83,0x24,0x83,0x26,0x83,0x43,0x83, -0x19,0x83,0x7f,0x33,0x83,0x7f,0x22,0x83,0x14,0x83,0x15,0x83,0x57,0x83,0x11, -0x82,0x04,0x82,0x10,0x83,0x04,0x83,0x09,0x83,0x09,0x83,0x06,0x83,0x04,0x83, -0x04,0x82,0x09,0x83,0x07,0x83,0x10,0x82,0x16,0x83,0x13,0x83,0x14,0x83,0x14, -0x83,0x5d,0x82,0x0b,0x83,0x0a,0x83,0x0f,0x83,0x0c,0x83,0x09,0x83,0x08,0x83, -0x09,0x83,0x0e,0x83,0x01,0x83,0x0c,0x83,0x13,0x83,0x1e,0x83,0x0b,0x83,0x09, -0x83,0x06,0x83,0x0a,0x83,0x0d,0x83,0x14,0x83,0x5f,0x83,0x08,0x83,0x0b,0x82, -0x0c,0x83,0x01,0x83,0x0b,0x83,0x0b,0x83,0x06,0x83,0x0c,0x83,0x04,0x83,0x0c, -0x83,0x06,0x83,0x14,0x83,0x14,0x83,0x0c,0x83,0x04,0x83,0x0d,0x83,0x0c,0x83, -0x19,0x83,0x08,0x83,0x06,0x84,0x0b,0x83,0x10,0x87,0x09,0x86,0x03,0x87,0x09, -0x83,0x04,0x83,0x0c,0x83,0x06,0x83,0x0c,0x83,0x04,0x83,0x0c,0x83,0x06,0x83, -0x0b,0x83,0x06,0x83,0x0b,0x83,0x0d,0x83,0x0c,0x83,0x0d,0x83,0x05,0x83,0x0a, -0x84,0x04,0x83,0x06,0x83,0x05,0x83,0x07,0x84,0x05,0x84,0x0a,0x83,0x07,0x84, -0x13,0x83,0x0f,0x83,0x10,0x83,0x17,0x83,0x12,0x83,0x01,0x83,0x40,0x86,0x0c, -0x83,0x03,0x85,0x11,0x86,0x10,0x85,0x03,0x83,0x0d,0x85,0x0f,0x8a,0x0f,0x85, -0x04,0x82,0x08,0x83,0x03,0x85,0x0f,0x86,0x17,0x83,0x0c,0x83,0x07,0x84,0x0e, -0x83,0x0a,0x83,0x02,0x83,0x07,0x83,0x09,0x83,0x03,0x85,0x10,0x86,0x0d,0x82, -0x04,0x85,0x10,0x85,0x04,0x82,0x09,0x83,0x02,0x85,0x11,0x86,0x0c,0x8d,0x0a, -0x83,0x09,0x83,0x08,0x84,0x09,0x83,0x03,0x84,0x0f,0x83,0x05,0x84,0x08,0x84, -0x07,0x83,0x0a,0x83,0x07,0x8f,0x0e,0x83,0x14,0x83,0x15,0x83,0x57,0x83,0x11, -0x82,0x04,0x82,0x0b,0x92,0x06,0x83,0x12,0x83,0x04,0x83,0x03,0x82,0x0a,0x83, -0x06,0x84,0x10,0x82,0x16,0x83,0x13,0x83,0x14,0x83,0x14,0x83,0x5c,0x83,0x0b, -0x83,0x0a,0x83,0x0f,0x83,0x0c,0x83,0x09,0x83,0x14,0x83,0x0d,0x84,0x01,0x83, -0x0c,0x83,0x12,0x83,0x1e,0x83,0x0c,0x83,0x09,0x83,0x06,0x83,0x0a,0x83,0x0d, -0x83,0x14,0x83,0x5f,0x83,0x07,0x83,0x0d,0x82,0x0b,0x83,0x01,0x84,0x0a,0x83, -0x0b,0x83,0x05,0x84,0x0c,0x83,0x04,0x83,0x0c,0x83,0x06,0x83,0x14,0x83,0x13, -0x83,0x0d,0x83,0x04,0x83,0x0d,0x83,0x0c,0x83,0x19,0x83,0x08,0x83,0x05,0x84, -0x0c,0x83,0x10,0x83,0x01,0x83,0x08,0x83,0x01,0x83,0x03,0x83,0x01,0x84,0x08, -0x83,0x03,0x84,0x0c,0x84,0x05,0x83,0x0c,0x83,0x03,0x84,0x0c,0x84,0x05,0x83, -0x0b,0x83,0x06,0x83,0x0b,0x83,0x0d,0x83,0x0c,0x83,0x0d,0x83,0x05,0x84,0x09, -0x84,0x04,0x83,0x06,0x83,0x05,0x83,0x08,0x84,0x03,0x84,0x0b,0x84,0x05,0x84, -0x13,0x84,0x0f,0x83,0x10,0x84,0x16,0x83,0x11,0x83,0x03,0x83,0x3d,0x8a,0x0a, -0x83,0x01,0x89,0x0d,0x89,0x0d,0x89,0x01,0x83,0x0b,0x89,0x0d,0x8a,0x0d,0x89, -0x01,0x83,0x08,0x83,0x01,0x89,0x0d,0x86,0x17,0x83,0x0c,0x83,0x06,0x84,0x0f, -0x83,0x0a,0x83,0x01,0x86,0x03,0x87,0x07,0x83,0x01,0x89,0x0d,0x89,0x0b,0x83, -0x01,0x89,0x0c,0x89,0x01,0x83,0x09,0x83,0x01,0x88,0x0d,0x8a,0x0a,0x8d,0x0a, -0x83,0x09,0x83,0x08,0x84,0x09,0x83,0x03,0x84,0x06,0x82,0x06,0x84,0x06,0x84, -0x06,0x84,0x08,0x84,0x08,0x84,0x07,0x8f,0x0e,0x83,0x14,0x83,0x15,0x83,0x57, -0x83,0x11,0x82,0x04,0x82,0x0b,0x92,0x06,0x84,0x12,0x83,0x02,0x83,0x03,0x83, -0x0a,0x84,0x04,0x84,0x11,0x82,0x16,0x83,0x13,0x83,0x14,0x83,0x14,0x83,0x5c, -0x83,0x0b,0x83,0x0a,0x83,0x0f,0x83,0x18,0x83,0x13,0x84,0x0d,0x83,0x02,0x83, -0x0c,0x83,0x12,0x83,0x1d,0x84,0x0c,0x84,0x07,0x84,0x06,0x83,0x0a,0x83,0x0d, -0x83,0x14,0x83,0x1a,0x82,0x0a,0x8f,0x08,0x81,0x21,0x83,0x07,0x82,0x06,0x84, -0x04,0x83,0x09,0x83,0x03,0x83,0x0a,0x83,0x0b,0x83,0x05,0x83,0x0d,0x83,0x04, -0x83,0x0d,0x83,0x05,0x83,0x14,0x83,0x13,0x83,0x14,0x83,0x0d,0x83,0x0c,0x83, -0x19,0x83,0x08,0x83,0x04,0x84,0x0d,0x83,0x10,0x83,0x01,0x84,0x07,0x83,0x01, -0x83,0x03,0x83,0x01,0x85,0x07,0x83,0x03,0x83,0x0e,0x83,0x05,0x83,0x0c,0x83, -0x03,0x83,0x0e,0x83,0x05,0x83,0x0b,0x83,0x06,0x83,0x1b,0x83,0x0c,0x83,0x0d, -0x83,0x05,0x84,0x09,0x83,0x06,0x82,0x06,0x83,0x05,0x82,0x0a,0x83,0x02,0x84, -0x0d,0x83,0x05,0x83,0x13,0x84,0x10,0x83,0x11,0x83,0x16,0x83,0x11,0x83,0x03, -0x83,0x3c,0x8c,0x09,0x8e,0x0b,0x8b,0x0b,0x8e,0x0a,0x8b,0x0c,0x8a,0x0c,0x8e, -0x08,0x8e,0x0f,0x83,0x17,0x83,0x0c,0x83,0x06,0x84,0x0f,0x83,0x0a,0x8b,0x01, -0x89,0x06,0x8e,0x0a,0x8c,0x0a,0x8e,0x0a,0x8e,0x09,0x8d,0x0b,0x8c,0x09,0x8d, -0x0a,0x83,0x09,0x83,0x08,0x84,0x08,0x84,0x03,0x84,0x05,0x83,0x06,0x84,0x06, -0x84,0x06,0x83,0x09,0x84,0x08,0x84,0x07,0x8f,0x0e,0x83,0x14,0x83,0x15,0x83, -0x57,0x83,0x24,0x92,0x07,0x83,0x12,0x88,0x03,0x82,0x0c,0x83,0x03,0x84,0x29, -0x83,0x15,0x83,0x0f,0x81,0x03,0x83,0x03,0x81,0x10,0x83,0x5b,0x83,0x0c,0x83, -0x0a,0x83,0x0f,0x83,0x17,0x83,0x13,0x84,0x0d,0x83,0x03,0x83,0x0c,0x83,0x01, -0x85,0x0c,0x83,0x03,0x85,0x15,0x83,0x0e,0x84,0x05,0x84,0x07,0x83,0x0a,0x83, -0x3f,0x84,0x0a,0x8f,0x08,0x83,0x1e,0x83,0x07,0x82,0x06,0x86,0x04,0x82,0x09, -0x83,0x03,0x83,0x0a,0x83,0x0a,0x83,0x06,0x83,0x14,0x83,0x0d,0x83,0x05,0x83, -0x14,0x83,0x13,0x83,0x14,0x83,0x0d,0x83,0x0c,0x83,0x19,0x83,0x08,0x83,0x03, -0x84,0x0e,0x83,0x10,0x83,0x02,0x83,0x06,0x84,0x01,0x83,0x03,0x83,0x02,0x84, -0x07,0x83,0x03,0x83,0x0e,0x83,0x05,0x83,0x0c,0x83,0x03,0x83,0x0e,0x83,0x05, -0x83,0x0b,0x83,0x07,0x83,0x1a,0x83,0x0c,0x83,0x0d,0x83,0x06,0x83,0x08,0x84, -0x06,0x83,0x04,0x85,0x04,0x82,0x0a,0x84,0x01,0x84,0x0d,0x84,0x03,0x84,0x12, -0x84,0x11,0x83,0x11,0x84,0x15,0x83,0x11,0x83,0x03,0x84,0x3b,0x84,0x04,0x84, -0x09,0x85,0x05,0x84,0x0b,0x84,0x04,0x84,0x0a,0x84,0x05,0x85,0x09,0x84,0x05, -0x84,0x0e,0x83,0x10,0x84,0x05,0x85,0x08,0x85,0x05,0x84,0x0f,0x83,0x17,0x83, -0x0c,0x83,0x05,0x84,0x10,0x83,0x0a,0x85,0x02,0x84,0x01,0x83,0x02,0x84,0x06, -0x85,0x05,0x84,0x0a,0x84,0x05,0x84,0x09,0x85,0x05,0x84,0x0a,0x84,0x05,0x85, -0x09,0x85,0x05,0x84,0x09,0x84,0x05,0x84,0x0c,0x83,0x11,0x83,0x09,0x83,0x09, -0x83,0x08,0x83,0x05,0x83,0x05,0x83,0x06,0x83,0x08,0x84,0x04,0x84,0x0a,0x83, -0x08,0x83,0x12,0x84,0x0f,0x83,0x14,0x83,0x15,0x83,0x57,0x83,0x28,0x83,0x05, -0x82,0x0b,0x85,0x12,0x84,0x04,0x82,0x0d,0x89,0x2a,0x83,0x15,0x83,0x0e,0x88, -0x01,0x83,0x10,0x83,0x5b,0x83,0x0c,0x83,0x0a,0x83,0x0f,0x83,0x17,0x83,0x0e, -0x88,0x0e,0x83,0x03,0x83,0x0c,0x8b,0x0a,0x83,0x01,0x89,0x12,0x83,0x10,0x8b, -0x08,0x83,0x0a,0x83,0x3c,0x87,0x0a,0x8f,0x08,0x86,0x1a,0x84,0x07,0x82,0x05, -0x83,0x02,0x82,0x04,0x82,0x08,0x84,0x03,0x84,0x09,0x83,0x09,0x84,0x06,0x83, -0x14,0x83,0x0d,0x83,0x05,0x83,0x14,0x83,0x13,0x83,0x14,0x83,0x0d,0x83,0x0c, -0x83,0x19,0x83,0x08,0x83,0x02,0x84,0x0f,0x83,0x10,0x83,0x02,0x83,0x06,0x83, -0x02,0x83,0x03,0x83,0x03,0x84,0x06,0x83,0x03,0x83,0x0e,0x83,0x05,0x83,0x0b, -0x84,0x03,0x83,0x0e,0x83,0x05,0x83,0x0a,0x83,0x08,0x84,0x19,0x83,0x0c,0x83, -0x0d,0x83,0x06,0x84,0x07,0x84,0x06,0x83,0x04,0x85,0x03,0x83,0x0b,0x87,0x0f, -0x83,0x03,0x83,0x13,0x84,0x11,0x83,0x12,0x83,0x15,0x83,0x10,0x83,0x05,0x83, -0x3a,0x83,0x07,0x84,0x08,0x84,0x07,0x84,0x09,0x84,0x06,0x84,0x08,0x84,0x07, -0x84,0x08,0x84,0x07,0x83,0x0e,0x83,0x0f,0x84,0x07,0x84,0x08,0x84,0x07,0x84, -0x0e,0x83,0x17,0x83,0x0c,0x83,0x04,0x84,0x11,0x83,0x0a,0x84,0x04,0x85,0x05, -0x84,0x05,0x84,0x07,0x84,0x08,0x84,0x07,0x84,0x08,0x84,0x07,0x84,0x08,0x84, -0x07,0x84,0x09,0x84,0x08,0x82,0x09,0x83,0x07,0x84,0x0b,0x83,0x11,0x83,0x09, -0x83,0x09,0x84,0x07,0x83,0x05,0x83,0x05,0x83,0x06,0x83,0x09,0x83,0x04,0x83, -0x0b,0x84,0x06,0x84,0x12,0x84,0x0f,0x83,0x14,0x83,0x15,0x83,0x57,0x83,0x28, -0x83,0x04,0x83,0x0c,0x86,0x17,0x83,0x0e,0x86,0x2c,0x83,0x15,0x83,0x0e,0x8d, -0x0f,0x83,0x5b,0x82,0x0d,0x83,0x0a,0x83,0x0f,0x83,0x16,0x83,0x0f,0x87,0x0e, -0x83,0x04,0x83,0x0c,0x8c,0x09,0x8e,0x11,0x83,0x12,0x87,0x0a,0x84,0x09,0x83, -0x3a,0x88,0x22,0x88,0x18,0x83,0x08,0x82,0x04,0x83,0x03,0x82,0x04,0x83,0x07, -0x83,0x05,0x83,0x09,0x8f,0x07,0x83,0x14,0x83,0x0d,0x83,0x05,0x8e,0x09,0x8f, -0x07,0x83,0x14,0x93,0x0c,0x83,0x19,0x83,0x08,0x88,0x10,0x83,0x10,0x83,0x02, -0x84,0x05,0x83,0x02,0x83,0x03,0x83,0x03,0x85,0x05,0x83,0x03,0x83,0x0e,0x83, -0x05,0x83,0x0b,0x83,0x04,0x83,0x0e,0x83,0x05,0x83,0x09,0x84,0x09,0x86,0x16, -0x83,0x0c,0x83,0x0d,0x83,0x07,0x83,0x07,0x83,0x07,0x83,0x04,0x82,0x01,0x82, -0x03,0x83,0x0c,0x85,0x10,0x84,0x01,0x84,0x12,0x84,0x12,0x83,0x12,0x83,0x15, -0x83,0x10,0x83,0x05,0x83,0x3a,0x83,0x08,0x83,0x08,0x83,0x09,0x83,0x09,0x83, -0x08,0x83,0x08,0x83,0x09,0x83,0x08,0x83,0x09,0x83,0x0d,0x83,0x0f,0x83,0x09, -0x83,0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c,0x83,0x04,0x84,0x11,0x83, -0x0a,0x83,0x06,0x84,0x06,0x83,0x05,0x83,0x09,0x83,0x08,0x83,0x09,0x83,0x08, -0x83,0x09,0x83,0x08,0x83,0x09,0x83,0x09,0x83,0x14,0x83,0x08,0x83,0x0b,0x83, -0x11,0x83,0x09,0x83,0x0a,0x83,0x06,0x84,0x05,0x84,0x04,0x84,0x05,0x83,0x09, -0x84,0x02,0x84,0x0b,0x84,0x06,0x84,0x11,0x84,0x0f,0x83,0x15,0x83,0x16,0x83, -0x56,0x83,0x28,0x83,0x04,0x83,0x0d,0x88,0x14,0x82,0x0f,0x85,0x2d,0x83,0x15, -0x83,0x11,0x88,0x0a,0x92,0x52,0x83,0x0d,0x83,0x0a,0x83,0x0f,0x83,0x15,0x84, -0x0f,0x89,0x0b,0x83,0x05,0x83,0x0b,0x85,0x04,0x85,0x08,0x85,0x05,0x85,0x0f, -0x83,0x11,0x8b,0x09,0x83,0x08,0x84,0x38,0x88,0x26,0x88,0x15,0x83,0x08,0x82, -0x05,0x83,0x03,0x82,0x05,0x82,0x07,0x83,0x05,0x83,0x09,0x8f,0x07,0x83,0x14, -0x83,0x0d,0x83,0x05,0x8e,0x09,0x8f,0x07,0x83,0x07,0x89,0x04,0x93,0x0c,0x83, -0x19,0x83,0x08,0x88,0x10,0x83,0x10,0x83,0x03,0x83,0x04,0x83,0x03,0x83,0x03, -0x83,0x04,0x84,0x05,0x83,0x03,0x83,0x0e,0x83,0x05,0x83,0x09,0x85,0x04,0x83, -0x0e,0x83,0x05,0x8f,0x0c,0x87,0x13,0x83,0x0c,0x83,0x0d,0x83,0x07,0x83,0x06, -0x84,0x08,0x82,0x04,0x82,0x01,0x83,0x02,0x82,0x0d,0x85,0x11,0x83,0x01,0x83, -0x12,0x84,0x13,0x83,0x12,0x84,0x14,0x83,0x0f,0x84,0x06,0x83,0x44,0x83,0x08, -0x83,0x09,0x84,0x07,0x83,0x09,0x83,0x07,0x84,0x09,0x83,0x07,0x83,0x0a,0x83, -0x0d,0x83,0x0e,0x84,0x09,0x83,0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c, -0x83,0x03,0x84,0x12,0x83,0x0a,0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83, -0x07,0x84,0x09,0x84,0x07,0x83,0x09,0x84,0x06,0x84,0x09,0x83,0x09,0x83,0x14, -0x83,0x16,0x83,0x11,0x83,0x09,0x83,0x0a,0x83,0x06,0x83,0x06,0x84,0x03,0x85, -0x04,0x83,0x0b,0x88,0x0d,0x83,0x06,0x83,0x11,0x84,0x0f,0x84,0x15,0x83,0x16, -0x84,0x0c,0x85,0x44,0x83,0x28,0x82,0x05,0x83,0x0e,0x88,0x12,0x82,0x0f,0x87, -0x2c,0x83,0x15,0x83,0x12,0x85,0x0c,0x92,0x1f,0x8d,0x26,0x83,0x0d,0x83,0x0a, -0x83,0x0f,0x83,0x15,0x83,0x16,0x84,0x0a,0x83,0x05,0x83,0x0b,0x84,0x07,0x83, -0x08,0x84,0x08,0x83,0x0f,0x83,0x10,0x84,0x04,0x85,0x08,0x85,0x04,0x86,0x36, -0x87,0x2c,0x87,0x12,0x83,0x09,0x82,0x04,0x83,0x04,0x82,0x05,0x82,0x06,0x83, -0x06,0x84,0x08,0x90,0x06,0x83,0x14,0x83,0x0d,0x83,0x05,0x8e,0x09,0x8f,0x07, -0x83,0x07,0x89,0x04,0x93,0x0c,0x83,0x19,0x83,0x08,0x89,0x0f,0x83,0x10,0x83, -0x03,0x84,0x03,0x83,0x03,0x83,0x03,0x83,0x05,0x84,0x04,0x83,0x03,0x83,0x0e, -0x83,0x05,0x90,0x05,0x83,0x0e,0x83,0x05,0x8e,0x0f,0x87,0x11,0x83,0x0c,0x83, -0x0d,0x83,0x07,0x84,0x05,0x83,0x09,0x83,0x02,0x83,0x02,0x82,0x02,0x82,0x0d, -0x85,0x11,0x87,0x12,0x84,0x13,0x83,0x13,0x83,0x14,0x83,0x60,0x83,0x08,0x83, -0x0a,0x83,0x07,0x83,0x13,0x83,0x0a,0x83,0x07,0x83,0x0a,0x83,0x0d,0x83,0x0e, -0x83,0x0a,0x83,0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c,0x83,0x02,0x84, -0x13,0x83,0x0a,0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83,0x07,0x83,0x0b, -0x83,0x07,0x83,0x0a,0x83,0x06,0x83,0x0a,0x83,0x09,0x83,0x14,0x84,0x15,0x83, -0x11,0x83,0x09,0x83,0x0a,0x84,0x05,0x83,0x07,0x83,0x03,0x85,0x04,0x83,0x0c, -0x86,0x0e,0x84,0x05,0x83,0x10,0x84,0x0f,0x84,0x16,0x83,0x17,0x85,0x09,0x88, -0x07,0x83,0x38,0x83,0x28,0x82,0x05,0x82,0x12,0x86,0x11,0x82,0x03,0x84,0x07, -0x84,0x01,0x84,0x06,0x83,0x22,0x83,0x15,0x83,0x11,0x87,0x0b,0x92,0x1f,0x8d, -0x26,0x82,0x0e,0x83,0x0a,0x83,0x0f,0x83,0x14,0x83,0x18,0x83,0x09,0x83,0x06, -0x83,0x16,0x84,0x07,0x83,0x09,0x84,0x0d,0x83,0x10,0x83,0x08,0x83,0x09,0x8e, -0x34,0x87,0x30,0x87,0x0f,0x83,0x0a,0x82,0x04,0x83,0x04,0x82,0x05,0x82,0x06, -0x83,0x07,0x83,0x08,0x83,0x09,0x85,0x05,0x83,0x14,0x83,0x0d,0x83,0x05,0x83, -0x14,0x83,0x13,0x83,0x07,0x89,0x04,0x83,0x0d,0x83,0x0c,0x83,0x19,0x83,0x08, -0x83,0x03,0x84,0x0e,0x83,0x10,0x83,0x04,0x83,0x02,0x84,0x03,0x83,0x03,0x83, -0x05,0x85,0x03,0x83,0x03,0x83,0x0e,0x83,0x05,0x8f,0x06,0x83,0x0e,0x83,0x05, -0x8f,0x11,0x86,0x0f,0x83,0x0c,0x83,0x0d,0x83,0x08,0x83,0x05,0x83,0x09,0x83, -0x02,0x82,0x03,0x82,0x01,0x83,0x0d,0x86,0x11,0x85,0x12,0x84,0x14,0x83,0x13, -0x83,0x14,0x83,0x59,0x8a,0x08,0x83,0x0a,0x83,0x07,0x83,0x13,0x83,0x0a,0x83, -0x07,0x90,0x0d,0x83,0x0e,0x83,0x0a,0x83,0x08,0x83,0x09,0x83,0x0e,0x83,0x17, -0x83,0x0c,0x88,0x14,0x83,0x0a,0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83, -0x07,0x83,0x0b,0x83,0x07,0x83,0x0a,0x83,0x06,0x83,0x0a,0x83,0x09,0x83,0x15, -0x85,0x13,0x83,0x11,0x83,0x09,0x83,0x0b,0x83,0x04,0x84,0x07,0x83,0x03,0x86, -0x03,0x83,0x0c,0x86,0x0f,0x83,0x04,0x84,0x10,0x84,0x0f,0x83,0x17,0x83,0x18, -0x84,0x08,0x8a,0x06,0x83,0x38,0x83,0x27,0x83,0x05,0x82,0x14,0x85,0x0f,0x82, -0x03,0x86,0x05,0x84,0x03,0x84,0x05,0x83,0x22,0x83,0x15,0x83,0x10,0x84,0x01, -0x83,0x12,0x83,0x27,0x8d,0x25,0x83,0x0e,0x83,0x0a,0x83,0x0f,0x83,0x13,0x83, -0x1a,0x83,0x07,0x84,0x06,0x83,0x17,0x83,0x07,0x83,0x0a,0x83,0x0d,0x83,0x0f, -0x84,0x08,0x84,0x09,0x89,0x01,0x83,0x34,0x85,0x35,0x85,0x0d,0x84,0x0a,0x82, -0x04,0x83,0x04,0x82,0x05,0x82,0x06,0x83,0x07,0x83,0x08,0x83,0x0b,0x83,0x05, -0x83,0x14,0x83,0x0d,0x83,0x05,0x83,0x14,0x83,0x13,0x83,0x0d,0x83,0x04,0x83, -0x0d,0x83,0x0c,0x83,0x19,0x83,0x08,0x83,0x03,0x85,0x0d,0x83,0x10,0x83,0x04, -0x84,0x01,0x83,0x04,0x83,0x03,0x83,0x06,0x84,0x03,0x83,0x03,0x83,0x0e,0x83, -0x05,0x8d,0x08,0x83,0x0e,0x83,0x05,0x83,0x09,0x84,0x13,0x84,0x0e,0x83,0x0c, -0x83,0x0d,0x83,0x08,0x83,0x04,0x84,0x09,0x83,0x02,0x82,0x03,0x82,0x01,0x83, -0x0c,0x87,0x11,0x85,0x11,0x84,0x15,0x83,0x13,0x84,0x13,0x83,0x56,0x8d,0x08, -0x83,0x0a,0x83,0x07,0x83,0x13,0x83,0x0a,0x83,0x07,0x90,0x0d,0x83,0x0e,0x83, -0x0a,0x83,0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c,0x88,0x14,0x83,0x0a, -0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83,0x07,0x83,0x0b,0x83,0x07,0x83, -0x0a,0x83,0x06,0x83,0x0a,0x83,0x09,0x83,0x16,0x88,0x0f,0x83,0x11,0x83,0x09, -0x83,0x0b,0x83,0x04,0x83,0x08,0x84,0x01,0x83,0x01,0x83,0x03,0x83,0x0d,0x84, -0x10,0x83,0x04,0x83,0x10,0x84,0x10,0x84,0x16,0x83,0x17,0x85,0x07,0x84,0x04, -0x84,0x04,0x84,0x38,0x83,0x23,0x92,0x12,0x84,0x0d,0x83,0x02,0x83,0x02,0x83, -0x03,0x84,0x05,0x84,0x04,0x83,0x22,0x83,0x15,0x83,0x10,0x83,0x03,0x83,0x11, -0x83,0x59,0x82,0x0f,0x83,0x0a,0x83,0x0f,0x83,0x12,0x84,0x1a,0x83,0x07,0x83, -0x07,0x83,0x17,0x83,0x07,0x83,0x0a,0x83,0x0d,0x83,0x0f,0x83,0x0a,0x83,0x0b, -0x85,0x03,0x83,0x34,0x85,0x14,0x8f,0x13,0x84,0x0d,0x83,0x0b,0x82,0x04,0x83, -0x04,0x82,0x05,0x82,0x05,0x8f,0x07,0x83,0x0c,0x83,0x04,0x83,0x14,0x83,0x0d, -0x83,0x05,0x83,0x14,0x83,0x13,0x83,0x0d,0x83,0x04,0x83,0x0d,0x83,0x0c,0x83, -0x19,0x83,0x08,0x83,0x04,0x85,0x0c,0x83,0x10,0x83,0x04,0x84,0x01,0x83,0x04, -0x83,0x03,0x83,0x07,0x84,0x02,0x83,0x03,0x83,0x0e,0x83,0x05,0x83,0x12,0x83, -0x0e,0x83,0x05,0x83,0x0a,0x84,0x13,0x83,0x0e,0x83,0x0c,0x83,0x0d,0x83,0x08, -0x84,0x03,0x83,0x0a,0x83,0x01,0x83,0x03,0x82,0x01,0x83,0x0b,0x84,0x01,0x84, -0x11,0x83,0x12,0x83,0x16,0x83,0x14,0x83,0x13,0x83,0x55,0x8e,0x08,0x83,0x0a, -0x83,0x07,0x83,0x13,0x83,0x0a,0x83,0x07,0x90,0x0d,0x83,0x0e,0x83,0x0a,0x83, -0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c,0x88,0x14,0x83,0x0a,0x83,0x06, -0x83,0x07,0x83,0x05,0x83,0x09,0x83,0x07,0x83,0x0b,0x83,0x07,0x83,0x0a,0x83, -0x06,0x83,0x0a,0x83,0x09,0x83,0x19,0x87,0x0d,0x83,0x11,0x83,0x09,0x83,0x0b, -0x84,0x03,0x83,0x09,0x83,0x01,0x83,0x01,0x83,0x02,0x83,0x0e,0x84,0x10,0x84, -0x03,0x83,0x0f,0x84,0x12,0x84,0x15,0x83,0x16,0x84,0x09,0x83,0x06,0x8a,0x39, -0x83,0x23,0x92,0x12,0x84,0x0d,0x82,0x02,0x83,0x04,0x83,0x02,0x83,0x07,0x84, -0x02,0x84,0x22,0x83,0x15,0x83,0x11,0x81,0x04,0x82,0x12,0x83,0x58,0x83,0x0f, -0x83,0x0a,0x83,0x0f,0x83,0x11,0x84,0x1b,0x83,0x06,0x92,0x13,0x83,0x07,0x83, -0x0a,0x83,0x0d,0x83,0x0f,0x83,0x0a,0x83,0x13,0x83,0x35,0x87,0x11,0x8f,0x10, -0x87,0x0d,0x83,0x0b,0x82,0x04,0x82,0x05,0x82,0x05,0x82,0x05,0x8f,0x07,0x83, -0x0c,0x83,0x04,0x83,0x0d,0x83,0x04,0x83,0x0d,0x83,0x05,0x83,0x14,0x83,0x13, -0x83,0x0d,0x83,0x04,0x83,0x0d,0x83,0x0c,0x83,0x19,0x83,0x08,0x83,0x05,0x84, -0x0c,0x83,0x10,0x83,0x05,0x86,0x05,0x83,0x03,0x83,0x07,0x85,0x01,0x83,0x03, -0x83,0x0e,0x83,0x05,0x83,0x12,0x83,0x0e,0x83,0x05,0x83,0x0b,0x83,0x14,0x83, -0x0d,0x83,0x0c,0x83,0x0d,0x83,0x09,0x83,0x03,0x83,0x0b,0x82,0x01,0x82,0x04, -0x86,0x0b,0x83,0x02,0x84,0x11,0x83,0x11,0x84,0x16,0x83,0x14,0x84,0x12,0x83, -0x55,0x84,0x07,0x83,0x08,0x83,0x0a,0x83,0x07,0x83,0x13,0x83,0x0a,0x83,0x07, -0x83,0x1a,0x83,0x0e,0x83,0x0a,0x83,0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83, -0x0c,0x83,0x02,0x84,0x13,0x83,0x0a,0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09, -0x83,0x07,0x83,0x0b,0x83,0x07,0x83,0x0a,0x83,0x06,0x83,0x0a,0x83,0x09,0x83, -0x1c,0x85,0x0c,0x83,0x11,0x83,0x09,0x83,0x0c,0x83,0x02,0x84,0x09,0x83,0x01, -0x83,0x01,0x83,0x02,0x83,0x0d,0x86,0x10,0x83,0x02,0x84,0x0e,0x84,0x14,0x83, -0x15,0x83,0x16,0x83,0x0a,0x83,0x07,0x88,0x60,0x92,0x13,0x83,0x0c,0x82,0x03, -0x83,0x04,0x83,0x02,0x83,0x07,0x85,0x01,0x83,0x23,0x83,0x15,0x83,0x2a,0x83, -0x58,0x83,0x0f,0x83,0x0a,0x83,0x0f,0x83,0x10,0x84,0x0f,0x83,0x0a,0x83,0x06, -0x92,0x13,0x83,0x07,0x83,0x0a,0x83,0x0c,0x83,0x10,0x83,0x0a,0x83,0x13,0x83, -0x37,0x87,0x0f,0x8f,0x0e,0x87,0x0f,0x83,0x0b,0x82,0x04,0x82,0x05,0x82,0x05, -0x82,0x05,0x8f,0x07,0x83,0x0c,0x83,0x04,0x84,0x0c,0x83,0x04,0x83,0x0c,0x84, -0x05,0x83,0x14,0x83,0x13,0x84,0x0c,0x83,0x04,0x83,0x0d,0x83,0x0c,0x83,0x0d, -0x83,0x09,0x83,0x08,0x83,0x06,0x84,0x0b,0x83,0x10,0x83,0x05,0x86,0x05,0x83, -0x03,0x83,0x08,0x84,0x01,0x83,0x03,0x84,0x0c,0x84,0x05,0x83,0x12,0x84,0x0c, -0x84,0x05,0x83,0x0b,0x83,0x05,0x83,0x0c,0x83,0x0d,0x83,0x0c,0x83,0x0d,0x83, -0x09,0x84,0x01,0x84,0x0b,0x82,0x01,0x82,0x05,0x84,0x0b,0x84,0x03,0x84,0x10, -0x83,0x10,0x84,0x17,0x83,0x15,0x83,0x12,0x83,0x54,0x84,0x08,0x83,0x08,0x83, -0x0a,0x83,0x07,0x83,0x13,0x83,0x0a,0x83,0x07,0x83,0x1a,0x83,0x0e,0x83,0x0a, -0x83,0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c,0x83,0x03,0x84,0x12,0x83, -0x0a,0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83,0x07,0x83,0x0b,0x83,0x07, -0x83,0x0a,0x83,0x06,0x83,0x0a,0x83,0x09,0x83,0x1e,0x84,0x0b,0x83,0x11,0x83, -0x09,0x83,0x0c,0x83,0x02,0x83,0x0a,0x83,0x01,0x82,0x03,0x83,0x01,0x83,0x0d, -0x87,0x0f,0x83,0x02,0x83,0x0f,0x83,0x16,0x83,0x14,0x83,0x15,0x83,0x17,0x85, -0x65,0x82,0x05,0x83,0x0a,0x83,0x0a,0x83,0x0c,0x82,0x03,0x83,0x04,0x83,0x02, -0x83,0x08,0x88,0x23,0x83,0x15,0x83,0x2a,0x83,0x58,0x82,0x10,0x83,0x0a,0x83, -0x0f,0x83,0x0f,0x84,0x10,0x83,0x0a,0x83,0x06,0x92,0x07,0x83,0x09,0x83,0x07, -0x84,0x09,0x83,0x0c,0x83,0x10,0x83,0x0a,0x83,0x12,0x84,0x39,0x87,0x27,0x88, -0x1f,0x82,0x04,0x82,0x05,0x82,0x04,0x82,0x05,0x83,0x0a,0x84,0x06,0x83,0x0c, -0x83,0x05,0x83,0x0c,0x83,0x04,0x83,0x0c,0x83,0x06,0x83,0x14,0x83,0x14,0x83, -0x0c,0x83,0x04,0x83,0x0d,0x83,0x0c,0x83,0x0d,0x83,0x09,0x83,0x08,0x83,0x07, -0x84,0x0a,0x83,0x10,0x83,0x06,0x85,0x05,0x83,0x03,0x83,0x09,0x87,0x04,0x83, -0x0c,0x83,0x06,0x83,0x13,0x83,0x0c,0x83,0x06,0x83,0x0b,0x83,0x05,0x83,0x0c, -0x83,0x0d,0x83,0x0c,0x83,0x0c,0x84,0x0a,0x83,0x01,0x83,0x0c,0x85,0x05,0x84, -0x0a,0x84,0x05,0x84,0x0f,0x83,0x10,0x83,0x18,0x83,0x15,0x83,0x12,0x83,0x54, -0x83,0x09,0x83,0x08,0x83,0x0a,0x83,0x07,0x83,0x09,0x83,0x07,0x83,0x0a,0x83, -0x07,0x83,0x1a,0x83,0x0e,0x83,0x0a,0x83,0x08,0x83,0x09,0x83,0x0e,0x83,0x17, -0x83,0x0c,0x83,0x04,0x84,0x11,0x83,0x0a,0x83,0x06,0x83,0x07,0x83,0x05,0x83, -0x09,0x83,0x07,0x84,0x09,0x84,0x07,0x83,0x0a,0x83,0x06,0x83,0x0a,0x83,0x09, -0x83,0x1f,0x83,0x0b,0x83,0x11,0x83,0x09,0x83,0x0d,0x83,0x01,0x83,0x0a,0x86, -0x03,0x83,0x01,0x82,0x0d,0x83,0x02,0x83,0x0f,0x84,0x01,0x83,0x0e,0x84,0x16, -0x83,0x14,0x83,0x15,0x83,0x7f,0x02,0x82,0x05,0x82,0x0b,0x83,0x0a,0x83,0x0b, -0x82,0x04,0x83,0x04,0x83,0x02,0x83,0x09,0x86,0x24,0x83,0x15,0x83,0x2a,0x83, -0x57,0x83,0x11,0x83,0x08,0x83,0x10,0x83,0x0f,0x83,0x11,0x84,0x08,0x84,0x11, -0x83,0x0b,0x83,0x08,0x84,0x08,0x83,0x08,0x84,0x0c,0x83,0x10,0x84,0x08,0x84, -0x12,0x83,0x3c,0x88,0x22,0x88,0x21,0x82,0x04,0x83,0x03,0x83,0x04,0x82,0x05, -0x83,0x0b,0x83,0x06,0x83,0x0c,0x83,0x05,0x84,0x0a,0x83,0x05,0x83,0x0b,0x84, -0x06,0x83,0x14,0x83,0x14,0x84,0x0b,0x83,0x04,0x83,0x0d,0x83,0x0c,0x83,0x0d, -0x83,0x08,0x84,0x08,0x83,0x07,0x85,0x09,0x83,0x10,0x83,0x07,0x83,0x06,0x83, -0x03,0x83,0x09,0x87,0x04,0x84,0x0a,0x84,0x06,0x83,0x13,0x84,0x0a,0x84,0x06, -0x83,0x0b,0x83,0x05,0x84,0x0b,0x83,0x0d,0x83,0x0d,0x83,0x0b,0x83,0x0b,0x83, -0x01,0x83,0x0c,0x85,0x05,0x84,0x0a,0x84,0x05,0x84,0x0f,0x83,0x0f,0x84,0x18, -0x83,0x15,0x84,0x11,0x83,0x54,0x83,0x09,0x83,0x08,0x83,0x09,0x83,0x09,0x83, -0x08,0x83,0x07,0x84,0x09,0x83,0x08,0x83,0x19,0x83,0x0e,0x84,0x09,0x83,0x08, -0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c,0x83,0x04,0x84,0x11,0x83,0x0a,0x83, -0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83,0x08,0x83,0x09,0x83,0x08,0x83,0x09, -0x83,0x07,0x84,0x09,0x83,0x09,0x83,0x13,0x83,0x09,0x83,0x0b,0x83,0x11,0x83, -0x09,0x83,0x0d,0x86,0x0c,0x85,0x03,0x83,0x01,0x82,0x0c,0x84,0x02,0x84,0x0f, -0x87,0x0d,0x84,0x17,0x83,0x14,0x83,0x15,0x83,0x7f,0x01,0x83,0x05,0x82,0x0b, -0x83,0x0a,0x83,0x0a,0x83,0x04,0x83,0x04,0x83,0x02,0x84,0x09,0x84,0x26,0x83, -0x13,0x83,0x2b,0x83,0x57,0x83,0x11,0x83,0x08,0x83,0x10,0x83,0x0e,0x83,0x13, -0x83,0x08,0x83,0x12,0x83,0x0b,0x84,0x07,0x83,0x09,0x84,0x07,0x83,0x0d,0x83, -0x11,0x83,0x08,0x83,0x12,0x84,0x25,0x83,0x16,0x86,0x21,0x86,0x25,0x82,0x03, -0x83,0x02,0x85,0x02,0x82,0x05,0x84,0x0b,0x83,0x06,0x83,0x0b,0x84,0x06,0x83, -0x09,0x84,0x05,0x83,0x0a,0x84,0x07,0x83,0x14,0x83,0x15,0x84,0x09,0x84,0x04, -0x83,0x0d,0x83,0x0c,0x83,0x0d,0x84,0x07,0x83,0x09,0x83,0x08,0x85,0x08,0x83, -0x10,0x83,0x07,0x83,0x06,0x83,0x03,0x83,0x0a,0x86,0x05,0x83,0x09,0x84,0x07, -0x83,0x14,0x83,0x09,0x84,0x07,0x83,0x0b,0x83,0x06,0x84,0x09,0x84,0x0d,0x83, -0x0d,0x84,0x09,0x84,0x0b,0x87,0x0c,0x84,0x07,0x83,0x09,0x84,0x07,0x84,0x0e, -0x83,0x0e,0x84,0x19,0x83,0x16,0x83,0x11,0x83,0x54,0x83,0x08,0x84,0x08,0x84, -0x08,0x83,0x09,0x83,0x07,0x84,0x08,0x83,0x08,0x84,0x08,0x83,0x0a,0x81,0x0e, -0x83,0x0f,0x83,0x08,0x84,0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c,0x83, -0x05,0x84,0x10,0x83,0x0a,0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83,0x08, -0x84,0x07,0x84,0x08,0x84,0x07,0x84,0x08,0x84,0x07,0x84,0x09,0x83,0x13,0x84, -0x08,0x83,0x0b,0x83,0x11,0x84,0x07,0x84,0x0d,0x86,0x0c,0x84,0x05,0x85,0x0c, -0x83,0x04,0x83,0x0f,0x86,0x0d,0x84,0x18,0x83,0x14,0x83,0x15,0x83,0x7f,0x01, -0x83,0x04,0x83,0x0c,0x83,0x08,0x84,0x0a,0x82,0x05,0x83,0x04,0x83,0x03,0x84, -0x06,0x87,0x25,0x83,0x13,0x83,0x2b,0x83,0x57,0x82,0x12,0x85,0x04,0x85,0x10, -0x83,0x0d,0x83,0x14,0x85,0x04,0x85,0x12,0x83,0x0c,0x84,0x05,0x84,0x0a,0x84, -0x04,0x85,0x0d,0x83,0x11,0x85,0x04,0x85,0x09,0x81,0x07,0x84,0x26,0x83,0x18, -0x84,0x21,0x84,0x18,0x83,0x0c,0x82,0x04,0x85,0x01,0x86,0x06,0x83,0x0c,0x84, -0x05,0x83,0x0a,0x84,0x07,0x85,0x06,0x84,0x06,0x83,0x08,0x85,0x08,0x83,0x14, -0x83,0x15,0x85,0x07,0x85,0x04,0x83,0x0d,0x83,0x0c,0x83,0x0e,0x84,0x05,0x84, -0x09,0x83,0x09,0x84,0x08,0x83,0x10,0x83,0x10,0x83,0x03,0x83,0x0b,0x85,0x05, -0x85,0x06,0x85,0x07,0x83,0x14,0x85,0x06,0x85,0x07,0x83,0x0b,0x83,0x06,0x85, -0x06,0x85,0x0e,0x83,0x0e,0x85,0x05,0x85,0x0d,0x85,0x0d,0x84,0x07,0x83,0x08, -0x84,0x09,0x84,0x0d,0x83,0x0d,0x84,0x1a,0x83,0x16,0x83,0x11,0x83,0x54,0x84, -0x05,0x86,0x08,0x85,0x05,0x85,0x0a,0x84,0x04,0x84,0x09,0x85,0x05,0x85,0x09, -0x84,0x06,0x83,0x0e,0x83,0x0f,0x85,0x05,0x85,0x08,0x83,0x09,0x83,0x0e,0x83, -0x17,0x83,0x0c,0x83,0x06,0x84,0x0f,0x83,0x0a,0x83,0x06,0x83,0x07,0x83,0x05, -0x83,0x09,0x83,0x09,0x84,0x05,0x84,0x09,0x85,0x05,0x85,0x08,0x85,0x05,0x85, -0x09,0x83,0x14,0x84,0x05,0x85,0x0b,0x84,0x05,0x83,0x09,0x84,0x05,0x85,0x0e, -0x85,0x0c,0x84,0x05,0x85,0x0b,0x84,0x04,0x84,0x0e,0x86,0x0d,0x83,0x19,0x83, -0x14,0x83,0x15,0x83,0x57,0x83,0x26,0x83,0x04,0x83,0x0c,0x85,0x05,0x84,0x13, -0x83,0x02,0x83,0x05,0x91,0x24,0x83,0x13,0x83,0x40,0x83,0x2c,0x83,0x12,0x83, -0x13,0x8c,0x11,0x83,0x0c,0x90,0x09,0x8c,0x13,0x83,0x0c,0x8c,0x0b,0x8c,0x0e, -0x83,0x12,0x8c,0x0a,0x8c,0x0f,0x83,0x14,0x83,0x1a,0x82,0x21,0x82,0x1a,0x83, -0x0c,0x83,0x04,0x83,0x03,0x84,0x07,0x83,0x0d,0x83,0x05,0x90,0x09,0x8e,0x06, -0x8f,0x09,0x90,0x07,0x83,0x16,0x8f,0x05,0x83,0x0d,0x83,0x0c,0x83,0x0e,0x8c, -0x0a,0x83,0x0a,0x84,0x07,0x90,0x03,0x83,0x10,0x83,0x03,0x83,0x0b,0x85,0x06, -0x8e,0x08,0x83,0x15,0x90,0x06,0x83,0x0b,0x83,0x07,0x8e,0x0f,0x83,0x0e,0x8e, -0x0e,0x85,0x0e,0x83,0x07,0x83,0x08,0x84,0x09,0x84,0x0d,0x83,0x0d,0x92,0x0c, -0x83,0x16,0x84,0x10,0x83,0x55,0x8a,0x01,0x83,0x08,0x8e,0x0b,0x8b,0x0b,0x8e, -0x09,0x8e,0x0d,0x83,0x10,0x8e,0x08,0x83,0x09,0x83,0x0e,0x83,0x17,0x83,0x0c, -0x83,0x06,0x84,0x0f,0x83,0x0a,0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83, -0x09,0x8d,0x09,0x8e,0x0a,0x8e,0x09,0x83,0x14,0x8d,0x0c,0x8c,0x09,0x8e,0x0e, -0x84,0x0e,0x83,0x05,0x84,0x0b,0x84,0x06,0x84,0x0e,0x85,0x0c,0x8f,0x0e,0x83, -0x14,0x83,0x15,0x83,0x57,0x83,0x26,0x82,0x05,0x83,0x0d,0x8c,0x15,0x86,0x07, -0x8b,0x02,0x84,0x23,0x83,0x13,0x83,0x40,0x83,0x2c,0x83,0x12,0x82,0x15,0x8a, -0x12,0x83,0x0c,0x90,0x0a,0x8a,0x14,0x83,0x0d,0x8a,0x0e,0x89,0x0f,0x83,0x13, -0x8a,0x0b,0x8a,0x11,0x83,0x14,0x83,0x59,0x83,0x0d,0x82,0x14,0x84,0x0d,0x83, -0x05,0x8f,0x0b,0x8b,0x08,0x8e,0x0a,0x90,0x07,0x83,0x18,0x8b,0x07,0x83,0x0d, -0x83,0x09,0x89,0x0c,0x8a,0x0b,0x83,0x0b,0x84,0x06,0x90,0x03,0x83,0x10,0x83, -0x03,0x83,0x0c,0x84,0x07,0x8b,0x0a,0x83,0x17,0x8a,0x01,0x84,0x05,0x83,0x0b, -0x83,0x09,0x8b,0x10,0x83,0x10,0x8b,0x0f,0x84,0x0f,0x82,0x09,0x82,0x07,0x84, -0x0b,0x84,0x0c,0x83,0x0d,0x92,0x0c,0x83,0x17,0x83,0x10,0x83,0x56,0x88,0x02, -0x83,0x08,0x83,0x01,0x89,0x0d,0x89,0x0d,0x89,0x01,0x83,0x0b,0x8a,0x0f,0x83, -0x11,0x89,0x01,0x83,0x08,0x83,0x09,0x83,0x0a,0x8b,0x13,0x83,0x0c,0x83,0x07, -0x84,0x0a,0x8b,0x06,0x83,0x06,0x83,0x07,0x83,0x05,0x83,0x09,0x83,0x0b,0x89, -0x0b,0x83,0x01,0x89,0x0c,0x89,0x01,0x83,0x09,0x83,0x16,0x8a,0x0e,0x8a,0x0b, -0x89,0x01,0x83,0x0e,0x84,0x0e,0x83,0x06,0x83,0x0b,0x84,0x06,0x84,0x0e,0x84, -0x0d,0x8f,0x0e,0x83,0x14,0x83,0x15,0x83,0x57,0x83,0x25,0x83,0x05,0x82,0x0f, -0x8a,0x17,0x84,0x0a,0x87,0x04,0x84,0x24,0x83,0x11,0x83,0x41,0x83,0x2c,0x83, -0x11,0x83,0x17,0x86,0x14,0x83,0x0c,0x90,0x0c,0x86,0x16,0x83,0x0f,0x86,0x11, -0x86,0x11,0x83,0x15,0x86,0x0e,0x87,0x13,0x83,0x14,0x82,0x5a,0x83,0x0d,0x83, -0x13,0x83,0x0e,0x84,0x04,0x8d,0x0f,0x87,0x0a,0x8c,0x0c,0x90,0x07,0x83,0x1a, -0x87,0x09,0x83,0x0d,0x83,0x09,0x89,0x0e,0x86,0x0d,0x83,0x0b,0x85,0x05,0x90, -0x03,0x83,0x10,0x83,0x03,0x83,0x0d,0x83,0x0a,0x86,0x0c,0x83,0x19,0x86,0x04, -0x84,0x04,0x83,0x0c,0x83,0x0a,0x87,0x12,0x83,0x12,0x87,0x12,0x83,0x10,0x81, -0x09,0x81,0x07,0x85,0x0b,0x85,0x0b,0x83,0x0d,0x92,0x0c,0x83,0x17,0x84,0x0f, -0x83,0x57,0x86,0x03,0x83,0x08,0x82,0x04,0x85,0x11,0x86,0x10,0x85,0x04,0x82, -0x0d,0x86,0x11,0x83,0x13,0x85,0x03,0x83,0x08,0x83,0x09,0x83,0x0a,0x8b,0x13, -0x83,0x0c,0x83,0x08,0x84,0x09,0x8b,0x06,0x83,0x06,0x83,0x07,0x83,0x05,0x83, -0x09,0x83,0x0c,0x87,0x0c,0x83,0x03,0x85,0x10,0x85,0x03,0x83,0x09,0x83,0x17, -0x87,0x11,0x87,0x0f,0x85,0x03,0x83,0x0f,0x83,0x0e,0x82,0x07,0x83,0x0a,0x84, -0x08,0x84,0x0d,0x84,0x0d,0x8f,0x0e,0x83,0x14,0x83,0x15,0x83,0x7f,0x1c,0x85, -0x5a,0x83,0x11,0x83,0x41,0x83,0x40,0x83,0x7f,0x7f,0x16,0x83,0x6b,0x83,0x7f, -0x7f,0x7f,0x17,0x83,0x7f,0x5b,0x83,0x18,0x83,0x0f,0x83,0x25,0x90,0x7f,0x36, -0x83,0x3f,0x83,0x7e,0x83,0x20,0x83,0x7f,0x30,0x83,0x2b,0x83,0x14,0x83,0x15, -0x83,0x7f,0x1d,0x83,0x5c,0x83,0x0f,0x83,0x42,0x82,0x41,0x82,0x7f,0x7f,0x17, -0x82,0x6d,0x84,0x06,0x81,0x7f,0x7f,0x7f,0x0f,0x81,0x7f,0x5c,0x83,0x18,0x83, -0x0f,0x83,0x25,0x90,0x7f,0x36,0x83,0x3f,0x83,0x7e,0x83,0x20,0x83,0x7f,0x30, -0x83,0x2b,0x84,0x13,0x83,0x14,0x83,0x7f,0x1e,0x83,0x5c,0x83,0x0f,0x83,0x41, -0x83,0x7f,0x7f,0x5a,0x82,0x6e,0x8b,0x7f,0x7f,0x7f,0x7f,0x6b,0x83,0x2a,0x83, -0x25,0x90,0x7f,0x36,0x83,0x3f,0x83,0x7e,0x83,0x20,0x83,0x7f,0x2f,0x84,0x2c, -0x83,0x13,0x83,0x14,0x83,0x7f,0x1e,0x83,0x5d,0x83,0x0d,0x83,0x42,0x82,0x7f, -0x7f,0x7f,0x4e,0x86,0x7f,0x7f,0x7f,0x7f,0x6e,0x87,0x23,0x86,0x7f,0x6a,0x83, -0x3f,0x84,0x7e,0x83,0x20,0x83,0x7f,0x2f,0x83,0x2d,0x84,0x12,0x83,0x13,0x84, -0x7f,0x7f,0x82,0x0d,0x82,0x43,0x82,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x43,0x87,0x23,0x86,0x7f,0x60,0x82,0x07,0x84,0x3e,0x84,0x7f,0x83,0x20,0x83, -0x7f,0x2e,0x84,0x2e,0x84,0x11,0x83,0x11,0x85,0x7f,0x7f,0x01,0x83,0x0b,0x83, -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x09,0x87,0x23,0x86,0x7f,0x60, -0x8c,0x3b,0x88,0x7f,0x83,0x20,0x83,0x7f,0x2b,0x86,0x31,0x82,0x11,0x83,0x12, -0x82,0x7f,0x7f,0x04,0x83,0x09,0x83,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x7f,0x1b,0x8b,0x3c,0x87,0x7f,0x01,0x83,0x20,0x83,0x7f,0x2b,0x86, -0x7f,0x7f,0x60,0x81,0x0b,0x81,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x1e,0x87,0x3e,0x85,0x7f,0x03,0x83,0x20,0x83,0x7f,0x2b,0x84,0x7f, -0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, -0x7f,0x7f,0x4a, -0x00, - } -}; diff --git a/mmcutils/mmcutils.c b/mmcutils/mmcutils.c old mode 100644 new mode 100755 index a003a2d6..3f5514ed --- a/mmcutils/mmcutils.c +++ b/mmcutils/mmcutils.c @@ -315,9 +315,9 @@ mmc_find_partition_by_name(const char *name) return NULL; } -#define MKE2FS_BIN "/sbin/mke2fs" -#define TUNE2FS_BIN "/sbin/tune2fs" -#define E2FSCK_BIN "/sbin/e2fsck" +#define MKE2FS_BIN "/system/bin/mke2fs" +#define TUNE2FS_BIN "/system/bin/tune2fs" +#define E2FSCK_BIN "/system/bin/e2fsck" int run_exec_process ( char *const *argv) { diff --git a/mtp/legacy/Android.mk b/mtp/legacy/Android.mk deleted file mode 100644 index cd04ac01..00000000 --- a/mtp/legacy/Android.mk +++ /dev/null @@ -1,47 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -# Build libtwrpmtp library - -include $(CLEAR_VARS) -LOCAL_MODULE := libtwrpmtp-legacy -LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64 -DMTP_DEVICE -DMTP_HOST -fno-strict-aliasing -Wno-unused-variable -Wno-format -Wno-unused-parameter -Wno-unused-private-field -LOCAL_C_INCLUDES += $(LOCAL_PATH) bionic frameworks/base/include system/core/include bionic/libc/private/ -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0) - LOCAL_C_INCLUDES += external/stlport/stlport - LOCAL_SHARED_LIBRARIES += libstlport -else - LOCAL_SHARED_LIBRARIES += libc++ -endif - -LOCAL_SRC_FILES = \ - btree.cpp \ - MtpDataPacket.cpp \ - MtpDebug.cpp \ - MtpDevice.cpp \ - MtpDeviceInfo.cpp \ - MtpEventPacket.cpp \ - MtpObjectInfo.cpp \ - MtpPacket.cpp \ - MtpProperty.cpp \ - MtpRequestPacket.cpp \ - MtpResponsePacket.cpp \ - MtpServer.cpp \ - MtpStorage.cpp \ - MtpStorageInfo.cpp \ - MtpStringBuffer.cpp \ - MtpUtils.cpp \ - mtp_MtpServer.cpp \ - twrpMtp.cpp \ - mtp_MtpDatabase.cpp \ - node.cpp -LOCAL_SHARED_LIBRARIES += libz libc libusbhost libstdc++ libdl libcutils libutils libaosprecovery libselinux - -ifneq ($(TW_MTP_DEVICE),) - LOCAL_CFLAGS += -DUSB_MTP_DEVICE=$(TW_MTP_DEVICE) -endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25; echo $$?),0) - LOCAL_CFLAGS += -DHAS_USBHOST_TIMEOUT -endif - -include $(BUILD_SHARED_LIBRARY) diff --git a/mtp/legacy/MtpDataPacket.cpp b/mtp/legacy/MtpDataPacket.cpp deleted file mode 100644 index 845db968..00000000 --- a/mtp/legacy/MtpDataPacket.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to c++ - * - */ - -#include -#include -#include - -#include - -#include "MtpDataPacket.h" -#include "MtpStringBuffer.h" -#include "MtpDebug.h" - -#define MTP_BUFFER_SIZE 16384 - - -MtpDataPacket::MtpDataPacket() - : MtpPacket(MTP_BUFFER_SIZE), // MAX_USBFS_BUFFER_SIZE - mOffset(MTP_CONTAINER_HEADER_SIZE) -{ -} - -MtpDataPacket::~MtpDataPacket() { -} - -void MtpDataPacket::reset() { - MtpPacket::reset(); - mOffset = MTP_CONTAINER_HEADER_SIZE; -} - -void MtpDataPacket::setOperationCode(MtpOperationCode code) { - MtpPacket::putUInt16(MTP_CONTAINER_CODE_OFFSET, code); -} - -void MtpDataPacket::setTransactionID(MtpTransactionID id) { - MtpPacket::putUInt32(MTP_CONTAINER_TRANSACTION_ID_OFFSET, id); -} - -uint16_t MtpDataPacket::getUInt16() { - int offset = mOffset; - uint16_t result = (uint16_t)mBuffer[offset] | ((uint16_t)mBuffer[offset + 1] << 8); - mOffset += 2; - return result; -} - -uint32_t MtpDataPacket::getUInt32() { - int offset = mOffset; - uint32_t result = (uint32_t)mBuffer[offset] | ((uint32_t)mBuffer[offset + 1] << 8) | - ((uint32_t)mBuffer[offset + 2] << 16) | ((uint32_t)mBuffer[offset + 3] << 24); - mOffset += 4; - return result; -} - -uint64_t MtpDataPacket::getUInt64() { - int offset = mOffset; - uint64_t result = (uint64_t)mBuffer[offset] | ((uint64_t)mBuffer[offset + 1] << 8) | - ((uint64_t)mBuffer[offset + 2] << 16) | ((uint64_t)mBuffer[offset + 3] << 24) | - ((uint64_t)mBuffer[offset + 4] << 32) | ((uint64_t)mBuffer[offset + 5] << 40) | - ((uint64_t)mBuffer[offset + 6] << 48) | ((uint64_t)mBuffer[offset + 7] << 56); - mOffset += 8; - return result; -} - -void MtpDataPacket::getUInt128(uint128_t& value) { - value[0] = getUInt32(); - value[1] = getUInt32(); - value[2] = getUInt32(); - value[3] = getUInt32(); -} - -void MtpDataPacket::getString(MtpStringBuffer& string) -{ - string.readFromPacket(this); -} - -Int8List* MtpDataPacket::getAInt8() { - Int8List* result = new Int8List; - int count = getUInt32(); - for (int i = 0; i < count; i++) - result->push(getInt8()); - return result; -} - -UInt8List* MtpDataPacket::getAUInt8() { - UInt8List* result = new UInt8List; - int count = getUInt32(); - for (int i = 0; i < count; i++) - result->push(getUInt8()); - return result; -} - -Int16List* MtpDataPacket::getAInt16() { - Int16List* result = new Int16List; - int count = getUInt32(); - for (int i = 0; i < count; i++) - result->push(getInt16()); - return result; -} - -UInt16List* MtpDataPacket::getAUInt16() { - UInt16List* result = new UInt16List; - int count = getUInt32(); - for (int i = 0; i < count; i++) - result->push(getUInt16()); - return result; -} - -Int32List* MtpDataPacket::getAInt32() { - Int32List* result = new Int32List; - int count = getUInt32(); - for (int i = 0; i < count; i++) - result->push(getInt32()); - return result; -} - -UInt32List* MtpDataPacket::getAUInt32() { - UInt32List* result = new UInt32List; - int count = getUInt32(); - for (int i = 0; i < count; i++) - result->push(getUInt32()); - return result; -} - -Int64List* MtpDataPacket::getAInt64() { - Int64List* result = new Int64List; - int count = getUInt32(); - for (int i = 0; i < count; i++) - result->push(getInt64()); - return result; -} - -UInt64List* MtpDataPacket::getAUInt64() { - UInt64List* result = new UInt64List; - int count = getUInt32(); - for (int i = 0; i < count; i++) - result->push(getUInt64()); - return result; -} - -void MtpDataPacket::putInt8(int8_t value) { - allocate(mOffset + 1); - mBuffer[mOffset++] = (uint8_t)value; - if (mPacketSize < mOffset) - mPacketSize = mOffset; -} - -void MtpDataPacket::putUInt8(uint8_t value) { - allocate(mOffset + 1); - mBuffer[mOffset++] = (uint8_t)value; - if (mPacketSize < mOffset) - mPacketSize = mOffset; -} - -void MtpDataPacket::putInt16(int16_t value) { - allocate(mOffset + 2); - mBuffer[mOffset++] = (uint8_t)(value & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 8) & 0xFF); - if (mPacketSize < mOffset) - mPacketSize = mOffset; -} - -void MtpDataPacket::putUInt16(uint16_t value) { - allocate(mOffset + 2); - mBuffer[mOffset++] = (uint8_t)(value & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 8) & 0xFF); - if (mPacketSize < mOffset) - mPacketSize = mOffset; -} - -void MtpDataPacket::putInt32(int32_t value) { - allocate(mOffset + 4); - mBuffer[mOffset++] = (uint8_t)(value & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 8) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 16) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 24) & 0xFF); - if (mPacketSize < mOffset) - mPacketSize = mOffset; -} - -void MtpDataPacket::putUInt32(uint32_t value) { - allocate(mOffset + 4); - mBuffer[mOffset++] = (uint8_t)(value & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 8) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 16) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 24) & 0xFF); - if (mPacketSize < mOffset) - mPacketSize = mOffset; -} - -void MtpDataPacket::putInt64(int64_t value) { - allocate(mOffset + 8); - mBuffer[mOffset++] = (uint8_t)(value & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 8) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 16) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 24) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 32) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 40) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 48) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 56) & 0xFF); - if (mPacketSize < mOffset) - mPacketSize = mOffset; -} - -void MtpDataPacket::putUInt64(uint64_t value) { - allocate(mOffset + 8); - mBuffer[mOffset++] = (uint8_t)(value & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 8) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 16) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 24) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 32) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 40) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 48) & 0xFF); - mBuffer[mOffset++] = (uint8_t)((value >> 56) & 0xFF); - if (mPacketSize < mOffset) - mPacketSize = mOffset; -} - -void MtpDataPacket::putInt128(const int128_t& value) { - putInt32(value[0]); - putInt32(value[1]); - putInt32(value[2]); - putInt32(value[3]); -} - -void MtpDataPacket::putUInt128(const uint128_t& value) { - putUInt32(value[0]); - putUInt32(value[1]); - putUInt32(value[2]); - putUInt32(value[3]); -} - -void MtpDataPacket::putInt128(int64_t value) { - putInt64(value); - putInt64(value < 0 ? -1 : 0); -} - -void MtpDataPacket::putUInt128(uint64_t value) { - putUInt64(value); - putUInt64(0); -} - -void MtpDataPacket::putAInt8(const int8_t* values, int count) { - putUInt32(count); - for (int i = 0; i < count; i++) - putInt8(*values++); -} - -void MtpDataPacket::putAUInt8(const uint8_t* values, int count) { - putUInt32(count); - for (int i = 0; i < count; i++) - putUInt8(*values++); -} - -void MtpDataPacket::putAInt16(const int16_t* values, int count) { - putUInt32(count); - for (int i = 0; i < count; i++) - putInt16(*values++); -} - -void MtpDataPacket::putAUInt16(const uint16_t* values, int count) { - putUInt32(count); - for (int i = 0; i < count; i++) - putUInt16(*values++); -} - -void MtpDataPacket::putAUInt16(const UInt16List* values) { - size_t count = (values ? values->size() : 0); - putUInt32(count); - for (size_t i = 0; i < count; i++) - putUInt16((*values)[i]); -} - -void MtpDataPacket::putAInt32(const int32_t* values, int count) { - putUInt32(count); - for (int i = 0; i < count; i++) - putInt32(*values++); -} - -void MtpDataPacket::putAUInt32(const uint32_t* values, int count) { - putUInt32(count); - for (int i = 0; i < count; i++) - putUInt32(*values++); -} - -void MtpDataPacket::putAUInt32(const UInt32List* list) { - if (!list) { - putEmptyArray(); - } else { - size_t size = list->size(); - putUInt32(size); - for (size_t i = 0; i < size; i++) - putUInt32((*list)[i]); - } -} - -void MtpDataPacket::putAInt64(const int64_t* values, int count) { - putUInt32(count); - for (int i = 0; i < count; i++) - putInt64(*values++); -} - -void MtpDataPacket::putAUInt64(const uint64_t* values, int count) { - putUInt32(count); - for (int i = 0; i < count; i++) - putUInt64(*values++); -} - -void MtpDataPacket::putString(const MtpStringBuffer& string) { - string.writeToPacket(this); -} - -void MtpDataPacket::putString(const char* s) { - MtpStringBuffer string(s); - string.writeToPacket(this); -} - -void MtpDataPacket::putString(const uint16_t* string) { - int count = 0; - for (int i = 0; i < 256; i++) { - if (string[i]) - count++; - else - break; - } - putUInt8(count > 0 ? count + 1 : 0); - for (int i = 0; i < count; i++) - putUInt16(string[i]); - // only terminate with zero if string is not empty - if (count > 0) - putUInt16(0); -} - -#ifdef MTP_DEVICE -int MtpDataPacket::read(int fd) { - int ret = ::read(fd, mBuffer, MTP_BUFFER_SIZE); - if (ret < MTP_CONTAINER_HEADER_SIZE) - return -1; - mPacketSize = ret; - mOffset = MTP_CONTAINER_HEADER_SIZE; - return ret; -} - -int MtpDataPacket::write(int fd) { - MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); - MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA); - int ret = ::write(fd, mBuffer, mPacketSize); - return (ret < 0 ? ret : 0); -} - -int MtpDataPacket::writeData(int fd, void* data, uint32_t length) { - allocate(length); - memcpy(mBuffer + MTP_CONTAINER_HEADER_SIZE, data, length); - length += MTP_CONTAINER_HEADER_SIZE; - MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, length); - MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA); - int ret = ::write(fd, mBuffer, length); - return (ret < 0 ? ret : 0); -} - -#endif // MTP_DEVICE - -#ifdef MTP_HOST -int MtpDataPacket::read(struct usb_request *request) { - // first read the header - request->buffer = mBuffer; - request->buffer_length = mBufferSize; - int32_t length = transfer(request); - if (length >= MTP_CONTAINER_HEADER_SIZE) { - // look at the length field to see if the data spans multiple packets - uint32_t totalLength = MtpPacket::getUInt32(MTP_CONTAINER_LENGTH_OFFSET); - allocate(totalLength); - while (totalLength > (uint32_t)length) { - request->buffer = mBuffer + length; - request->buffer_length = totalLength - length; - int ret = transfer(request); - if (ret >= 0) - length += ret; - else { - length = ret; - break; - } - } - } - if (length >= 0) - mPacketSize = length; - return length; -} - -int MtpDataPacket::readData(struct usb_request *request, void* buffer, int length) { - int read = 0; - while (read < length) { - request->buffer = (char *)buffer + read; - request->buffer_length = length - read; - int ret = transfer(request); - if (ret < 0) { - return ret; - } - read += ret; - } - return read; -} - -// Queue a read request. Call readDataWait to wait for result -int MtpDataPacket::readDataAsync(struct usb_request *req) { - if (usb_request_queue(req)) { - MTPE("usb_endpoint_queue failed, errno: %d", errno); - return -1; - } - return 0; -} - -// Wait for result of readDataAsync -int MtpDataPacket::readDataWait(struct usb_device *device) { -#ifdef HAS_USBHOST_TIMEOUT - struct usb_request *req = usb_request_wait(device, 200); -#else - struct usb_request *req = usb_request_wait(device); -#endif - return (req ? req->actual_length : -1); -} - -int MtpDataPacket::readDataHeader(struct usb_request *request) { - request->buffer = mBuffer; - request->buffer_length = request->max_packet_size; - int length = transfer(request); - if (length >= 0) - mPacketSize = length; - return length; -} - -int MtpDataPacket::writeDataHeader(struct usb_request *request, uint32_t length) { - MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, length); - MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA); - request->buffer = mBuffer; - request->buffer_length = MTP_CONTAINER_HEADER_SIZE; - int ret = transfer(request); - return (ret < 0 ? ret : 0); -} -int MtpDataPacket::write(struct usb_request *request) { - MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); - MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA); - - // send header separately from data - request->buffer = mBuffer; - request->buffer_length = MTP_CONTAINER_HEADER_SIZE; - int ret = transfer(request); - if (ret == MTP_CONTAINER_HEADER_SIZE) { - request->buffer = mBuffer + MTP_CONTAINER_HEADER_SIZE; - request->buffer_length = mPacketSize - MTP_CONTAINER_HEADER_SIZE; - ret = transfer(request); - } - return (ret < 0 ? ret : 0); -} - -int MtpDataPacket::write(struct usb_request *request, void* buffer, uint32_t length) { - request->buffer = buffer; - request->buffer_length = length; - int ret = transfer(request); - return (ret < 0 ? ret : 0); -} - -#endif // MTP_HOST -void* MtpDataPacket::getData(int& outLength) const { - int length = mPacketSize - MTP_CONTAINER_HEADER_SIZE; - if (length > 0) { - void* result = malloc(length); - if (result) { - memcpy(result, mBuffer + MTP_CONTAINER_HEADER_SIZE, length); - outLength = length; - return result; - } - } - outLength = 0; - return NULL; -} - diff --git a/mtp/legacy/MtpDataPacket.h b/mtp/legacy/MtpDataPacket.h deleted file mode 100644 index 5ad440d7..00000000 --- a/mtp/legacy/MtpDataPacket.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to c++ - * - */ - -#ifndef _MTP_DATA_PACKET_H -#define _MTP_DATA_PACKET_H - -#include "MtpPacket.h" -#include "mtp.h" - -struct usb_device; -struct usb_request; - - -class MtpStringBuffer; - -class MtpDataPacket : public MtpPacket { -private: - // current offset for get/put methods - uint64_t mOffset; - -public: - MtpDataPacket(); - virtual ~MtpDataPacket(); - - virtual void reset(); - - void setOperationCode(MtpOperationCode code); - void setTransactionID(MtpTransactionID id); - - inline const uint8_t* getData() const { return mBuffer + MTP_CONTAINER_HEADER_SIZE; } - inline uint8_t getUInt8() { return (uint8_t)mBuffer[mOffset++]; } - inline int8_t getInt8() { return (int8_t)mBuffer[mOffset++]; } - uint16_t getUInt16(); - inline int16_t getInt16() { return (int16_t)getUInt16(); } - uint32_t getUInt32(); - inline int32_t getInt32() { return (int32_t)getUInt32(); } - uint64_t getUInt64(); - inline int64_t getInt64() { return (int64_t)getUInt64(); } - void getUInt128(uint128_t& value); - inline void getInt128(int128_t& value) { getUInt128((uint128_t&)value); } - void getString(MtpStringBuffer& string); - - Int8List* getAInt8(); - UInt8List* getAUInt8(); - Int16List* getAInt16(); - UInt16List* getAUInt16(); - Int32List* getAInt32(); - UInt32List* getAUInt32(); - Int64List* getAInt64(); - UInt64List* getAUInt64(); - - void putInt8(int8_t value); - void putUInt8(uint8_t value); - void putInt16(int16_t value); - void putUInt16(uint16_t value); - void putInt32(int32_t value); - void putUInt32(uint32_t value); - void putInt64(int64_t value); - void putUInt64(uint64_t value); - void putInt128(const int128_t& value); - void putUInt128(const uint128_t& value); - void putInt128(int64_t value); - void putUInt128(uint64_t value); - - void putAInt8(const int8_t* values, int count); - void putAUInt8(const uint8_t* values, int count); - void putAInt16(const int16_t* values, int count); - void putAUInt16(const uint16_t* values, int count); - void putAUInt16(const UInt16List* values); - void putAInt32(const int32_t* values, int count); - void putAUInt32(const uint32_t* values, int count); - void putAUInt32(const UInt32List* list); - void putAInt64(const int64_t* values, int count); - void putAUInt64(const uint64_t* values, int count); - void putString(const MtpStringBuffer& string); - void putString(const char* string); - void putString(const uint16_t* string); - inline void putEmptyString() { putUInt8(0); } - inline void putEmptyArray() { putUInt32(0); } - - -#ifdef MTP_DEVICE - // fill our buffer with data from the given file descriptor - int read(int fd); - - // write our data to the given file descriptor - int write(int fd); - int writeData(int fd, void* data, uint32_t length); -#endif -#ifdef MTP_HOST - int read(struct usb_request *request); - int readData(struct usb_request *request, void* buffer, int length); - int readDataAsync(struct usb_request *req); - int readDataWait(struct usb_device *device); - int readDataHeader(struct usb_request *ep); - - int writeDataHeader(struct usb_request *ep, uint32_t length); - int write(struct usb_request *ep); - int write(struct usb_request *ep, void* buffer, uint32_t length); -#endif - inline bool hasData() const { return mPacketSize > MTP_CONTAINER_HEADER_SIZE; } - inline uint32_t getContainerLength() const { return MtpPacket::getUInt32(MTP_CONTAINER_LENGTH_OFFSET); } - void* getData(int& outLength) const; -}; - - -#endif // _MTP_DATA_PACKET_H diff --git a/mtp/legacy/MtpDatabase.h b/mtp/legacy/MtpDatabase.h deleted file mode 100644 index f7f33ffb..00000000 --- a/mtp/legacy/MtpDatabase.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to c++ - */ - -#ifndef _MTP_DATABASE_H -#define _MTP_DATABASE_H - -#include "MtpTypes.h" - -class MtpDataPacket; -class MtpProperty; -class MtpObjectInfo; - -class MtpDatabase { -public: - virtual ~MtpDatabase() {} - - // called from SendObjectInfo to reserve a database entry for the incoming file - virtual MtpObjectHandle beginSendObject(const char* path, - MtpObjectFormat format, - MtpObjectHandle parent, - MtpStorageID storage, - uint64_t size, - time_t modified) = 0; - - // called to report success or failure of the SendObject file transfer - // success should signal a notification of the new object's creation, - // failure should remove the database entry created in beginSendObject - virtual void endSendObject(const char* path, - MtpObjectHandle handle, - MtpObjectFormat format, - bool succeeded) = 0; - - virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID, - MtpObjectFormat format, - MtpObjectHandle parent) = 0; - - virtual int getNumObjects(MtpStorageID storageID, - MtpObjectFormat format, - MtpObjectHandle parent) = 0; - - // callee should delete[] the results from these - // results can be NULL - virtual MtpObjectFormatList* getSupportedPlaybackFormats() = 0; - virtual MtpObjectFormatList* getSupportedCaptureFormats() = 0; - virtual MtpObjectPropertyList* getSupportedObjectProperties(MtpObjectFormat format) = 0; - virtual MtpDevicePropertyList* getSupportedDeviceProperties() = 0; - - virtual void createDB(MtpStorage* storage, MtpStorageID storageID) = 0; - virtual void destroyDB(MtpStorageID storageID) = 0; - - virtual MtpResponseCode getObjectPropertyValue(MtpObjectHandle handle, - MtpObjectProperty property, - MtpDataPacket& packet) = 0; - - virtual MtpResponseCode setObjectPropertyValue(MtpObjectHandle handle, - MtpObjectProperty property, - MtpDataPacket& packet) = 0; - - virtual MtpResponseCode getDevicePropertyValue(MtpDeviceProperty property, - MtpDataPacket& packet) = 0; - - virtual MtpResponseCode setDevicePropertyValue(MtpDeviceProperty property, - MtpDataPacket& packet) = 0; - - virtual MtpResponseCode resetDeviceProperty(MtpDeviceProperty property) = 0; - - virtual MtpResponseCode getObjectPropertyList(MtpObjectHandle handle, - uint32_t format, uint32_t property, - int groupCode, int depth, - MtpDataPacket& packet) = 0; - - virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle, - MtpObjectInfo& info) = 0; - - virtual void* getThumbnail(MtpObjectHandle handle, size_t& outThumbSize) = 0; - - virtual MtpResponseCode getObjectFilePath(MtpObjectHandle handle, - MtpString& outFilePath, - int64_t& outFileLength, - MtpObjectFormat& outFormat) = 0; - - virtual MtpResponseCode deleteFile(MtpObjectHandle handle) = 0; - - virtual MtpObjectHandleList* getObjectReferences(MtpObjectHandle handle) = 0; - - virtual MtpResponseCode setObjectReferences(MtpObjectHandle handle, - MtpObjectHandleList* references) = 0; - - virtual MtpProperty* getObjectPropertyDesc(MtpObjectProperty property, - MtpObjectFormat format) = 0; - - virtual MtpProperty* getDevicePropertyDesc(MtpDeviceProperty property) = 0; - - virtual void sessionStarted() = 0; - - virtual void sessionEnded() = 0; - virtual void lockMutex() = 0; - virtual void unlockMutex() = 0; -}; - -#endif // _MTP_DATABASE_H diff --git a/mtp/legacy/MtpDebug.cpp b/mtp/legacy/MtpDebug.cpp deleted file mode 100644 index c986923d..00000000 --- a/mtp/legacy/MtpDebug.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (C) 2017 TeamWin - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "MtpDebug.h" -#include -#include - -#define MTP_DEBUG_BUFFER_SIZE 2048 -static int debug_enabled = 0; - -extern "C" void mtpdebug(const char *fmt, ...) -{ - if (debug_enabled) { - char buf[MTP_DEBUG_BUFFER_SIZE]; // We're going to limit a single request to 512 bytes - - va_list ap; - va_start(ap, fmt); - vsnprintf(buf, MTP_DEBUG_BUFFER_SIZE, fmt, ap); - va_end(ap); - - fputs(buf, stdout); - } -} - -struct CodeEntry { - const char* name; - uint16_t code; -}; - -static const CodeEntry sOperationCodes[] = { - { "MTP_OPERATION_GET_DEVICE_INFO", 0x1001 }, - { "MTP_OPERATION_OPEN_SESSION", 0x1002 }, - { "MTP_OPERATION_CLOSE_SESSION", 0x1003 }, - { "MTP_OPERATION_GET_STORAGE_IDS", 0x1004 }, - { "MTP_OPERATION_GET_STORAGE_INFO", 0x1005 }, - { "MTP_OPERATION_GET_NUM_OBJECTS", 0x1006 }, - { "MTP_OPERATION_GET_OBJECT_HANDLES", 0x1007 }, - { "MTP_OPERATION_GET_OBJECT_INFO", 0x1008 }, - { "MTP_OPERATION_GET_OBJECT", 0x1009 }, - { "MTP_OPERATION_GET_THUMB", 0x100A }, - { "MTP_OPERATION_DELETE_OBJECT", 0x100B }, - { "MTP_OPERATION_SEND_OBJECT_INFO", 0x100C }, - { "MTP_OPERATION_SEND_OBJECT", 0x100D }, - { "MTP_OPERATION_INITIATE_CAPTURE", 0x100E }, - { "MTP_OPERATION_FORMAT_STORE", 0x100F }, - { "MTP_OPERATION_RESET_DEVICE", 0x1010 }, - { "MTP_OPERATION_SELF_TEST", 0x1011 }, - { "MTP_OPERATION_SET_OBJECT_PROTECTION", 0x1012 }, - { "MTP_OPERATION_POWER_DOWN", 0x1013 }, - { "MTP_OPERATION_GET_DEVICE_PROP_DESC", 0x1014 }, - { "MTP_OPERATION_GET_DEVICE_PROP_VALUE", 0x1015 }, - { "MTP_OPERATION_SET_DEVICE_PROP_VALUE", 0x1016 }, - { "MTP_OPERATION_RESET_DEVICE_PROP_VALUE", 0x1017 }, - { "MTP_OPERATION_TERMINATE_OPEN_CAPTURE", 0x1018 }, - { "MTP_OPERATION_MOVE_OBJECT", 0x1019 }, - { "MTP_OPERATION_COPY_OBJECT", 0x101A }, - { "MTP_OPERATION_GET_PARTIAL_OBJECT", 0x101B }, - { "MTP_OPERATION_INITIATE_OPEN_CAPTURE", 0x101C }, - { "MTP_OPERATION_GET_OBJECT_PROPS_SUPPORTED", 0x9801 }, - { "MTP_OPERATION_GET_OBJECT_PROP_DESC", 0x9802 }, - { "MTP_OPERATION_GET_OBJECT_PROP_VALUE", 0x9803 }, - { "MTP_OPERATION_SET_OBJECT_PROP_VALUE", 0x9804 }, - { "MTP_OPERATION_GET_OBJECT_PROP_LIST", 0x9805 }, - { "MTP_OPERATION_SET_OBJECT_PROP_LIST", 0x9806 }, - { "MTP_OPERATION_GET_INTERDEPENDENT_PROP_DESC", 0x9807 }, - { "MTP_OPERATION_SEND_OBJECT_PROP_LIST", 0x9808 }, - { "MTP_OPERATION_GET_OBJECT_REFERENCES", 0x9810 }, - { "MTP_OPERATION_SET_OBJECT_REFERENCES", 0x9811 }, - { "MTP_OPERATION_SKIP", 0x9820 }, - // android extensions - { "MTP_OPERATION_GET_PARTIAL_OBJECT_64", 0x95C1 }, - { "MTP_OPERATION_SEND_PARTIAL_OBJECT", 0x95C2 }, - { "MTP_OPERATION_TRUNCATE_OBJECT", 0x95C3 }, - { "MTP_OPERATION_BEGIN_EDIT_OBJECT", 0x95C4 }, - { "MTP_OPERATION_END_EDIT_OBJECT", 0x95C5 }, - { 0, 0 }, -}; - -static const CodeEntry sFormatCodes[] = { - { "MTP_FORMAT_UNDEFINED", 0x3000 }, - { "MTP_FORMAT_ASSOCIATION", 0x3001 }, - { "MTP_FORMAT_SCRIPT", 0x3002 }, - { "MTP_FORMAT_EXECUTABLE", 0x3003 }, - { "MTP_FORMAT_TEXT", 0x3004 }, - { "MTP_FORMAT_HTML", 0x3005 }, - { "MTP_FORMAT_DPOF", 0x3006 }, - { "MTP_FORMAT_AIFF", 0x3007 }, - { "MTP_FORMAT_WAV", 0x3008 }, - { "MTP_FORMAT_MP3", 0x3009 }, - { "MTP_FORMAT_AVI", 0x300A }, - { "MTP_FORMAT_MPEG", 0x300B }, - { "MTP_FORMAT_ASF", 0x300C }, - { "MTP_FORMAT_DEFINED", 0x3800 }, - { "MTP_FORMAT_EXIF_JPEG", 0x3801 }, - { "MTP_FORMAT_TIFF_EP", 0x3802 }, - { "MTP_FORMAT_FLASHPIX", 0x3803 }, - { "MTP_FORMAT_BMP", 0x3804 }, - { "MTP_FORMAT_CIFF", 0x3805 }, - { "MTP_FORMAT_GIF", 0x3807 }, - { "MTP_FORMAT_JFIF", 0x3808 }, - { "MTP_FORMAT_CD", 0x3809 }, - { "MTP_FORMAT_PICT", 0x380A }, - { "MTP_FORMAT_PNG", 0x380B }, - { "MTP_FORMAT_TIFF", 0x380D }, - { "MTP_FORMAT_TIFF_IT", 0x380E }, - { "MTP_FORMAT_JP2", 0x380F }, - { "MTP_FORMAT_JPX", 0x3810 }, - { "MTP_FORMAT_UNDEFINED_FIRMWARE", 0xB802 }, - { "MTP_FORMAT_WINDOWS_IMAGE_FORMAT", 0xB881 }, - { "MTP_FORMAT_UNDEFINED_AUDIO", 0xB900 }, - { "MTP_FORMAT_WMA", 0xB901 }, - { "MTP_FORMAT_OGG", 0xB902 }, - { "MTP_FORMAT_AAC", 0xB903 }, - { "MTP_FORMAT_AUDIBLE", 0xB904 }, - { "MTP_FORMAT_FLAC", 0xB906 }, - { "MTP_FORMAT_UNDEFINED_VIDEO", 0xB980 }, - { "MTP_FORMAT_WMV", 0xB981 }, - { "MTP_FORMAT_MP4_CONTAINER", 0xB982 }, - { "MTP_FORMAT_MP2", 0xB983 }, - { "MTP_FORMAT_3GP_CONTAINER", 0xB984 }, - { "MTP_FORMAT_UNDEFINED_COLLECTION", 0xBA00 }, - { "MTP_FORMAT_ABSTRACT_MULTIMEDIA_ALBUM", 0xBA01 }, - { "MTP_FORMAT_ABSTRACT_IMAGE_ALBUM", 0xBA02 }, - { "MTP_FORMAT_ABSTRACT_AUDIO_ALBUM", 0xBA03 }, - { "MTP_FORMAT_ABSTRACT_VIDEO_ALBUM", 0xBA04 }, - { "MTP_FORMAT_ABSTRACT_AV_PLAYLIST", 0xBA05 }, - { "MTP_FORMAT_ABSTRACT_CONTACT_GROUP", 0xBA06 }, - { "MTP_FORMAT_ABSTRACT_MESSAGE_FOLDER", 0xBA07 }, - { "MTP_FORMAT_ABSTRACT_CHAPTERED_PRODUCTION", 0xBA08 }, - { "MTP_FORMAT_ABSTRACT_AUDIO_PLAYLIST", 0xBA09 }, - { "MTP_FORMAT_ABSTRACT_VIDEO_PLAYLIST", 0xBA0A }, - { "MTP_FORMAT_ABSTRACT_MEDIACAST", 0xBA0B }, - { "MTP_FORMAT_WPL_PLAYLIST", 0xBA10 }, - { "MTP_FORMAT_M3U_PLAYLIST", 0xBA11 }, - { "MTP_FORMAT_MPL_PLAYLIST", 0xBA12 }, - { "MTP_FORMAT_ASX_PLAYLIST", 0xBA13 }, - { "MTP_FORMAT_PLS_PLAYLIST", 0xBA14 }, - { "MTP_FORMAT_UNDEFINED_DOCUMENT", 0xBA80 }, - { "MTP_FORMAT_ABSTRACT_DOCUMENT", 0xBA81 }, - { "MTP_FORMAT_XML_DOCUMENT", 0xBA82 }, - { "MTP_FORMAT_MS_WORD_DOCUMENT", 0xBA83 }, - { "MTP_FORMAT_MHT_COMPILED_HTML_DOCUMENT", 0xBA84 }, - { "MTP_FORMAT_MS_EXCEL_SPREADSHEET", 0xBA85 }, - { "MTP_FORMAT_MS_POWERPOINT_PRESENTATION", 0xBA86 }, - { "MTP_FORMAT_UNDEFINED_MESSAGE", 0xBB00 }, - { "MTP_FORMAT_ABSTRACT_MESSSAGE", 0xBB01 }, - { "MTP_FORMAT_UNDEFINED_CONTACT", 0xBB80 }, - { "MTP_FORMAT_ABSTRACT_CONTACT", 0xBB81 }, - { "MTP_FORMAT_VCARD_2", 0xBB82 }, - { 0, 0 }, -}; - -static const CodeEntry sObjectPropCodes[] = { - { "MTP_PROPERTY_STORAGE_ID", 0xDC01 }, - { "MTP_PROPERTY_OBJECT_FORMAT", 0xDC02 }, - { "MTP_PROPERTY_PROTECTION_STATUS", 0xDC03 }, - { "MTP_PROPERTY_OBJECT_SIZE", 0xDC04 }, - { "MTP_PROPERTY_ASSOCIATION_TYPE", 0xDC05 }, - { "MTP_PROPERTY_ASSOCIATION_DESC", 0xDC06 }, - { "MTP_PROPERTY_OBJECT_FILE_NAME", 0xDC07 }, - { "MTP_PROPERTY_DATE_CREATED", 0xDC08 }, - { "MTP_PROPERTY_DATE_MODIFIED", 0xDC09 }, - { "MTP_PROPERTY_KEYWORDS", 0xDC0A }, - { "MTP_PROPERTY_PARENT_OBJECT", 0xDC0B }, - { "MTP_PROPERTY_ALLOWED_FOLDER_CONTENTS", 0xDC0C }, - { "MTP_PROPERTY_HIDDEN", 0xDC0D }, - { "MTP_PROPERTY_SYSTEM_OBJECT", 0xDC0E }, - { "MTP_PROPERTY_PERSISTENT_UID", 0xDC41 }, - { "MTP_PROPERTY_SYNC_ID", 0xDC42 }, - { "MTP_PROPERTY_PROPERTY_BAG", 0xDC43 }, - { "MTP_PROPERTY_NAME", 0xDC44 }, - { "MTP_PROPERTY_CREATED_BY", 0xDC45 }, - { "MTP_PROPERTY_ARTIST", 0xDC46 }, - { "MTP_PROPERTY_DATE_AUTHORED", 0xDC47 }, - { "MTP_PROPERTY_DESCRIPTION", 0xDC48 }, - { "MTP_PROPERTY_URL_REFERENCE", 0xDC49 }, - { "MTP_PROPERTY_LANGUAGE_LOCALE", 0xDC4A }, - { "MTP_PROPERTY_COPYRIGHT_INFORMATION", 0xDC4B }, - { "MTP_PROPERTY_SOURCE", 0xDC4C }, - { "MTP_PROPERTY_ORIGIN_LOCATION", 0xDC4D }, - { "MTP_PROPERTY_DATE_ADDED", 0xDC4E }, - { "MTP_PROPERTY_NON_CONSUMABLE", 0xDC4F }, - { "MTP_PROPERTY_CORRUPT_UNPLAYABLE", 0xDC50 }, - { "MTP_PROPERTY_PRODUCER_SERIAL_NUMBER", 0xDC51 }, - { "MTP_PROPERTY_REPRESENTATIVE_SAMPLE_FORMAT", 0xDC81 }, - { "MTP_PROPERTY_REPRESENTATIVE_SAMPLE_SIZE", 0xDC82 }, - { "MTP_PROPERTY_REPRESENTATIVE_SAMPLE_HEIGHT", 0xDC83 }, - { "MTP_PROPERTY_REPRESENTATIVE_SAMPLE_WIDTH", 0xDC84 }, - { "MTP_PROPERTY_REPRESENTATIVE_SAMPLE_DURATION", 0xDC85 }, - { "MTP_PROPERTY_REPRESENTATIVE_SAMPLE_DATA", 0xDC86 }, - { "MTP_PROPERTY_WIDTH", 0xDC87 }, - { "MTP_PROPERTY_HEIGHT", 0xDC88 }, - { "MTP_PROPERTY_DURATION", 0xDC89 }, - { "MTP_PROPERTY_RATING", 0xDC8A }, - { "MTP_PROPERTY_TRACK", 0xDC8B }, - { "MTP_PROPERTY_GENRE", 0xDC8C }, - { "MTP_PROPERTY_CREDITS", 0xDC8D }, - { "MTP_PROPERTY_LYRICS", 0xDC8E }, - { "MTP_PROPERTY_SUBSCRIPTION_CONTENT_ID", 0xDC8F }, - { "MTP_PROPERTY_PRODUCED_BY", 0xDC90 }, - { "MTP_PROPERTY_USE_COUNT", 0xDC91 }, - { "MTP_PROPERTY_SKIP_COUNT", 0xDC92 }, - { "MTP_PROPERTY_LAST_ACCESSED", 0xDC93 }, - { "MTP_PROPERTY_PARENTAL_RATING", 0xDC94 }, - { "MTP_PROPERTY_META_GENRE", 0xDC95 }, - { "MTP_PROPERTY_COMPOSER", 0xDC96 }, - { "MTP_PROPERTY_EFFECTIVE_RATING", 0xDC97 }, - { "MTP_PROPERTY_SUBTITLE", 0xDC98 }, - { "MTP_PROPERTY_ORIGINAL_RELEASE_DATE", 0xDC99 }, - { "MTP_PROPERTY_ALBUM_NAME", 0xDC9A }, - { "MTP_PROPERTY_ALBUM_ARTIST", 0xDC9B }, - { "MTP_PROPERTY_MOOD", 0xDC9C }, - { "MTP_PROPERTY_DRM_STATUS", 0xDC9D }, - { "MTP_PROPERTY_SUB_DESCRIPTION", 0xDC9E }, - { "MTP_PROPERTY_IS_CROPPED", 0xDCD1 }, - { "MTP_PROPERTY_IS_COLOUR_CORRECTED", 0xDCD2 }, - { "MTP_PROPERTY_IMAGE_BIT_DEPTH", 0xDCD3 }, - { "MTP_PROPERTY_F_NUMBER", 0xDCD4 }, - { "MTP_PROPERTY_EXPOSURE_TIME", 0xDCD5 }, - { "MTP_PROPERTY_EXPOSURE_INDEX", 0xDCD6 }, - { "MTP_PROPERTY_TOTAL_BITRATE", 0xDE91 }, - { "MTP_PROPERTY_BITRATE_TYPE", 0xDE92 }, - { "MTP_PROPERTY_SAMPLE_RATE", 0xDE93 }, - { "MTP_PROPERTY_NUMBER_OF_CHANNELS", 0xDE94 }, - { "MTP_PROPERTY_AUDIO_BIT_DEPTH", 0xDE95 }, - { "MTP_PROPERTY_SCAN_TYPE", 0xDE97 }, - { "MTP_PROPERTY_AUDIO_WAVE_CODEC", 0xDE99 }, - { "MTP_PROPERTY_AUDIO_BITRATE", 0xDE9A }, - { "MTP_PROPERTY_VIDEO_FOURCC_CODEC", 0xDE9B }, - { "MTP_PROPERTY_VIDEO_BITRATE", 0xDE9C }, - { "MTP_PROPERTY_FRAMES_PER_THOUSAND_SECONDS", 0xDE9D }, - { "MTP_PROPERTY_KEYFRAME_DISTANCE", 0xDE9E }, - { "MTP_PROPERTY_BUFFER_SIZE", 0xDE9F }, - { "MTP_PROPERTY_ENCODING_QUALITY", 0xDEA0 }, - { "MTP_PROPERTY_ENCODING_PROFILE", 0xDEA1 }, - { "MTP_PROPERTY_DISPLAY_NAME", 0xDCE0 }, - { "MTP_PROPERTY_BODY_TEXT", 0xDCE1 }, - { "MTP_PROPERTY_SUBJECT", 0xDCE2 }, - { "MTP_PROPERTY_PRIORITY", 0xDCE3 }, - { "MTP_PROPERTY_GIVEN_NAME", 0xDD00 }, - { "MTP_PROPERTY_MIDDLE_NAMES", 0xDD01 }, - { "MTP_PROPERTY_FAMILY_NAME", 0xDD02 }, - { "MTP_PROPERTY_PREFIX", 0xDD03 }, - { "MTP_PROPERTY_SUFFIX", 0xDD04 }, - { "MTP_PROPERTY_PHONETIC_GIVEN_NAME", 0xDD05 }, - { "MTP_PROPERTY_PHONETIC_FAMILY_NAME", 0xDD06 }, - { "MTP_PROPERTY_EMAIL_PRIMARY", 0xDD07 }, - { "MTP_PROPERTY_EMAIL_PERSONAL_1", 0xDD08 }, - { "MTP_PROPERTY_EMAIL_PERSONAL_2", 0xDD09 }, - { "MTP_PROPERTY_EMAIL_BUSINESS_1", 0xDD0A }, - { "MTP_PROPERTY_EMAIL_BUSINESS_2", 0xDD0B }, - { "MTP_PROPERTY_EMAIL_OTHERS", 0xDD0C }, - { "MTP_PROPERTY_PHONE_NUMBER_PRIMARY", 0xDD0D }, - { "MTP_PROPERTY_PHONE_NUMBER_PERSONAL", 0xDD0E }, - { "MTP_PROPERTY_PHONE_NUMBER_PERSONAL_2", 0xDD0F }, - { "MTP_PROPERTY_PHONE_NUMBER_BUSINESS", 0xDD10 }, - { "MTP_PROPERTY_PHONE_NUMBER_BUSINESS_2", 0xDD11 }, - { "MTP_PROPERTY_PHONE_NUMBER_MOBILE", 0xDD12 }, - { "MTP_PROPERTY_PHONE_NUMBER_MOBILE_2", 0xDD13 }, - { "MTP_PROPERTY_FAX_NUMBER_PRIMARY", 0xDD14 }, - { "MTP_PROPERTY_FAX_NUMBER_PERSONAL", 0xDD15 }, - { "MTP_PROPERTY_FAX_NUMBER_BUSINESS", 0xDD16 }, - { "MTP_PROPERTY_PAGER_NUMBER", 0xDD17 }, - { "MTP_PROPERTY_PHONE_NUMBER_OTHERS", 0xDD18 }, - { "MTP_PROPERTY_PRIMARY_WEB_ADDRESS", 0xDD19 }, - { "MTP_PROPERTY_PERSONAL_WEB_ADDRESS", 0xDD1A }, - { "MTP_PROPERTY_BUSINESS_WEB_ADDRESS", 0xDD1B }, - { "MTP_PROPERTY_INSTANT_MESSANGER_ADDRESS", 0xDD1C }, - { "MTP_PROPERTY_INSTANT_MESSANGER_ADDRESS_2", 0xDD1D }, - { "MTP_PROPERTY_INSTANT_MESSANGER_ADDRESS_3", 0xDD1E }, - { "MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_FULL", 0xDD1F }, - { "MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_LINE_1", 0xDD20 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_LINE_2", 0xDD21 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_CITY", 0xDD22 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_REGION", 0xDD23 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_POSTAL_CODE", 0xDD24 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_COUNTRY", 0xDD25 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_FULL", 0xDD26 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_LINE_1", 0xDD27 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_LINE_2", 0xDD28 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_CITY", 0xDD29 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_REGION", 0xDD2A }, - { "MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_POSTAL_CODE", 0xDD2B }, - { "MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_COUNTRY", 0xDD2C }, - { "MTP_PROPERTY_POSTAL_ADDRESS_OTHER_FULL", 0xDD2D }, - { "MTP_PROPERTY_POSTAL_ADDRESS_OTHER_LINE_1", 0xDD2E }, - { "MTP_PROPERTY_POSTAL_ADDRESS_OTHER_LINE_2", 0xDD2F }, - { "MTP_PROPERTY_POSTAL_ADDRESS_OTHER_CITY", 0xDD30 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_OTHER_REGION", 0xDD31 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_OTHER_POSTAL_CODE", 0xDD32 }, - { "MTP_PROPERTY_POSTAL_ADDRESS_OTHER_COUNTRY", 0xDD33 }, - { "MTP_PROPERTY_ORGANIZATION_NAME", 0xDD34 }, - { "MTP_PROPERTY_PHONETIC_ORGANIZATION_NAME", 0xDD35 }, - { "MTP_PROPERTY_ROLE", 0xDD36 }, - { "MTP_PROPERTY_BIRTHDATE", 0xDD37 }, - { "MTP_PROPERTY_MESSAGE_TO", 0xDD40 }, - { "MTP_PROPERTY_MESSAGE_CC", 0xDD41 }, - { "MTP_PROPERTY_MESSAGE_BCC", 0xDD42 }, - { "MTP_PROPERTY_MESSAGE_READ", 0xDD43 }, - { "MTP_PROPERTY_MESSAGE_RECEIVED_TIME", 0xDD44 }, - { "MTP_PROPERTY_MESSAGE_SENDER", 0xDD45 }, - { "MTP_PROPERTY_ACTIVITY_BEGIN_TIME", 0xDD50 }, - { "MTP_PROPERTY_ACTIVITY_END_TIME", 0xDD51 }, - { "MTP_PROPERTY_ACTIVITY_LOCATION", 0xDD52 }, - { "MTP_PROPERTY_ACTIVITY_REQUIRED_ATTENDEES", 0xDD54 }, - { "MTP_PROPERTY_ACTIVITY_OPTIONAL_ATTENDEES", 0xDD55 }, - { "MTP_PROPERTY_ACTIVITY_RESOURCES", 0xDD56 }, - { "MTP_PROPERTY_ACTIVITY_ACCEPTED", 0xDD57 }, - { "MTP_PROPERTY_ACTIVITY_TENTATIVE", 0xDD58 }, - { "MTP_PROPERTY_ACTIVITY_DECLINED", 0xDD59 }, - { "MTP_PROPERTY_ACTIVITY_REMAINDER_TIME", 0xDD5A }, - { "MTP_PROPERTY_ACTIVITY_OWNER", 0xDD5B }, - { "MTP_PROPERTY_ACTIVITY_STATUS", 0xDD5C }, - { "MTP_PROPERTY_OWNER", 0xDD5D }, - { "MTP_PROPERTY_EDITOR", 0xDD5E }, - { "MTP_PROPERTY_WEBMASTER", 0xDD5F }, - { "MTP_PROPERTY_URL_SOURCE", 0xDD60 }, - { "MTP_PROPERTY_URL_DESTINATION", 0xDD61 }, - { "MTP_PROPERTY_TIME_BOOKMARK", 0xDD62 }, - { "MTP_PROPERTY_OBJECT_BOOKMARK", 0xDD63 }, - { "MTP_PROPERTY_BYTE_BOOKMARK", 0xDD64 }, - { "MTP_PROPERTY_LAST_BUILD_DATE", 0xDD70 }, - { "MTP_PROPERTY_TIME_TO_LIVE", 0xDD71 }, - { "MTP_PROPERTY_MEDIA_GUID", 0xDD72 }, - { 0, 0 }, -}; - -static const CodeEntry sDevicePropCodes[] = { - { "MTP_DEVICE_PROPERTY_UNDEFINED", 0x5000 }, - { "MTP_DEVICE_PROPERTY_BATTERY_LEVEL", 0x5001 }, - { "MTP_DEVICE_PROPERTY_FUNCTIONAL_MODE", 0x5002 }, - { "MTP_DEVICE_PROPERTY_IMAGE_SIZE", 0x5003 }, - { "MTP_DEVICE_PROPERTY_COMPRESSION_SETTING", 0x5004 }, - { "MTP_DEVICE_PROPERTY_WHITE_BALANCE", 0x5005 }, - { "MTP_DEVICE_PROPERTY_RGB_GAIN", 0x5006 }, - { "MTP_DEVICE_PROPERTY_F_NUMBER", 0x5007 }, - { "MTP_DEVICE_PROPERTY_FOCAL_LENGTH", 0x5008 }, - { "MTP_DEVICE_PROPERTY_FOCUS_DISTANCE", 0x5009 }, - { "MTP_DEVICE_PROPERTY_FOCUS_MODE", 0x500A }, - { "MTP_DEVICE_PROPERTY_EXPOSURE_METERING_MODE", 0x500B }, - { "MTP_DEVICE_PROPERTY_FLASH_MODE", 0x500C }, - { "MTP_DEVICE_PROPERTY_EXPOSURE_TIME", 0x500D }, - { "MTP_DEVICE_PROPERTY_EXPOSURE_PROGRAM_MODE", 0x500E }, - { "MTP_DEVICE_PROPERTY_EXPOSURE_INDEX", 0x500F }, - { "MTP_DEVICE_PROPERTY_EXPOSURE_BIAS_COMPENSATION", 0x5010 }, - { "MTP_DEVICE_PROPERTY_DATETIME", 0x5011 }, - { "MTP_DEVICE_PROPERTY_CAPTURE_DELAY", 0x5012 }, - { "MTP_DEVICE_PROPERTY_STILL_CAPTURE_MODE", 0x5013 }, - { "MTP_DEVICE_PROPERTY_CONTRAST", 0x5014 }, - { "MTP_DEVICE_PROPERTY_SHARPNESS", 0x5015 }, - { "MTP_DEVICE_PROPERTY_DIGITAL_ZOOM", 0x5016 }, - { "MTP_DEVICE_PROPERTY_EFFECT_MODE", 0x5017 }, - { "MTP_DEVICE_PROPERTY_BURST_NUMBER", 0x5018 }, - { "MTP_DEVICE_PROPERTY_BURST_INTERVAL", 0x5019 }, - { "MTP_DEVICE_PROPERTY_TIMELAPSE_NUMBER", 0x501A }, - { "MTP_DEVICE_PROPERTY_TIMELAPSE_INTERVAL", 0x501B }, - { "MTP_DEVICE_PROPERTY_FOCUS_METERING_MODE", 0x501C }, - { "MTP_DEVICE_PROPERTY_UPLOAD_URL", 0x501D }, - { "MTP_DEVICE_PROPERTY_ARTIST", 0x501E }, - { "MTP_DEVICE_PROPERTY_COPYRIGHT_INFO", 0x501F }, - { "MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER", 0xD401 }, - { "MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME", 0xD402 }, - { "MTP_DEVICE_PROPERTY_VOLUME", 0xD403 }, - { "MTP_DEVICE_PROPERTY_SUPPORTED_FORMATS_ORDERED", 0xD404 }, - { "MTP_DEVICE_PROPERTY_DEVICE_ICON", 0xD405 }, - { "MTP_DEVICE_PROPERTY_PLAYBACK_RATE", 0xD410 }, - { "MTP_DEVICE_PROPERTY_PLAYBACK_OBJECT", 0xD411 }, - { "MTP_DEVICE_PROPERTY_PLAYBACK_CONTAINER_INDEX", 0xD412 }, - { "MTP_DEVICE_PROPERTY_SESSION_INITIATOR_VERSION_INFO", 0xD406 }, - { "MTP_DEVICE_PROPERTY_PERCEIVED_DEVICE_TYPE", 0xD407 }, - { 0, 0 }, -}; - -static const char* getCodeName(uint16_t code, const CodeEntry* table) { - const CodeEntry* entry = table; - while (entry->name) { - if (entry->code == code) - return entry->name; - entry++; - } - return "UNKNOWN"; -} - -const char* MtpDebug::getOperationCodeName(MtpOperationCode code) { - return getCodeName(code, sOperationCodes); -} - -const char* MtpDebug::getFormatCodeName(MtpObjectFormat code) { - if (code == 0) - return "NONE"; - return getCodeName(code, sFormatCodes); -} - -const char* MtpDebug::getObjectPropCodeName(MtpPropertyCode code) { - if (code == 0) - return "NONE"; - return getCodeName(code, sObjectPropCodes); -} - -const char* MtpDebug::getDevicePropCodeName(MtpPropertyCode code) { - if (code == 0) - return "NONE"; - return getCodeName(code, sDevicePropCodes); -} - -void MtpDebug::enableDebug(void) { - debug_enabled = 1; - MTPD("MTP debug logging enabled\n"); -} diff --git a/mtp/legacy/MtpDebug.h b/mtp/legacy/MtpDebug.h deleted file mode 100644 index 073ddcc8..00000000 --- a/mtp/legacy/MtpDebug.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017 TeamWin - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef _MTP_DEBUG_H -#define _MTP_DEBUG_H - -// #define LOG_NDEBUG 0 -#include - -#include "MtpTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif -void mtpdebug(const char *fmt, ...); - -#define MTPI(...) fprintf(stdout, "I:[MTP] " __VA_ARGS__) -#define MTPD(...) mtpdebug("D:[MTP] " __VA_ARGS__) -#define MTPE(...) fprintf(stdout, "E:[MTP] " __VA_ARGS__) - -#ifdef __cplusplus -} -#endif - -class MtpDebug { -public: - static const char* getOperationCodeName(MtpOperationCode code); - static const char* getFormatCodeName(MtpObjectFormat code); - static const char* getObjectPropCodeName(MtpPropertyCode code); - static const char* getDevicePropCodeName(MtpPropertyCode code); - static void enableDebug(); -}; - - -#endif // _MTP_DEBUG_H diff --git a/mtp/legacy/MtpDevice.cpp b/mtp/legacy/MtpDevice.cpp deleted file mode 100644 index 089fc227..00000000 --- a/mtp/legacy/MtpDevice.cpp +++ /dev/null @@ -1,851 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include "MtpDevice.h" -#include "MtpDebug.h" -#include "MtpDeviceInfo.h" -#include "MtpObjectInfo.h" -#include "MtpProperty.h" -#include "MtpStorageInfo.h" -#include "MtpStringBuffer.h" -#include "MtpUtils.h" -#include "MtpDataPacket.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -#if 0 -static bool isMtpDevice(uint16_t vendor, uint16_t product) { - // Sandisk Sansa Fuze - if (vendor == 0x0781 && product == 0x74c2) - return true; - // Samsung YP-Z5 - if (vendor == 0x04e8 && product == 0x503c) - return true; - return false; -} -#endif - -#ifdef HAS_USBHOST_TIMEOUT -static const int USB_CONTROL_TRANSFER_TIMEOUT_MS = 200; -#endif - -MtpDevice* MtpDevice::open(const char* deviceName, int fd) { - struct usb_device *device = usb_device_new(deviceName, fd); - if (!device) { - MTPE("usb_device_new failed for %s", deviceName); - return NULL; - } - - struct usb_descriptor_header* desc; - struct usb_descriptor_iter iter; - - usb_descriptor_iter_init(device, &iter); - - while ((desc = usb_descriptor_iter_next(&iter)) != NULL) { - if (desc->bDescriptorType == USB_DT_INTERFACE) { - struct usb_interface_descriptor *interface = (struct usb_interface_descriptor *)desc; - - if (interface->bInterfaceClass == USB_CLASS_STILL_IMAGE && - interface->bInterfaceSubClass == 1 && // Still Image Capture - interface->bInterfaceProtocol == 1) // Picture Transfer Protocol (PIMA 15470) - { -#ifdef HAS_USBHOST_TIMEOUT - char* manufacturerName = usb_device_get_manufacturer_name(device, USB_CONTROL_TRANSFER_TIMEOUT_MS); - char* productName = usb_device_get_product_name(device, USB_CONTROL_TRANSFER_TIMEOUT_MS); -#else - char* manufacturerName = usb_device_get_manufacturer_name(device); - char* productName = usb_device_get_product_name(device); -#endif - MTPD("Found camera: \"%s\" \"%s\"\n", manufacturerName, productName); - free(manufacturerName); - free(productName); - } else if (interface->bInterfaceClass == 0xFF && - interface->bInterfaceSubClass == 0xFF && - interface->bInterfaceProtocol == 0) { -#ifdef HAS_USBHOST_TIMEOUT - char* interfaceName = usb_device_get_string(device, interface->iInterface, USB_CONTROL_TRANSFER_TIMEOUT_MS); -#else - char* interfaceName = usb_device_get_string(device, interface->iInterface); -#endif - if (!interfaceName) { - continue; - } else if (strcmp(interfaceName, "MTP")) { - free(interfaceName); - continue; - } - free(interfaceName); - - // Looks like an android style MTP device -#ifdef HAS_USBHOST_TIMEOUT - char* manufacturerName = usb_device_get_manufacturer_name(device, USB_CONTROL_TRANSFER_TIMEOUT_MS); - char* productName = usb_device_get_product_name(device, USB_CONTROL_TRANSFER_TIMEOUT_MS); -#else - char* manufacturerName = usb_device_get_manufacturer_name(device); - char* productName = usb_device_get_product_name(device); -#endif - MTPI("Found MTP device: \"%s\" \"%s\"\n", manufacturerName, productName); - free(manufacturerName); - free(productName); - } -#if 0 - else { - // look for special cased devices based on vendor/product ID - // we are doing this mainly for testing purposes - uint16_t vendor = usb_device_get_vendor_id(device); - uint16_t product = usb_device_get_product_id(device); - if (!isMtpDevice(vendor, product)) { - // not an MTP or PTP device - continue; - } - // request MTP OS string and descriptor - // some music players need to see this before entering MTP mode. - char buffer[256]; - memset(buffer, 0, sizeof(buffer)); - int ret = usb_device_control_transfer(device, - USB_DIR_IN|USB_RECIP_DEVICE|USB_TYPE_STANDARD, - USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | 0xEE, - 0, buffer, sizeof(buffer), 0); - MTPE("usb_device_control_transfer returned %d errno: %d\n", ret, errno); - if (ret > 0) { - MTPI("got MTP string %s\n", buffer); - ret = usb_device_control_transfer(device, - USB_DIR_IN|USB_RECIP_DEVICE|USB_TYPE_VENDOR, 1, - 0, 4, buffer, sizeof(buffer), 0); - MTPI("OS descriptor got %d\n", ret); - } else { - MTPI("no MTP string\n"); - } - } -#endif - // if we got here, then we have a likely MTP or PTP device - - // interface should be followed by three endpoints - struct usb_endpoint_descriptor *ep; - struct usb_endpoint_descriptor *ep_in_desc = NULL; - struct usb_endpoint_descriptor *ep_out_desc = NULL; - struct usb_endpoint_descriptor *ep_intr_desc = NULL; - for (int i = 0; i < 3; i++) { - ep = (struct usb_endpoint_descriptor *)usb_descriptor_iter_next(&iter); - if (!ep || ep->bDescriptorType != USB_DT_ENDPOINT) { - MTPE("endpoints not found\n"); - usb_device_close(device); - return NULL; - } - if (ep->bmAttributes == USB_ENDPOINT_XFER_BULK) { - if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) - ep_in_desc = ep; - else - ep_out_desc = ep; - } else if (ep->bmAttributes == USB_ENDPOINT_XFER_INT && - ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) { - ep_intr_desc = ep; - } - } - if (!ep_in_desc || !ep_out_desc || !ep_intr_desc) { - MTPE("endpoints not found\n"); - usb_device_close(device); - return NULL; - } - - if (usb_device_claim_interface(device, interface->bInterfaceNumber)) { - MTPE("usb_device_claim_interface failed errno: %d\n", errno); - usb_device_close(device); - return NULL; - } - - MtpDevice* mtpDevice = new MtpDevice(device, interface->bInterfaceNumber, - ep_in_desc, ep_out_desc, ep_intr_desc); - mtpDevice->initialize(); - return mtpDevice; - } - } - - usb_device_close(device); - MTPE("device not found"); - return NULL; -} - -MtpDevice::MtpDevice(struct usb_device* device, int interface, - const struct usb_endpoint_descriptor *ep_in, - const struct usb_endpoint_descriptor *ep_out, - const struct usb_endpoint_descriptor *ep_intr) - : mDevice(device), - mInterface(interface), - mRequestIn1(NULL), - mRequestIn2(NULL), - mRequestOut(NULL), - mRequestIntr(NULL), - mDeviceInfo(NULL), - mSessionID(0), - mTransactionID(0), - mReceivedResponse(false) -{ - mRequestIn1 = usb_request_new(device, ep_in); - mRequestIn2 = usb_request_new(device, ep_in); - mRequestOut = usb_request_new(device, ep_out); - mRequestIntr = usb_request_new(device, ep_intr); -} - -MtpDevice::~MtpDevice() { - close(); - for (size_t i = 0; i < mDeviceProperties.size(); i++) - delete mDeviceProperties[i]; - usb_request_free(mRequestIn1); - usb_request_free(mRequestIn2); - usb_request_free(mRequestOut); - usb_request_free(mRequestIntr); -} - -void MtpDevice::initialize() { - openSession(); - mDeviceInfo = getDeviceInfo(); - if (mDeviceInfo) { - if (mDeviceInfo->mDeviceProperties) { - int count = mDeviceInfo->mDeviceProperties->size(); - for (int i = 0; i < count; i++) { - MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i]; - MtpProperty* property = getDevicePropDesc(propCode); - if (property) - mDeviceProperties.push(property); - } - } - } -} - -void MtpDevice::close() { - if (mDevice) { - usb_device_release_interface(mDevice, mInterface); - usb_device_close(mDevice); - mDevice = NULL; - } -} - -void MtpDevice::print() { - if (mDeviceInfo) { - mDeviceInfo->print(); - - if (mDeviceInfo->mDeviceProperties) { - MTPI("***** DEVICE PROPERTIES *****\n"); - int count = mDeviceInfo->mDeviceProperties->size(); - for (int i = 0; i < count; i++) { - MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i]; - MtpProperty* property = getDevicePropDesc(propCode); - if (property) { - property->print(); - delete property; - } - } - } - } - - if (mDeviceInfo->mPlaybackFormats) { - MTPI("***** OBJECT PROPERTIES *****\n"); - int count = mDeviceInfo->mPlaybackFormats->size(); - for (int i = 0; i < count; i++) { - MtpObjectFormat format = (*mDeviceInfo->mPlaybackFormats)[i]; - MTPI("*** FORMAT: %s\n", MtpDebug::getFormatCodeName(format)); - MtpObjectPropertyList* props = getObjectPropsSupported(format); - if (props) { - for (size_t j = 0; j < props->size(); j++) { - MtpObjectProperty prop = (*props)[j]; - MtpProperty* property = getObjectPropDesc(prop, format); - if (property) { - property->print(); - delete property; - } else { - MTPI("could not fetch property: %s", - MtpDebug::getObjectPropCodeName(prop)); - } - } - } - } - } -} - -const char* MtpDevice::getDeviceName() { - if (mDevice) - return usb_device_get_name(mDevice); - else - return "???"; -} - -bool MtpDevice::openSession() { - android::Mutex::Autolock autoLock(mMutex); - - mSessionID = 0; - mTransactionID = 0; - MtpSessionID newSession = 1; - mRequest.reset(); - mRequest.setParameter(1, newSession); - if (!sendRequest(MTP_OPERATION_OPEN_SESSION)) - return false; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_SESSION_ALREADY_OPEN) - newSession = mResponse.getParameter(1); - else if (ret != MTP_RESPONSE_OK) - return false; - - mSessionID = newSession; - mTransactionID = 1; - return true; -} - -bool MtpDevice::closeSession() { - // FIXME - return true; -} - -MtpDeviceInfo* MtpDevice::getDeviceInfo() { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - if (!sendRequest(MTP_OPERATION_GET_DEVICE_INFO)) - return NULL; - if (!readData()) - return NULL; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - MtpDeviceInfo* info = new MtpDeviceInfo; - info->read(mData); - return info; - } - return NULL; -} - -MtpStorageIDList* MtpDevice::getStorageIDs() { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - if (!sendRequest(MTP_OPERATION_GET_STORAGE_IDS)) - return NULL; - if (!readData()) - return NULL; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - return mData.getAUInt32(); - } - return NULL; -} - -MtpStorageInfo* MtpDevice::getStorageInfo(MtpStorageID storageID) { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - mRequest.setParameter(1, storageID); - if (!sendRequest(MTP_OPERATION_GET_STORAGE_INFO)) - return NULL; - if (!readData()) - return NULL; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - MtpStorageInfo* info = new MtpStorageInfo(storageID); - info->read(mData); - return info; - } - return NULL; -} - -MtpObjectHandleList* MtpDevice::getObjectHandles(MtpStorageID storageID, - MtpObjectFormat format, MtpObjectHandle parent) { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - mRequest.setParameter(1, storageID); - mRequest.setParameter(2, format); - mRequest.setParameter(3, parent); - if (!sendRequest(MTP_OPERATION_GET_OBJECT_HANDLES)) - return NULL; - if (!readData()) - return NULL; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - return mData.getAUInt32(); - } - return NULL; -} - -MtpObjectInfo* MtpDevice::getObjectInfo(MtpObjectHandle handle) { - android::Mutex::Autolock autoLock(mMutex); - - // FIXME - we might want to add some caching here - - mRequest.reset(); - mRequest.setParameter(1, handle); - if (!sendRequest(MTP_OPERATION_GET_OBJECT_INFO)) - return NULL; - if (!readData()) - return NULL; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - MtpObjectInfo* info = new MtpObjectInfo(handle); - info->read(mData); - return info; - } - return NULL; -} - -void* MtpDevice::getThumbnail(MtpObjectHandle handle, int& outLength) { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - mRequest.setParameter(1, handle); - if (sendRequest(MTP_OPERATION_GET_THUMB) && readData()) { - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - return mData.getData(outLength); - } - } - outLength = 0; - return NULL; -} - -MtpObjectHandle MtpDevice::sendObjectInfo(MtpObjectInfo* info) { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - MtpObjectHandle parent = info->mParent; - if (parent == 0) - parent = MTP_PARENT_ROOT; - - mRequest.setParameter(1, info->mStorageID); - mRequest.setParameter(2, info->mParent); - - mData.putUInt32(info->mStorageID); - mData.putUInt16(info->mFormat); - mData.putUInt16(info->mProtectionStatus); - mData.putUInt32(info->mCompressedSize); - mData.putUInt16(info->mThumbFormat); - mData.putUInt32(info->mThumbCompressedSize); - mData.putUInt32(info->mThumbPixWidth); - mData.putUInt32(info->mThumbPixHeight); - mData.putUInt32(info->mImagePixWidth); - mData.putUInt32(info->mImagePixHeight); - mData.putUInt32(info->mImagePixDepth); - mData.putUInt32(info->mParent); - mData.putUInt16(info->mAssociationType); - mData.putUInt32(info->mAssociationDesc); - mData.putUInt32(info->mSequenceNumber); - mData.putString(info->mName); - - char created[100], modified[100]; - formatDateTime(info->mDateCreated, created, sizeof(created)); - formatDateTime(info->mDateModified, modified, sizeof(modified)); - - mData.putString(created); - mData.putString(modified); - if (info->mKeywords) - mData.putString(info->mKeywords); - else - mData.putEmptyString(); - - if (sendRequest(MTP_OPERATION_SEND_OBJECT_INFO) && sendData()) { - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - info->mStorageID = mResponse.getParameter(1); - info->mParent = mResponse.getParameter(2); - info->mHandle = mResponse.getParameter(3); - return info->mHandle; - } - } - return (MtpObjectHandle)-1; -} - -bool MtpDevice::sendObject(MtpObjectInfo* info, int srcFD) { - android::Mutex::Autolock autoLock(mMutex); - - int remaining = info->mCompressedSize; - mRequest.reset(); - mRequest.setParameter(1, info->mHandle); - if (sendRequest(MTP_OPERATION_SEND_OBJECT)) { - // send data header - writeDataHeader(MTP_OPERATION_SEND_OBJECT, remaining); - - char buffer[65536]; - while (remaining > 0) { - int count = read(srcFD, buffer, sizeof(buffer)); - if (count > 0) { - int written = mData.write(mRequestOut, buffer, count); - // FIXME check error - remaining -= count; - } else { - break; - } - } - } - MtpResponseCode ret = readResponse(); - return (remaining == 0 && ret == MTP_RESPONSE_OK); -} - -bool MtpDevice::deleteObject(MtpObjectHandle handle) { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - mRequest.setParameter(1, handle); - if (sendRequest(MTP_OPERATION_DELETE_OBJECT)) { - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) - return true; - } - return false; -} - -MtpObjectHandle MtpDevice::getParent(MtpObjectHandle handle) { - MtpObjectInfo* info = getObjectInfo(handle); - if (info) { - MtpObjectHandle parent = info->mParent; - delete info; - return parent; - } else { - return -1; - } -} - -MtpObjectHandle MtpDevice::getStorageID(MtpObjectHandle handle) { - MtpObjectInfo* info = getObjectInfo(handle); - if (info) { - MtpObjectHandle storageId = info->mStorageID; - delete info; - return storageId; - } else { - return -1; - } -} - -MtpObjectPropertyList* MtpDevice::getObjectPropsSupported(MtpObjectFormat format) { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - mRequest.setParameter(1, format); - if (!sendRequest(MTP_OPERATION_GET_OBJECT_PROPS_SUPPORTED)) - return NULL; - if (!readData()) - return NULL; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - return mData.getAUInt16(); - } - return NULL; - -} - -MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - mRequest.setParameter(1, code); - if (!sendRequest(MTP_OPERATION_GET_DEVICE_PROP_DESC)) - return NULL; - if (!readData()) - return NULL; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - MtpProperty* property = new MtpProperty; - property->read(mData); - return property; - } - return NULL; -} - -MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format) { - android::Mutex::Autolock autoLock(mMutex); - - mRequest.reset(); - mRequest.setParameter(1, code); - mRequest.setParameter(2, format); - if (!sendRequest(MTP_OPERATION_GET_OBJECT_PROP_DESC)) - return NULL; - if (!readData()) - return NULL; - MtpResponseCode ret = readResponse(); - if (ret == MTP_RESPONSE_OK) { - MtpProperty* property = new MtpProperty; - property->read(mData); - return property; - } - return NULL; -} - -bool MtpDevice::readObject(MtpObjectHandle handle, - bool (* callback)(void* data, int offset, int length, void* clientData), - int objectSize, void* clientData) { - android::Mutex::Autolock autoLock(mMutex); - bool result = false; - - mRequest.reset(); - mRequest.setParameter(1, handle); - if (sendRequest(MTP_OPERATION_GET_OBJECT) - && mData.readDataHeader(mRequestIn1)) { - uint32_t length = mData.getContainerLength(); - if ((int)length - MTP_CONTAINER_HEADER_SIZE != objectSize) { - MTPE("readObject error objectSize: %d, length: %d", - objectSize, length); - goto fail; - } - length -= MTP_CONTAINER_HEADER_SIZE; - uint32_t remaining = length; - int offset = 0; - - int initialDataLength = 0; - void* initialData = mData.getData(initialDataLength); - if (initialData) { - if (initialDataLength > 0) { - if (!callback(initialData, 0, initialDataLength, clientData)) - goto fail; - remaining -= initialDataLength; - offset += initialDataLength; - } - free(initialData); - } - - // USB reads greater than 16K don't work - char buffer1[16384], buffer2[16384]; - mRequestIn1->buffer = buffer1; - mRequestIn2->buffer = buffer2; - struct usb_request* req = mRequestIn1; - void* writeBuffer = NULL; - int writeLength = 0; - - while (remaining > 0 || writeBuffer) { - if (remaining > 0) { - // queue up a read request - req->buffer_length = (remaining > sizeof(buffer1) ? sizeof(buffer1) : remaining); - if (mData.readDataAsync(req)) { - MTPE("readDataAsync failed"); - goto fail; - } - } else { - req = NULL; - } - - if (writeBuffer) { - // write previous buffer - if (!callback(writeBuffer, offset, writeLength, clientData)) { - MTPE("write failed"); - // wait for pending read before failing - if (req) - mData.readDataWait(mDevice); - goto fail; - } - offset += writeLength; - writeBuffer = NULL; - } - - // wait for read to complete - if (req) { - int read = mData.readDataWait(mDevice); - if (read < 0) - goto fail; - - if (read > 0) { - writeBuffer = req->buffer; - writeLength = read; - remaining -= read; - req = (req == mRequestIn1 ? mRequestIn2 : mRequestIn1); - } else { - writeBuffer = NULL; - } - } - } - - MtpResponseCode response = readResponse(); - if (response == MTP_RESPONSE_OK) - result = true; - } - -fail: - return result; -} - - -// reads the object's data and writes it to the specified file path -bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) { - MTPI("readObject: %s", destPath); - int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC, 0640); - if (fd < 0) { - MTPE("open failed for %s", destPath); - return false; - } - - fchown(fd, getuid(), group); - // set permissions - int mask = umask(0); - fchmod(fd, perm); - umask(mask); - - android::Mutex::Autolock autoLock(mMutex); - bool result = false; - - mRequest.reset(); - mRequest.setParameter(1, handle); - if (sendRequest(MTP_OPERATION_GET_OBJECT) - && mData.readDataHeader(mRequestIn1)) { - uint32_t length = mData.getContainerLength(); - if (length < MTP_CONTAINER_HEADER_SIZE) - goto fail; - length -= MTP_CONTAINER_HEADER_SIZE; - uint32_t remaining = length; - - int initialDataLength = 0; - void* initialData = mData.getData(initialDataLength); - if (initialData) { - if (initialDataLength > 0) { - if (write(fd, initialData, initialDataLength) != initialDataLength) { - free(initialData); - goto fail; - } - remaining -= initialDataLength; - } - free(initialData); - } - - // USB reads greater than 16K don't work - char buffer1[16384], buffer2[16384]; - mRequestIn1->buffer = buffer1; - mRequestIn2->buffer = buffer2; - struct usb_request* req = mRequestIn1; - void* writeBuffer = NULL; - int writeLength = 0; - - while (remaining > 0 || writeBuffer) { - if (remaining > 0) { - // queue up a read request - req->buffer_length = (remaining > sizeof(buffer1) ? sizeof(buffer1) : remaining); - if (mData.readDataAsync(req)) { - MTPE("readDataAsync failed"); - goto fail; - } - } else { - req = NULL; - } - - if (writeBuffer) { - // write previous buffer - if (write(fd, writeBuffer, writeLength) != writeLength) { - MTPE("write failed"); - // wait for pending read before failing - if (req) - mData.readDataWait(mDevice); - goto fail; - } - writeBuffer = NULL; - } - - // wait for read to complete - if (req) { - int read = mData.readDataWait(mDevice); - if (read < 0) - goto fail; - - if (read > 0) { - writeBuffer = req->buffer; - writeLength = read; - remaining -= read; - req = (req == mRequestIn1 ? mRequestIn2 : mRequestIn1); - } else { - writeBuffer = NULL; - } - } - } - - MtpResponseCode response = readResponse(); - if (response == MTP_RESPONSE_OK) - result = true; - } - -fail: - ::close(fd); - return result; -} - -bool MtpDevice::sendRequest(MtpOperationCode operation) { - MTPD("sendRequest: %s\n", MtpDebug::getOperationCodeName(operation)); - mReceivedResponse = false; - mRequest.setOperationCode(operation); - if (mTransactionID > 0) - mRequest.setTransactionID(mTransactionID++); - int ret = mRequest.write(mRequestOut); - mRequest.dump(); - return (ret > 0); -} - -bool MtpDevice::sendData() { - MTPD("sendData\n"); - mData.setOperationCode(mRequest.getOperationCode()); - mData.setTransactionID(mRequest.getTransactionID()); - int ret = mData.write(mRequestOut); - mData.dump(); - return (ret > 0); -} - -bool MtpDevice::readData() { - mData.reset(); - int ret = mData.read(mRequestIn1); - MTPD("readData returned %d\n", ret); - if (ret >= MTP_CONTAINER_HEADER_SIZE) { - if (mData.getContainerType() == MTP_CONTAINER_TYPE_RESPONSE) { - MTPD("got response packet instead of data packet"); - // we got a response packet rather than data - // copy it to mResponse - mResponse.copyFrom(mData); - mReceivedResponse = true; - return false; - } - mData.dump(); - return true; - } - else { - MTPE("readResponse failed\n"); - return false; - } -} - -bool MtpDevice::writeDataHeader(MtpOperationCode operation, int dataLength) { - mData.setOperationCode(operation); - mData.setTransactionID(mRequest.getTransactionID()); - return (!mData.writeDataHeader(mRequestOut, dataLength)); -} - -MtpResponseCode MtpDevice::readResponse() { - MTPD("readResponse\n"); - if (mReceivedResponse) { - mReceivedResponse = false; - return mResponse.getResponseCode(); - } - int ret = mResponse.read(mRequestIn1); - // handle zero length packets, which might occur if the data transfer - // ends on a packet boundary - if (ret == 0) - ret = mResponse.read(mRequestIn1); - if (ret >= MTP_CONTAINER_HEADER_SIZE) { - mResponse.dump(); - return mResponse.getResponseCode(); - } else { - MTPE("readResponse failed\n"); - return -1; - } -} diff --git a/mtp/legacy/MtpDevice.h b/mtp/legacy/MtpDevice.h deleted file mode 100644 index 34b39ecb..00000000 --- a/mtp/legacy/MtpDevice.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_DEVICE_H -#define _MTP_DEVICE_H - -#include "MtpRequestPacket.h" -#include "MtpDataPacket.h" -#include "MtpResponsePacket.h" -#include "MtpTypes.h" - -#include - -struct usb_device; -struct usb_request; -struct usb_endpoint_descriptor; - - -class MtpDeviceInfo; -class MtpObjectInfo; -class MtpStorageInfo; - -class MtpDevice { -private: - struct usb_device* mDevice; - int mInterface; - struct usb_request* mRequestIn1; - struct usb_request* mRequestIn2; - struct usb_request* mRequestOut; - struct usb_request* mRequestIntr; - MtpDeviceInfo* mDeviceInfo; - MtpPropertyList mDeviceProperties; - - // current session ID - MtpSessionID mSessionID; - // current transaction ID - MtpTransactionID mTransactionID; - - MtpRequestPacket mRequest; - MtpDataPacket mData; - MtpResponsePacket mResponse; - // set to true if we received a response packet instead of a data packet - bool mReceivedResponse; - - // to ensure only one MTP transaction at a time - android::Mutex mMutex; - -public: - MtpDevice(struct usb_device* device, int interface, - const struct usb_endpoint_descriptor *ep_in, - const struct usb_endpoint_descriptor *ep_out, - const struct usb_endpoint_descriptor *ep_intr); - - static MtpDevice* open(const char* deviceName, int fd); - - virtual ~MtpDevice(); - - void initialize(); - void close(); - void print(); - const char* getDeviceName(); - - bool openSession(); - bool closeSession(); - - MtpDeviceInfo* getDeviceInfo(); - MtpStorageIDList* getStorageIDs(); - MtpStorageInfo* getStorageInfo(MtpStorageID storageID); - MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, - MtpObjectHandle parent); - MtpObjectInfo* getObjectInfo(MtpObjectHandle handle); - void* getThumbnail(MtpObjectHandle handle, int& outLength); - MtpObjectHandle sendObjectInfo(MtpObjectInfo* info); - bool sendObject(MtpObjectInfo* info, int srcFD); - bool deleteObject(MtpObjectHandle handle); - MtpObjectHandle getParent(MtpObjectHandle handle); - MtpObjectHandle getStorageID(MtpObjectHandle handle); - - MtpObjectPropertyList* getObjectPropsSupported(MtpObjectFormat format); - - MtpProperty* getDevicePropDesc(MtpDeviceProperty code); - MtpProperty* getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format); - - bool readObject(MtpObjectHandle handle, - bool (* callback)(void* data, int offset, - int length, void* clientData), - int objectSize, void* clientData); - bool readObject(MtpObjectHandle handle, const char* destPath, int group, - int perm); - -private: - bool sendRequest(MtpOperationCode operation); - bool sendData(); - bool readData(); - bool writeDataHeader(MtpOperationCode operation, int dataLength); - MtpResponseCode readResponse(); - -}; - - -#endif // _MTP_DEVICE_H diff --git a/mtp/legacy/MtpDeviceInfo.cpp b/mtp/legacy/MtpDeviceInfo.cpp deleted file mode 100644 index 337cc130..00000000 --- a/mtp/legacy/MtpDeviceInfo.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include "MtpDebug.h" -#include "MtpDataPacket.h" -#include "MtpDeviceInfo.h" -#include "MtpStringBuffer.h" - -MtpDeviceInfo::MtpDeviceInfo() - : mStandardVersion(0), - mVendorExtensionID(0), - mVendorExtensionVersion(0), - mVendorExtensionDesc(NULL), - mFunctionalCode(0), - mOperations(NULL), - mEvents(NULL), - mDeviceProperties(NULL), - mCaptureFormats(NULL), - mPlaybackFormats(NULL), - mManufacturer(NULL), - mModel(NULL), - mVersion(NULL), - mSerial(NULL) -{ -} - -MtpDeviceInfo::~MtpDeviceInfo() { - if (mVendorExtensionDesc) - free(mVendorExtensionDesc); - delete mOperations; - delete mEvents; - delete mDeviceProperties; - delete mCaptureFormats; - delete mPlaybackFormats; - if (mManufacturer) - free(mManufacturer); - if (mModel) - free(mModel); - if (mVersion) - free(mVersion); - if (mSerial) - free(mSerial); -} - -void MtpDeviceInfo::read(MtpDataPacket& packet) { - MtpStringBuffer string; - - // read the device info - mStandardVersion = packet.getUInt16(); - mVendorExtensionID = packet.getUInt32(); - mVendorExtensionVersion = packet.getUInt16(); - - packet.getString(string); - mVendorExtensionDesc = strdup((const char *)string); - - mFunctionalCode = packet.getUInt16(); - mOperations = packet.getAUInt16(); - mEvents = packet.getAUInt16(); - mDeviceProperties = packet.getAUInt16(); - mCaptureFormats = packet.getAUInt16(); - mPlaybackFormats = packet.getAUInt16(); - - packet.getString(string); - mManufacturer = strdup((const char *)string); - packet.getString(string); - mModel = strdup((const char *)string); - packet.getString(string); - mVersion = strdup((const char *)string); - packet.getString(string); - mSerial = strdup((const char *)string); -} - -void MtpDeviceInfo::print() { - MTPI("Device Info:\n\tmStandardVersion: %d\n\tmVendorExtensionID: %d\n\tmVendorExtensionVersiony: %d\n", - mStandardVersion, mVendorExtensionID, mVendorExtensionVersion); - MTPI("\tmVendorExtensionDesc: %s\n\tmFunctionalCode: %d\n\tmManufacturer: %s\n\tmModel: %s\n\tmVersion: %s\n\tmSerial: %s\n", - mVendorExtensionDesc, mFunctionalCode, mManufacturer, mModel, mVersion, mSerial); -} - diff --git a/mtp/legacy/MtpDeviceInfo.h b/mtp/legacy/MtpDeviceInfo.h deleted file mode 100644 index 264e199d..00000000 --- a/mtp/legacy/MtpDeviceInfo.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_DEVICE_INFO_H -#define _MTP_DEVICE_INFO_H - -struct stat; - - -class MtpDataPacket; - -class MtpDeviceInfo { -public: - uint16_t mStandardVersion; - uint32_t mVendorExtensionID; - uint16_t mVendorExtensionVersion; - char* mVendorExtensionDesc; - uint16_t mFunctionalCode; - UInt16List* mOperations; - UInt16List* mEvents; - MtpDevicePropertyList* mDeviceProperties; - MtpObjectFormatList* mCaptureFormats; - MtpObjectFormatList* mPlaybackFormats; - char* mManufacturer; - char* mModel; - char* mVersion; - char* mSerial; - -public: - MtpDeviceInfo(); - virtual ~MtpDeviceInfo(); - - void read(MtpDataPacket& packet); - - void print(); -}; - - -#endif // _MTP_DEVICE_INFO_H diff --git a/mtp/legacy/MtpEventPacket.cpp b/mtp/legacy/MtpEventPacket.cpp deleted file mode 100644 index 1119f7d5..00000000 --- a/mtp/legacy/MtpEventPacket.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include -#include -#include -#include - -#ifdef MTP_DEVICE -#include -#endif - -#include "MtpEventPacket.h" - -#include - - -MtpEventPacket::MtpEventPacket() - : MtpPacket(512) -{ -} - -MtpEventPacket::~MtpEventPacket() { -} - -#ifdef MTP_DEVICE -int MtpEventPacket::write(int fd) { - struct mtp_event event; - - putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); - putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_EVENT); - - event.data = mBuffer; - event.length = mPacketSize; - int ret = ::ioctl(fd, MTP_SEND_EVENT, (unsigned long)&event); - return (ret < 0 ? ret : 0); -} -#endif - -#ifdef MTP_HOST -int MtpEventPacket::read(struct usb_request *request) { - request->buffer = mBuffer; - request->buffer_length = mBufferSize; - int ret = transfer(request); - if (ret >= 0) - mPacketSize = ret; - else - mPacketSize = 0; - return ret; -} -#endif - - diff --git a/mtp/legacy/MtpEventPacket.h b/mtp/legacy/MtpEventPacket.h deleted file mode 100644 index 64398560..00000000 --- a/mtp/legacy/MtpEventPacket.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_EVENT_PACKET_H -#define _MTP_EVENT_PACKET_H - -#include "MtpPacket.h" -#include "mtp.h" - -class MtpEventPacket : public MtpPacket { - -public: - MtpEventPacket(); - virtual ~MtpEventPacket(); - -#ifdef MTP_DEVICE - // write our data to the given file descriptor - int write(int fd); -#endif - -#ifdef MTP_HOST - // read our buffer with the given request - int read(struct usb_request *request); -#endif - - inline MtpEventCode getEventCode() const { return getContainerCode(); } - inline void setEventCode(MtpEventCode code) - { return setContainerCode(code); } -}; - -#endif // _MTP_EVENT_PACKET_H diff --git a/mtp/legacy/MtpMessage.hpp b/mtp/legacy/MtpMessage.hpp deleted file mode 100644 index 31465d8c..00000000 --- a/mtp/legacy/MtpMessage.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTPMESSAGE_HPP -#define _MTPMESSAGE_HPP - -#define MTP_MESSAGE_ADD_STORAGE 1 -#define MTP_MESSAGE_REMOVE_STORAGE 2 - -struct mtpmsg { - int message_type; // 1 is add, 2 is remove, see above - unsigned int storage_id; - char display[1024]; - char path[1024]; - uint64_t maxFileSize; -}; - -#endif //_MTPMESSAGE_HPP diff --git a/mtp/legacy/MtpObjectInfo.cpp b/mtp/legacy/MtpObjectInfo.cpp deleted file mode 100644 index 50192d73..00000000 --- a/mtp/legacy/MtpObjectInfo.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include "MtpDebug.h" -#include "MtpDataPacket.h" -#include "MtpObjectInfo.h" -#include "MtpStringBuffer.h" -#include "MtpUtils.h" - -MtpObjectInfo::MtpObjectInfo(MtpObjectHandle handle) - : mHandle(handle), - mStorageID(0), - mFormat(0), - mProtectionStatus(0), - mCompressedSize(0), - mThumbFormat(0), - mThumbCompressedSize(0), - mThumbPixWidth(0), - mThumbPixHeight(0), - mImagePixWidth(0), - mImagePixHeight(0), - mImagePixDepth(0), - mParent(0), - mAssociationType(0), - mAssociationDesc(0), - mSequenceNumber(0), - mName(NULL), - mDateCreated(0), - mDateModified(0), - mKeywords(NULL) -{ -} - -MtpObjectInfo::~MtpObjectInfo() { - if (mName) - free(mName); - if (mKeywords) - free(mKeywords); -} - -void MtpObjectInfo::read(MtpDataPacket& packet) { - MtpStringBuffer string; - time_t time; - - mStorageID = packet.getUInt32(); - mFormat = packet.getUInt16(); - mProtectionStatus = packet.getUInt16(); - mCompressedSize = packet.getUInt32(); - mThumbFormat = packet.getUInt16(); - mThumbCompressedSize = packet.getUInt32(); - mThumbPixWidth = packet.getUInt32(); - mThumbPixHeight = packet.getUInt32(); - mImagePixWidth = packet.getUInt32(); - mImagePixHeight = packet.getUInt32(); - mImagePixDepth = packet.getUInt32(); - mParent = packet.getUInt32(); - mAssociationType = packet.getUInt16(); - mAssociationDesc = packet.getUInt32(); - mSequenceNumber = packet.getUInt32(); - - packet.getString(string); - mName = strdup((const char *)string); - - packet.getString(string); - if (parseDateTime((const char*)string, time)) - mDateCreated = time; - - packet.getString(string); - if (parseDateTime((const char*)string, time)) - mDateModified = time; - - packet.getString(string); - mKeywords = strdup((const char *)string); -} - -void MtpObjectInfo::print() { - MTPI("MtpObject Info %08X: %s\n", mHandle, mName); - MTPI(" mStorageID: %08X mFormat: %04X mProtectionStatus: %d\n", - mStorageID, mFormat, mProtectionStatus); - MTPI(" mCompressedSize: %d mThumbFormat: %04X mThumbCompressedSize: %d\n", - mCompressedSize, mFormat, mThumbCompressedSize); - MTPI(" mThumbPixWidth: %d mThumbPixHeight: %d\n", mThumbPixWidth, mThumbPixHeight); - MTPI(" mImagePixWidth: %d mImagePixHeight: %d mImagePixDepth: %d\n", - mImagePixWidth, mImagePixHeight, mImagePixDepth); - MTPI(" mParent: %08X mAssociationType: %04X mAssociationDesc: %04X\n", - mParent, mAssociationType, mAssociationDesc); - MTPI(" mSequenceNumber: %d mDateCreated: %ld mDateModified: %ld mKeywords: %s\n", - mSequenceNumber, mDateCreated, mDateModified, mKeywords); -} - diff --git a/mtp/legacy/MtpObjectInfo.h b/mtp/legacy/MtpObjectInfo.h deleted file mode 100644 index 9b023bce..00000000 --- a/mtp/legacy/MtpObjectInfo.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_OBJECT_INFO_H -#define _MTP_OBJECT_INFO_H - -#include "MtpTypes.h" - - -class MtpDataPacket; - -class MtpObjectInfo { -public: - MtpObjectHandle mHandle; - MtpStorageID mStorageID; - MtpObjectFormat mFormat; - uint16_t mProtectionStatus; - uint32_t mCompressedSize; - MtpObjectFormat mThumbFormat; - uint32_t mThumbCompressedSize; - uint32_t mThumbPixWidth; - uint32_t mThumbPixHeight; - uint32_t mImagePixWidth; - uint32_t mImagePixHeight; - uint32_t mImagePixDepth; - MtpObjectHandle mParent; - uint16_t mAssociationType; - uint32_t mAssociationDesc; - uint32_t mSequenceNumber; - char* mName; - time_t mDateCreated; - time_t mDateModified; - char* mKeywords; - -public: - MtpObjectInfo(MtpObjectHandle handle); - virtual ~MtpObjectInfo(); - - void read(MtpDataPacket& packet); - - void print(); -}; - - -#endif // _MTP_OBJECT_INFO_H diff --git a/mtp/legacy/MtpPacket.cpp b/mtp/legacy/MtpPacket.cpp deleted file mode 100644 index 2f9e438b..00000000 --- a/mtp/legacy/MtpPacket.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include "MtpDebug.h" -#include "MtpPacket.h" -#include "mtp.h" - -#include -#include -#include - -#include - - -MtpPacket::MtpPacket(int bufferSize) - : mBuffer(NULL), - mBufferSize(bufferSize), - mAllocationIncrement(bufferSize), - mPacketSize(0) -{ - mBuffer = (uint8_t *)malloc(bufferSize); - if (!mBuffer) { - MTPE("out of memory!"); - abort(); - } -} - -MtpPacket::~MtpPacket() { - if (mBuffer) - free(mBuffer); -} - -void MtpPacket::reset() { - allocate(MTP_CONTAINER_HEADER_SIZE); - mPacketSize = MTP_CONTAINER_HEADER_SIZE; - memset(mBuffer, 0, mBufferSize); -} - -void MtpPacket::allocate(int length) { - if (length > mBufferSize) { - int newLength = length + mAllocationIncrement; - mBuffer = (uint8_t *)realloc(mBuffer, newLength); - if (!mBuffer) { - MTPE("out of memory!"); - abort(); - } - mBufferSize = newLength; - } -} - -void MtpPacket::dump() { -#define DUMP_BYTES_PER_ROW 16 - char buffer[500]; - char* bufptr = buffer; - - for (size_t i = 0; i < mPacketSize; i++) { - sprintf(bufptr, "%02X ", mBuffer[i]); - bufptr += strlen(bufptr); - if (i % DUMP_BYTES_PER_ROW == (DUMP_BYTES_PER_ROW - 1)) { - MTPD("%s", buffer); - bufptr = buffer; - } - } - if (bufptr != buffer) { - // print last line - MTPD("%s", buffer); - } - MTPD("\n"); -} - -void MtpPacket::copyFrom(const MtpPacket& src) { - int length = src.mPacketSize; - allocate(length); - mPacketSize = length; - memcpy(mBuffer, src.mBuffer, length); -} - -uint16_t MtpPacket::getUInt16(int offset) const { - return ((uint16_t)mBuffer[offset + 1] << 8) | (uint16_t)mBuffer[offset]; -} - -uint32_t MtpPacket::getUInt32(int offset) const { - return ((uint32_t)mBuffer[offset + 3] << 24) | ((uint32_t)mBuffer[offset + 2] << 16) | - ((uint32_t)mBuffer[offset + 1] << 8) | (uint32_t)mBuffer[offset]; -} - -void MtpPacket::putUInt16(int offset, uint16_t value) { - mBuffer[offset++] = (uint8_t)(value & 0xFF); - mBuffer[offset++] = (uint8_t)((value >> 8) & 0xFF); -} - -void MtpPacket::putUInt32(int offset, uint32_t value) { - mBuffer[offset++] = (uint8_t)(value & 0xFF); - mBuffer[offset++] = (uint8_t)((value >> 8) & 0xFF); - mBuffer[offset++] = (uint8_t)((value >> 16) & 0xFF); - mBuffer[offset++] = (uint8_t)((value >> 24) & 0xFF); -} - -uint16_t MtpPacket::getContainerCode() const { - return getUInt16(MTP_CONTAINER_CODE_OFFSET); -} - -void MtpPacket::setContainerCode(uint16_t code) { - putUInt16(MTP_CONTAINER_CODE_OFFSET, code); -} - -uint16_t MtpPacket::getContainerType() const { - return getUInt16(MTP_CONTAINER_TYPE_OFFSET); -} - -MtpTransactionID MtpPacket::getTransactionID() const { - return getUInt32(MTP_CONTAINER_TRANSACTION_ID_OFFSET); -} - -void MtpPacket::setTransactionID(MtpTransactionID id) { - putUInt32(MTP_CONTAINER_TRANSACTION_ID_OFFSET, id); -} - -uint32_t MtpPacket::getParameter(int index) const { - if (index < 1 || index > 5) { - MTPE("index %d out of range in MtpPacket::getParameter", index); - return 0; - } - return getUInt32(MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t)); -} - -void MtpPacket::setParameter(int index, uint32_t value) { - if (index < 1 || index > 5) { - MTPE("index %d out of range in MtpPacket::setParameter", index); - return; - } - int offset = MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t); - if (mPacketSize < offset + sizeof(uint32_t)) - mPacketSize = offset + sizeof(uint32_t); - putUInt32(offset, value); -} - -#ifdef MTP_HOST -int MtpPacket::transfer(struct usb_request* request) { - int result = usb_device_bulk_transfer(request->dev, - request->endpoint, - request->buffer, - request->buffer_length, - 0); - request->actual_length = result; - return result; -} -#endif - diff --git a/mtp/legacy/MtpPacket.h b/mtp/legacy/MtpPacket.h deleted file mode 100644 index be3db309..00000000 --- a/mtp/legacy/MtpPacket.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_PACKET_H -#define _MTP_PACKET_H - -#include "MtpTypes.h" - -struct usb_request; - - -class MtpPacket { - -protected: - uint8_t* mBuffer; - // current size of the buffer - int mBufferSize; - // number of bytes to add when resizing the buffer - int mAllocationIncrement; - // size of the data in the packet - unsigned mPacketSize; - -public: - MtpPacket(int bufferSize); - virtual ~MtpPacket(); - - // sets packet size to the default container size and sets buffer to zero - virtual void reset(); - - void allocate(int length); - void dump(); - void copyFrom(const MtpPacket& src); - - uint16_t getContainerCode() const; - void setContainerCode(uint16_t code); - - uint16_t getContainerType() const; - - MtpTransactionID getTransactionID() const; - void setTransactionID(MtpTransactionID id); - - uint32_t getParameter(int index) const; - void setParameter(int index, uint32_t value); - -#ifdef MTP_HOST - int transfer(struct usb_request* request); -#endif - -protected: - uint16_t getUInt16(int offset) const; - uint32_t getUInt32(int offset) const; - void putUInt16(int offset, uint16_t value); - void putUInt32(int offset, uint32_t value); -}; - - -#endif // _MTP_PACKET_H diff --git a/mtp/legacy/MtpProperty.cpp b/mtp/legacy/MtpProperty.cpp deleted file mode 100644 index e105f249..00000000 --- a/mtp/legacy/MtpProperty.cpp +++ /dev/null @@ -1,531 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include "MtpDataPacket.h" -#include "MtpDebug.h" -#include "MtpProperty.h" -#include "MtpStringBuffer.h" -#include "MtpUtils.h" - -MtpProperty::MtpProperty() - : mCode(0), - mType(0), - mWriteable(false), - mDefaultArrayLength(0), - mDefaultArrayValues(NULL), - mCurrentArrayLength(0), - mCurrentArrayValues(NULL), - mGroupCode(0), - mFormFlag(kFormNone), - mEnumLength(0), - mEnumValues(NULL) -{ - memset(&mDefaultValue, 0, sizeof(mDefaultValue)); - memset(&mCurrentValue, 0, sizeof(mCurrentValue)); - memset(&mMinimumValue, 0, sizeof(mMinimumValue)); - memset(&mMaximumValue, 0, sizeof(mMaximumValue)); -} - -MtpProperty::MtpProperty(MtpPropertyCode propCode, - MtpDataType type, - bool writeable, - int defaultValue) - : mCode(propCode), - mType(type), - mWriteable(writeable), - mDefaultArrayLength(0), - mDefaultArrayValues(NULL), - mCurrentArrayLength(0), - mCurrentArrayValues(NULL), - mGroupCode(0), - mFormFlag(kFormNone), - mEnumLength(0), - mEnumValues(NULL) -{ - memset(&mDefaultValue, 0, sizeof(mDefaultValue)); - memset(&mCurrentValue, 0, sizeof(mCurrentValue)); - memset(&mMinimumValue, 0, sizeof(mMinimumValue)); - memset(&mMaximumValue, 0, sizeof(mMaximumValue)); - - if (defaultValue) { - switch (type) { - case MTP_TYPE_INT8: - mDefaultValue.u.i8 = defaultValue; - break; - case MTP_TYPE_UINT8: - mDefaultValue.u.u8 = defaultValue; - break; - case MTP_TYPE_INT16: - mDefaultValue.u.i16 = defaultValue; - break; - case MTP_TYPE_UINT16: - mDefaultValue.u.u16 = defaultValue; - break; - case MTP_TYPE_INT32: - mDefaultValue.u.i32 = defaultValue; - break; - case MTP_TYPE_UINT32: - mDefaultValue.u.u32 = defaultValue; - break; - case MTP_TYPE_INT64: - mDefaultValue.u.i64 = defaultValue; - break; - case MTP_TYPE_UINT64: - mDefaultValue.u.u64 = defaultValue; - break; - default: - MTPE("unknown type %04X in MtpProperty::MtpProperty", type); - } - } -} - -MtpProperty::~MtpProperty() { - if (mType == MTP_TYPE_STR) { - // free all strings - free(mDefaultValue.str); - free(mCurrentValue.str); - free(mMinimumValue.str); - free(mMaximumValue.str); - if (mDefaultArrayValues) { - for (int i = 0; i < mDefaultArrayLength; i++) - free(mDefaultArrayValues[i].str); - } - if (mCurrentArrayValues) { - for (int i = 0; i < mCurrentArrayLength; i++) - free(mCurrentArrayValues[i].str); - } - if (mEnumValues) { - for (int i = 0; i < mEnumLength; i++) - free(mEnumValues[i].str); - } - } - delete[] mDefaultArrayValues; - delete[] mCurrentArrayValues; - delete[] mEnumValues; -} - -void MtpProperty::read(MtpDataPacket& packet) { - mCode = packet.getUInt16(); - bool deviceProp = isDeviceProperty(); - mType = packet.getUInt16(); - mWriteable = (packet.getUInt8() == 1); - switch (mType) { - case MTP_TYPE_AINT8: - case MTP_TYPE_AUINT8: - case MTP_TYPE_AINT16: - case MTP_TYPE_AUINT16: - case MTP_TYPE_AINT32: - case MTP_TYPE_AUINT32: - case MTP_TYPE_AINT64: - case MTP_TYPE_AUINT64: - case MTP_TYPE_AINT128: - case MTP_TYPE_AUINT128: - mDefaultArrayValues = readArrayValues(packet, mDefaultArrayLength); - if (deviceProp) - mCurrentArrayValues = readArrayValues(packet, mCurrentArrayLength); - break; - default: - readValue(packet, mDefaultValue); - if (deviceProp) - readValue(packet, mCurrentValue); - } - if (!deviceProp) - mGroupCode = packet.getUInt32(); - mFormFlag = packet.getUInt8(); - - if (mFormFlag == kFormRange) { - readValue(packet, mMinimumValue); - readValue(packet, mMaximumValue); - readValue(packet, mStepSize); - } else if (mFormFlag == kFormEnum) { - mEnumLength = packet.getUInt16(); - mEnumValues = new MtpPropertyValue[mEnumLength]; - for (int i = 0; i < mEnumLength; i++) - readValue(packet, mEnumValues[i]); - } -} - -void MtpProperty::write(MtpDataPacket& packet) { - bool deviceProp = isDeviceProperty(); - - packet.putUInt16(mCode); - packet.putUInt16(mType); - packet.putUInt8(mWriteable ? 1 : 0); - - switch (mType) { - case MTP_TYPE_AINT8: - case MTP_TYPE_AUINT8: - case MTP_TYPE_AINT16: - case MTP_TYPE_AUINT16: - case MTP_TYPE_AINT32: - case MTP_TYPE_AUINT32: - case MTP_TYPE_AINT64: - case MTP_TYPE_AUINT64: - case MTP_TYPE_AINT128: - case MTP_TYPE_AUINT128: - writeArrayValues(packet, mDefaultArrayValues, mDefaultArrayLength); - if (deviceProp) - writeArrayValues(packet, mCurrentArrayValues, mCurrentArrayLength); - break; - default: - writeValue(packet, mDefaultValue); - if (deviceProp) - writeValue(packet, mCurrentValue); - } - packet.putUInt32(mGroupCode); - if (!deviceProp) - packet.putUInt8(mFormFlag); - if (mFormFlag == kFormRange) { - writeValue(packet, mMinimumValue); - writeValue(packet, mMaximumValue); - writeValue(packet, mStepSize); - } else if (mFormFlag == kFormEnum) { - packet.putUInt16(mEnumLength); - for (int i = 0; i < mEnumLength; i++) - writeValue(packet, mEnumValues[i]); - } -} - -void MtpProperty::setDefaultValue(const uint16_t* string) { - free(mDefaultValue.str); - if (string) { - MtpStringBuffer buffer(string); - mDefaultValue.str = strdup(buffer); - } - else - mDefaultValue.str = NULL; -} - -void MtpProperty::setCurrentValue(const uint16_t* string) { - free(mCurrentValue.str); - if (string) { - MtpStringBuffer buffer(string); - mCurrentValue.str = strdup(buffer); - } - else - mCurrentValue.str = NULL; -} - -void MtpProperty::setFormRange(int min, int max, int step) { - mFormFlag = kFormRange; - switch (mType) { - case MTP_TYPE_INT8: - mMinimumValue.u.i8 = min; - mMaximumValue.u.i8 = max; - mStepSize.u.i8 = step; - break; - case MTP_TYPE_UINT8: - mMinimumValue.u.u8 = min; - mMaximumValue.u.u8 = max; - mStepSize.u.u8 = step; - break; - case MTP_TYPE_INT16: - mMinimumValue.u.i16 = min; - mMaximumValue.u.i16 = max; - mStepSize.u.i16 = step; - break; - case MTP_TYPE_UINT16: - mMinimumValue.u.u16 = min; - mMaximumValue.u.u16 = max; - mStepSize.u.u16 = step; - break; - case MTP_TYPE_INT32: - mMinimumValue.u.i32 = min; - mMaximumValue.u.i32 = max; - mStepSize.u.i32 = step; - break; - case MTP_TYPE_UINT32: - mMinimumValue.u.u32 = min; - mMaximumValue.u.u32 = max; - mStepSize.u.u32 = step; - break; - case MTP_TYPE_INT64: - mMinimumValue.u.i64 = min; - mMaximumValue.u.i64 = max; - mStepSize.u.i64 = step; - break; - case MTP_TYPE_UINT64: - mMinimumValue.u.u64 = min; - mMaximumValue.u.u64 = max; - mStepSize.u.u64 = step; - break; - default: - MTPE("unsupported type for MtpProperty::setRange"); - break; - } -} - -void MtpProperty::setFormEnum(const int* values, int count) { - mFormFlag = kFormEnum; - delete[] mEnumValues; - mEnumValues = new MtpPropertyValue[count]; - mEnumLength = count; - - for (int i = 0; i < count; i++) { - int value = *values++; - switch (mType) { - case MTP_TYPE_INT8: - mEnumValues[i].u.i8 = value; - break; - case MTP_TYPE_UINT8: - mEnumValues[i].u.u8 = value; - break; - case MTP_TYPE_INT16: - mEnumValues[i].u.i16 = value; - break; - case MTP_TYPE_UINT16: - mEnumValues[i].u.u16 = value; - break; - case MTP_TYPE_INT32: - mEnumValues[i].u.i32 = value; - break; - case MTP_TYPE_UINT32: - mEnumValues[i].u.u32 = value; - break; - case MTP_TYPE_INT64: - mEnumValues[i].u.i64 = value; - break; - case MTP_TYPE_UINT64: - mEnumValues[i].u.u64 = value; - break; - default: - MTPE("unsupported type for MtpProperty::setEnum"); - break; - } - } -} - -void MtpProperty::setFormDateTime() { - mFormFlag = kFormDateTime; -} - -void MtpProperty::print() { - MtpString buffer; - bool deviceProp = isDeviceProperty(); - if (deviceProp) - MTPI(" %s (%04X)", MtpDebug::getDevicePropCodeName(mCode), mCode); - else - MTPI(" %s (%04X)", MtpDebug::getObjectPropCodeName(mCode), mCode); - MTPI(" type %04X", mType); - MTPI(" writeable %s", (mWriteable ? "true" : "false")); - buffer = " default value: "; - print(mDefaultValue, buffer); - MTPI("%s", (const char *)buffer); - if (deviceProp) { - buffer = " current value: "; - print(mCurrentValue, buffer); - MTPI("%s", (const char *)buffer); - } - switch (mFormFlag) { - case kFormNone: - break; - case kFormRange: - buffer = " Range ("; - print(mMinimumValue, buffer); - buffer += ", "; - print(mMaximumValue, buffer); - buffer += ", "; - print(mStepSize, buffer); - buffer += ")"; - MTPI("%s", (const char *)buffer); - break; - case kFormEnum: - buffer = " Enum { "; - for (int i = 0; i < mEnumLength; i++) { - print(mEnumValues[i], buffer); - buffer += " "; - } - buffer += "}"; - MTPI("%s", (const char *)buffer); - break; - case kFormDateTime: - MTPI(" DateTime\n"); - break; - default: - MTPI(" form %d\n", mFormFlag); - break; - } -} - -void MtpProperty::print(MtpPropertyValue& value, MtpString& buffer) { - switch (mType) { - case MTP_TYPE_INT8: - buffer.appendFormat("%d", value.u.i8); - break; - case MTP_TYPE_UINT8: - buffer.appendFormat("%d", value.u.u8); - break; - case MTP_TYPE_INT16: - buffer.appendFormat("%d", value.u.i16); - break; - case MTP_TYPE_UINT16: - buffer.appendFormat("%d", value.u.u16); - break; - case MTP_TYPE_INT32: - buffer.appendFormat("%d", value.u.i32); - break; - case MTP_TYPE_UINT32: - buffer.appendFormat("%d", value.u.u32); - break; - case MTP_TYPE_INT64: - buffer.appendFormat("%lld", value.u.i64); - break; - case MTP_TYPE_UINT64: - buffer.appendFormat("%lld", value.u.u64); - break; - case MTP_TYPE_INT128: - buffer.appendFormat("%08X%08X%08X%08X", value.u.i128[0], value.u.i128[1], - value.u.i128[2], value.u.i128[3]); - break; - case MTP_TYPE_UINT128: - buffer.appendFormat("%08X%08X%08X%08X", value.u.u128[0], value.u.u128[1], - value.u.u128[2], value.u.u128[3]); - break; - case MTP_TYPE_STR: - buffer.appendFormat("%s", value.str); - break; - default: - MTPE("unsupported type for MtpProperty::print\n"); - break; - } -} - -void MtpProperty::readValue(MtpDataPacket& packet, MtpPropertyValue& value) { - MtpStringBuffer stringBuffer; - - switch (mType) { - case MTP_TYPE_INT8: - case MTP_TYPE_AINT8: - value.u.i8 = packet.getInt8(); - break; - case MTP_TYPE_UINT8: - case MTP_TYPE_AUINT8: - value.u.u8 = packet.getUInt8(); - break; - case MTP_TYPE_INT16: - case MTP_TYPE_AINT16: - value.u.i16 = packet.getInt16(); - break; - case MTP_TYPE_UINT16: - case MTP_TYPE_AUINT16: - value.u.u16 = packet.getUInt16(); - break; - case MTP_TYPE_INT32: - case MTP_TYPE_AINT32: - value.u.i32 = packet.getInt32(); - break; - case MTP_TYPE_UINT32: - case MTP_TYPE_AUINT32: - value.u.u32 = packet.getUInt32(); - break; - case MTP_TYPE_INT64: - case MTP_TYPE_AINT64: - value.u.i64 = packet.getInt64(); - break; - case MTP_TYPE_UINT64: - case MTP_TYPE_AUINT64: - value.u.u64 = packet.getUInt64(); - break; - case MTP_TYPE_INT128: - case MTP_TYPE_AINT128: - packet.getInt128(value.u.i128); - break; - case MTP_TYPE_UINT128: - case MTP_TYPE_AUINT128: - packet.getUInt128(value.u.u128); - break; - case MTP_TYPE_STR: - packet.getString(stringBuffer); - value.str = strdup(stringBuffer); - break; - default: - MTPE("unknown type %04X in MtpProperty::readValue", mType); - } -} - -void MtpProperty::writeValue(MtpDataPacket& packet, MtpPropertyValue& value) { - MtpStringBuffer stringBuffer; - - switch (mType) { - case MTP_TYPE_INT8: - case MTP_TYPE_AINT8: - packet.putInt8(value.u.i8); - break; - case MTP_TYPE_UINT8: - case MTP_TYPE_AUINT8: - packet.putUInt8(value.u.u8); - break; - case MTP_TYPE_INT16: - case MTP_TYPE_AINT16: - packet.putInt16(value.u.i16); - break; - case MTP_TYPE_UINT16: - case MTP_TYPE_AUINT16: - packet.putUInt16(value.u.u16); - break; - case MTP_TYPE_INT32: - case MTP_TYPE_AINT32: - packet.putInt32(value.u.i32); - break; - case MTP_TYPE_UINT32: - case MTP_TYPE_AUINT32: - packet.putUInt32(value.u.u32); - break; - case MTP_TYPE_INT64: - case MTP_TYPE_AINT64: - packet.putInt64(value.u.i64); - break; - case MTP_TYPE_UINT64: - case MTP_TYPE_AUINT64: - packet.putUInt64(value.u.u64); - break; - case MTP_TYPE_INT128: - case MTP_TYPE_AINT128: - packet.putInt128(value.u.i128); - break; - case MTP_TYPE_UINT128: - case MTP_TYPE_AUINT128: - packet.putUInt128(value.u.u128); - break; - case MTP_TYPE_STR: - if (value.str) - packet.putString(value.str); - else - packet.putEmptyString(); - break; - default: - MTPE("unknown type %04X in MtpProperty::writeValue", mType); - } -} - -MtpPropertyValue* MtpProperty::readArrayValues(MtpDataPacket& packet, int& length) { - length = packet.getUInt32(); - if (length == 0) - return NULL; - MtpPropertyValue* result = new MtpPropertyValue[length]; - for (int i = 0; i < length; i++) - readValue(packet, result[i]); - return result; -} - -void MtpProperty::writeArrayValues(MtpDataPacket& packet, MtpPropertyValue* values, int length) { - packet.putUInt32(length); - for (int i = 0; i < length; i++) - writeValue(packet, values[i]); -} - diff --git a/mtp/legacy/MtpProperty.h b/mtp/legacy/MtpProperty.h deleted file mode 100644 index c1f32338..00000000 --- a/mtp/legacy/MtpProperty.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_PROPERTY_H -#define _MTP_PROPERTY_H - -#include "MtpTypes.h" - - -class MtpDataPacket; - -struct MtpPropertyValue { - union { - int8_t i8; - uint8_t u8; - int16_t i16; - uint16_t u16; - int32_t i32; - uint32_t u32; - int64_t i64; - uint64_t u64; - int128_t i128; - uint128_t u128; - } u; - // string in UTF8 format - char* str; -}; - -class MtpProperty { -public: - MtpPropertyCode mCode; - MtpDataType mType; - bool mWriteable; - MtpPropertyValue mDefaultValue; - MtpPropertyValue mCurrentValue; - - // for array types - int mDefaultArrayLength; - MtpPropertyValue* mDefaultArrayValues; - int mCurrentArrayLength; - MtpPropertyValue* mCurrentArrayValues; - - enum { - kFormNone = 0, - kFormRange = 1, - kFormEnum = 2, - kFormDateTime = 3, - }; - - uint32_t mGroupCode; - uint8_t mFormFlag; - - // for range form - MtpPropertyValue mMinimumValue; - MtpPropertyValue mMaximumValue; - MtpPropertyValue mStepSize; - - // for enum form - int mEnumLength; - MtpPropertyValue* mEnumValues; - -public: - MtpProperty(); - MtpProperty(MtpPropertyCode propCode, - MtpDataType type, - bool writeable = false, - int defaultValue = 0); - virtual ~MtpProperty(); - - inline MtpPropertyCode getPropertyCode() const { return mCode; } - - void read(MtpDataPacket& packet); - void write(MtpDataPacket& packet); - - void setDefaultValue(const uint16_t* string); - void setCurrentValue(const uint16_t* string); - - void setFormRange(int min, int max, int step); - void setFormEnum(const int* values, int count); - void setFormDateTime(); - - void print(); - void print(MtpPropertyValue& value, MtpString& buffer); - - inline bool isDeviceProperty() const { - return ( ((mCode & 0xF000) == 0x5000) - || ((mCode & 0xF800) == 0xD000)); - } - -private: - void readValue(MtpDataPacket& packet, MtpPropertyValue& value); - void writeValue(MtpDataPacket& packet, MtpPropertyValue& value); - MtpPropertyValue* readArrayValues(MtpDataPacket& packet, int& length); - void writeArrayValues(MtpDataPacket& packet, - MtpPropertyValue* values, int length); -}; - - -#endif // _MTP_PROPERTY_H diff --git a/mtp/legacy/MtpRequestPacket.cpp b/mtp/legacy/MtpRequestPacket.cpp deleted file mode 100644 index e700e3b2..00000000 --- a/mtp/legacy/MtpRequestPacket.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include -#include -#include - -#include "MtpRequestPacket.h" -#include "MtpDebug.h" - -#include - - -MtpRequestPacket::MtpRequestPacket() - : MtpPacket(512) -{ -} - -MtpRequestPacket::~MtpRequestPacket() { -} - -#ifdef MTP_DEVICE -int MtpRequestPacket::read(int fd) { - int ret = ::read(fd, mBuffer, mBufferSize); - if (ret >= 0) - mPacketSize = ret; - else - mPacketSize = 0; - return ret; -} -#endif - -#ifdef MTP_HOST - // write our buffer to the given endpoint (host mode) -int MtpRequestPacket::write(struct usb_request *request) -{ - putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); - putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_COMMAND); - request->buffer = mBuffer; - request->buffer_length = mPacketSize; - return transfer(request); -} -#endif - diff --git a/mtp/legacy/MtpRequestPacket.h b/mtp/legacy/MtpRequestPacket.h deleted file mode 100644 index dcf00d6e..00000000 --- a/mtp/legacy/MtpRequestPacket.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_REQUEST_PACKET_H -#define _MTP_REQUEST_PACKET_H - -#include "MtpPacket.h" -#include "mtp.h" - -struct usb_request; - - -class MtpRequestPacket : public MtpPacket { - -public: - MtpRequestPacket(); - virtual ~MtpRequestPacket(); -#ifdef MTP_DEVICE - // fill our buffer with data from the given file descriptor - int read(int fd); -#endif - -#ifdef MTP_HOST - // write our buffer to the given endpoint - int write(struct usb_request *request); -#endif - - inline MtpOperationCode getOperationCode() const { return getContainerCode(); } - inline void setOperationCode(MtpOperationCode code) - { return setContainerCode(code); } -}; - - -#endif // _MTP_REQUEST_PACKET_H diff --git a/mtp/legacy/MtpResponsePacket.cpp b/mtp/legacy/MtpResponsePacket.cpp deleted file mode 100644 index 8eed13a1..00000000 --- a/mtp/legacy/MtpResponsePacket.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include -#include -#include - -#include "MtpResponsePacket.h" - -#include - - -MtpResponsePacket::MtpResponsePacket() - : MtpPacket(512) -{ -} - -MtpResponsePacket::~MtpResponsePacket() { -} - -#ifdef MTP_DEVICE -int MtpResponsePacket::write(int fd) { - putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize); - putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_RESPONSE); - int ret = ::write(fd, mBuffer, mPacketSize); - return (ret < 0 ? ret : 0); -} -#endif - -#ifdef MTP_HOST -int MtpResponsePacket::read(struct usb_request *request) { - request->buffer = mBuffer; - request->buffer_length = mBufferSize; - int ret = transfer(request); - if (ret >= 0) - mPacketSize = ret; - else - mPacketSize = 0; - return ret; -} -#endif - - diff --git a/mtp/legacy/MtpResponsePacket.h b/mtp/legacy/MtpResponsePacket.h deleted file mode 100644 index f9621aac..00000000 --- a/mtp/legacy/MtpResponsePacket.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_RESPONSE_PACKET_H -#define _MTP_RESPONSE_PACKET_H - -#include "MtpPacket.h" -#include "mtp.h" - - -class MtpResponsePacket : public MtpPacket { - -public: - MtpResponsePacket(); - virtual ~MtpResponsePacket(); - -#ifdef MTP_DEVICE - // write our data to the given file descriptor - int write(int fd); -#endif - -#ifdef MTP_HOST - // read our buffer with the given request - int read(struct usb_request *request); -#endif - - inline MtpResponseCode getResponseCode() const { return getContainerCode(); } - inline void setResponseCode(MtpResponseCode code) - { return setContainerCode(code); } -}; - - -#endif // _MTP_RESPONSE_PACKET_H diff --git a/mtp/legacy/MtpServer.cpp b/mtp/legacy/MtpServer.cpp deleted file mode 100644 index c4e1cd3a..00000000 --- a/mtp/legacy/MtpServer.cpp +++ /dev/null @@ -1,1379 +0,0 @@ -/* - * Copyright (C) 2017 TeamWin - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../twcommon.h" -#include "../../set_metadata.h" -#include - -#include "MtpTypes.h" -#include "MtpDebug.h" -#include "MtpDatabase.h" -#include "MtpObjectInfo.h" -#include "MtpProperty.h" -#include "MtpServer.h" -#include "MtpStorage.h" -#include "MtpStringBuffer.h" - -#include - -static const MtpOperationCode kSupportedOperationCodes[] = { - MTP_OPERATION_GET_DEVICE_INFO, - MTP_OPERATION_OPEN_SESSION, - MTP_OPERATION_CLOSE_SESSION, - MTP_OPERATION_GET_STORAGE_IDS, - MTP_OPERATION_GET_STORAGE_INFO, - MTP_OPERATION_GET_NUM_OBJECTS, - MTP_OPERATION_GET_OBJECT_HANDLES, - MTP_OPERATION_GET_OBJECT_INFO, - MTP_OPERATION_GET_OBJECT, - MTP_OPERATION_GET_THUMB, - MTP_OPERATION_DELETE_OBJECT, - MTP_OPERATION_SEND_OBJECT_INFO, - MTP_OPERATION_SEND_OBJECT, -// MTP_OPERATION_INITIATE_CAPTURE, -// MTP_OPERATION_FORMAT_STORE, -// MTP_OPERATION_RESET_DEVICE, -// MTP_OPERATION_SELF_TEST, -// MTP_OPERATION_SET_OBJECT_PROTECTION, -// MTP_OPERATION_POWER_DOWN, - MTP_OPERATION_GET_DEVICE_PROP_DESC, - MTP_OPERATION_GET_DEVICE_PROP_VALUE, - MTP_OPERATION_SET_DEVICE_PROP_VALUE, - MTP_OPERATION_RESET_DEVICE_PROP_VALUE, -// MTP_OPERATION_TERMINATE_OPEN_CAPTURE, -// MTP_OPERATION_MOVE_OBJECT, -// MTP_OPERATION_COPY_OBJECT, - MTP_OPERATION_GET_PARTIAL_OBJECT, -// MTP_OPERATION_INITIATE_OPEN_CAPTURE, - MTP_OPERATION_GET_OBJECT_PROPS_SUPPORTED, - MTP_OPERATION_GET_OBJECT_PROP_DESC, - MTP_OPERATION_GET_OBJECT_PROP_VALUE, - MTP_OPERATION_SET_OBJECT_PROP_VALUE, - MTP_OPERATION_GET_OBJECT_PROP_LIST, -// MTP_OPERATION_SET_OBJECT_PROP_LIST, -// MTP_OPERATION_GET_INTERDEPENDENT_PROP_DESC, -// MTP_OPERATION_SEND_OBJECT_PROP_LIST, - MTP_OPERATION_GET_OBJECT_REFERENCES, - MTP_OPERATION_SET_OBJECT_REFERENCES, -// MTP_OPERATION_SKIP, - // Android extension for direct file IO - MTP_OPERATION_GET_PARTIAL_OBJECT_64, - MTP_OPERATION_SEND_PARTIAL_OBJECT, - MTP_OPERATION_TRUNCATE_OBJECT, - MTP_OPERATION_BEGIN_EDIT_OBJECT, - MTP_OPERATION_END_EDIT_OBJECT, -}; - -static const MtpEventCode kSupportedEventCodes[] = { - MTP_EVENT_OBJECT_ADDED, - MTP_EVENT_OBJECT_REMOVED, - MTP_EVENT_STORE_ADDED, - MTP_EVENT_STORE_REMOVED, - MTP_EVENT_OBJECT_PROP_CHANGED, -}; - -MtpServer::MtpServer(MtpDatabase* database, bool ptp, - int fileGroup, int filePerm, int directoryPerm) - : mDatabase(database), - mPtp(ptp), - mFileGroup(fileGroup), - mFilePermission(filePerm), - mDirectoryPermission(directoryPerm), - mSessionID(0), - mSessionOpen(false), - mSendObjectHandle(kInvalidObjectHandle), - mSendObjectFormat(0), - mSendObjectFileSize(0) -{ - mFD = -1; -} - -MtpServer::~MtpServer() { -} - -void MtpServer::addStorage(MtpStorage* storage) { - android::Mutex::Autolock autoLock(mMutex); - MTPD("addStorage(): storage: %x\n", storage); - if (getStorage(storage->getStorageID()) != NULL) { - MTPE("MtpServer::addStorage Storage for storage ID %i already exists.\n", storage->getStorageID()); - return; - } - mDatabase->createDB(storage, storage->getStorageID()); - mStorages.push(storage); - sendStoreAdded(storage->getStorageID()); -} - -void MtpServer::removeStorage(MtpStorage* storage) { - android::Mutex::Autolock autoLock(mMutex); - - for (size_t i = 0; i < mStorages.size(); i++) { - if (mStorages[i] == storage) { - MTPD("MtpServer::removeStorage calling sendStoreRemoved\n"); - // First lock the mutex so that the inotify thread and main - // thread do not do anything while we remove the storage - // item, and to make sure we don't remove the item while an - // operation is in progress - mDatabase->lockMutex(); - // Grab the storage ID before we delete the item from the - // database - MtpStorageID storageID = storage->getStorageID(); - // Remove the item from the mStorages from the vector. At - // this point the main thread will no longer be able to find - // this storage item anymore. - mStorages.removeAt(i); - // Destroy the storage item, free up all the memory, kill - // the inotify thread. - mDatabase->destroyDB(storageID); - // Tell the host OS that the storage item is gone. - sendStoreRemoved(storageID); - // Unlock any remaining mutexes on other storage devices. - // If no storage devices exist anymore this will do nothing. - mDatabase->unlockMutex(); - break; - } - } - MTPD("MtpServer::removeStorage DONE\n"); -} - -MtpStorage* MtpServer::getStorage(MtpStorageID id) { - MTPD("getStorage\n"); - if (id == 0) { - MTPD("mStorages\n"); - return mStorages[0]; - } - for (size_t i = 0; i < mStorages.size(); i++) { - MtpStorage* storage = mStorages[i]; - MTPD("id: %d\n", id); - MTPD("storage: %d\n", storage->getStorageID()); - if (storage->getStorageID() == id) { - return storage; - } - } - return NULL; -} - -bool MtpServer::hasStorage(MtpStorageID id) { - MTPD("in hasStorage\n"); - if (id == 0 || id == 0xFFFFFFFF) - return mStorages.size() > 0; - return (getStorage(id) != NULL); -} - -void MtpServer::run(int fd) { - if (fd < 0) - return; - - mFD = fd; - MTPI("MtpServer::run fd: %d\n", fd); - - while (1) { - MTPD("About to read device...\n"); - int ret = mRequest.read(fd); - if (ret < 0) { - if (errno == ECANCELED) { - // return to top of loop and wait for next command - MTPD("request read returned %d ECANCELED, starting over\n", ret); - continue; - } - MTPE("request read returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); - break; - } - MtpOperationCode operation = mRequest.getOperationCode(); - MtpTransactionID transaction = mRequest.getTransactionID(); - - MTPD("operation: %s", MtpDebug::getOperationCodeName(operation)); - mRequest.dump(); - - // FIXME need to generalize this - bool dataIn = (operation == MTP_OPERATION_SEND_OBJECT_INFO - || operation == MTP_OPERATION_SET_OBJECT_REFERENCES - || operation == MTP_OPERATION_SET_OBJECT_PROP_VALUE - || operation == MTP_OPERATION_SET_DEVICE_PROP_VALUE); - if (dataIn) { - int ret = mData.read(fd); - if (ret < 0) { - if (errno == ECANCELED) { - // return to top of loop and wait for next command - MTPD("data read returned %d ECANCELED, starting over\n", ret); - continue; - } - MTPD("data read returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); - break; - } - MTPD("received data:"); - mData.dump(); - } else { - mData.reset(); - } - - if (handleRequest()) { - if (!dataIn && mData.hasData()) { - mData.setOperationCode(operation); - mData.setTransactionID(transaction); - MTPD("sending data:"); - mData.dump(); - ret = mData.write(fd); - if (ret < 0) { - if (errno == ECANCELED) { - // return to top of loop and wait for next command - MTPD("data write returned %d ECANCELED, starting over\n", ret); - continue; - } - MTPE("data write returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); - break; - } - } - - mResponse.setTransactionID(transaction); - MTPD("sending response %04X\n", mResponse.getResponseCode()); - ret = mResponse.write(fd); - MTPD("ret: %d\n", ret); - mResponse.dump(); - if (ret < 0) { - if (errno == ECANCELED) { - // return to top of loop and wait for next command - MTPD("response write returned %d ECANCELED, starting over\n", ret); - continue; - } - MTPE("response write returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); - break; - } - } else { - MTPD("skipping response\n"); - } - } - - // commit any open edits - int count = mObjectEditList.size(); - for (int i = 0; i < count; i++) { - ObjectEdit* edit = mObjectEditList[i]; - commitEdit(edit); - delete edit; - } - mObjectEditList.clear(); - - if (mSessionOpen) - mDatabase->sessionEnded(); // This doesn't actually do anything but was carry over from AOSP - close(fd); - mFD = -1; -} - -void MtpServer::sendObjectAdded(MtpObjectHandle handle) { - MTPD("sendObjectAdded %d\n", handle); - sendEvent(MTP_EVENT_OBJECT_ADDED, handle); -} - -void MtpServer::sendObjectRemoved(MtpObjectHandle handle) { - MTPD("sendObjectRemoved %d\n", handle); - sendEvent(MTP_EVENT_OBJECT_REMOVED, handle); -} - -void MtpServer::sendObjectUpdated(MtpObjectHandle handle) { - MTPD("sendObjectUpdated %d\n", handle); - sendEvent(MTP_EVENT_OBJECT_PROP_CHANGED, handle); -} - -void MtpServer::sendStoreAdded(MtpStorageID id) { - MTPD("sendStoreAdded %08X\n", id); - sendEvent(MTP_EVENT_STORE_ADDED, id); -} - -void MtpServer::sendStoreRemoved(MtpStorageID id) { - MTPD("sendStoreRemoved %08X\n", id); - sendEvent(MTP_EVENT_STORE_REMOVED, id); - MTPD("MtpServer::sendStoreRemoved done\n"); -} - -void MtpServer::sendEvent(MtpEventCode code, uint32_t param1) { - MTPD("MtpServer::sendEvent sending event code: %x\n", code); - if (mSessionOpen) { - mEvent.setEventCode(code); - mEvent.setTransactionID(mRequest.getTransactionID()); - mEvent.setParameter(1, param1); - int ret = mEvent.write(mFD); - MTPD("mEvent.write returned %d\n", ret); - } -} - -void MtpServer::addEditObject(MtpObjectHandle handle, MtpString& path, - uint64_t size, MtpObjectFormat format, int fd) { - ObjectEdit* edit = new ObjectEdit(handle, path, size, format, fd); - mObjectEditList.add(edit); -} - -MtpServer::ObjectEdit* MtpServer::getEditObject(MtpObjectHandle handle) { - int count = mObjectEditList.size(); - for (int i = 0; i < count; i++) { - ObjectEdit* edit = mObjectEditList[i]; - if (edit->mHandle == handle) return edit; - } - return NULL; -} - -void MtpServer::removeEditObject(MtpObjectHandle handle) { - int count = mObjectEditList.size(); - for (int i = 0; i < count; i++) { - ObjectEdit* edit = mObjectEditList[i]; - if (edit->mHandle == handle) { - delete edit; - mObjectEditList.removeAt(i); - return; - } - } - MTPE("ObjectEdit not found in removeEditObject"); -} - -void MtpServer::commitEdit(ObjectEdit* edit) { - mDatabase->endSendObject((const char *)edit->mPath, edit->mHandle, edit->mFormat, true); -} - - -bool MtpServer::handleRequest() { - android::Mutex::Autolock autoLock(mMutex); - - MtpOperationCode operation = mRequest.getOperationCode(); - MtpResponseCode response; - - mResponse.reset(); - - if (mSendObjectHandle != kInvalidObjectHandle && operation != MTP_OPERATION_SEND_OBJECT) { - // FIXME - need to delete mSendObjectHandle from the database - MTPE("expected SendObject after SendObjectInfo"); - mSendObjectHandle = kInvalidObjectHandle; - } - - switch (operation) { - case MTP_OPERATION_GET_DEVICE_INFO: - MTPD("doGetDeviceInfo()\n"); - response = doGetDeviceInfo(); - break; - case MTP_OPERATION_OPEN_SESSION: - MTPD("doOpenSesion()\n"); - response = doOpenSession(); - break; - case MTP_OPERATION_CLOSE_SESSION: - MTPD("doCloseSession()\n"); - response = doCloseSession(); - break; - case MTP_OPERATION_GET_STORAGE_IDS: - MTPD("doGetStorageIDs()\n"); - response = doGetStorageIDs(); - break; - case MTP_OPERATION_GET_STORAGE_INFO: - MTPD("about to call doGetStorageInfo()\n"); - response = doGetStorageInfo(); - break; - case MTP_OPERATION_GET_OBJECT_PROPS_SUPPORTED: - MTPD("about to call doGetObjectPropsSupported()\n"); - response = doGetObjectPropsSupported(); - break; - case MTP_OPERATION_GET_OBJECT_HANDLES: - MTPD("about to call doGetObjectHandles()\n"); - response = doGetObjectHandles(); - break; - case MTP_OPERATION_GET_NUM_OBJECTS: - MTPD("about to call doGetNumbObjects()\n"); - response = doGetNumObjects(); - break; - case MTP_OPERATION_GET_OBJECT_REFERENCES: - MTPD("about to call doGetObjectReferences()\n"); - response = doGetObjectReferences(); - break; - case MTP_OPERATION_SET_OBJECT_REFERENCES: - MTPD("about to call doSetObjectReferences()\n"); - response = doSetObjectReferences(); - break; - case MTP_OPERATION_GET_OBJECT_PROP_VALUE: - MTPD("about to call doGetObjectPropValue()\n"); - response = doGetObjectPropValue(); - break; - case MTP_OPERATION_SET_OBJECT_PROP_VALUE: - MTPD("about to call doSetObjectPropValue()\n"); - response = doSetObjectPropValue(); - break; - case MTP_OPERATION_GET_DEVICE_PROP_VALUE: - MTPD("about to call doGetDevicPropValue()\n"); - response = doGetDevicePropValue(); - break; - case MTP_OPERATION_SET_DEVICE_PROP_VALUE: - MTPD("about to call doSetDevicePropVaue()\n"); - response = doSetDevicePropValue(); - break; - case MTP_OPERATION_RESET_DEVICE_PROP_VALUE: - MTPD("about to call doResetDevicePropValue()\n"); - response = doResetDevicePropValue(); - break; - case MTP_OPERATION_GET_OBJECT_PROP_LIST: - MTPD("calling doGetObjectPropList()\n"); - response = doGetObjectPropList(); - break; - case MTP_OPERATION_GET_OBJECT_INFO: - MTPD("calling doGetObjectInfo()\n"); - response = doGetObjectInfo(); - break; - case MTP_OPERATION_GET_OBJECT: - MTPD("about to call doGetObject()\n"); - response = doGetObject(); - break; - case MTP_OPERATION_GET_THUMB: - response = doGetThumb(); - break; - case MTP_OPERATION_GET_PARTIAL_OBJECT: - case MTP_OPERATION_GET_PARTIAL_OBJECT_64: - response = doGetPartialObject(operation); - break; - case MTP_OPERATION_SEND_OBJECT_INFO: - MTPD("about to call doSendObjectInfo()\n"); - response = doSendObjectInfo(); - break; - case MTP_OPERATION_SEND_OBJECT: - MTPD("about to call doSendObject()\n"); - response = doSendObject(); - break; - case MTP_OPERATION_DELETE_OBJECT: - response = doDeleteObject(); - break; - case MTP_OPERATION_GET_OBJECT_PROP_DESC: - MTPD("about to call doGetObjectPropDesc()\n"); - response = doGetObjectPropDesc(); - break; - case MTP_OPERATION_GET_DEVICE_PROP_DESC: - MTPD("about to call doGetDevicePropDesc()\n"); - response = doGetDevicePropDesc(); - break; - case MTP_OPERATION_SEND_PARTIAL_OBJECT: - response = doSendPartialObject(); - break; - case MTP_OPERATION_TRUNCATE_OBJECT: - response = doTruncateObject(); - break; - case MTP_OPERATION_BEGIN_EDIT_OBJECT: - response = doBeginEditObject(); - break; - case MTP_OPERATION_END_EDIT_OBJECT: - response = doEndEditObject(); - break; - default: - MTPE("got unsupported command %s", MtpDebug::getOperationCodeName(operation)); - response = MTP_RESPONSE_OPERATION_NOT_SUPPORTED; - break; - } - - if (response == MTP_RESPONSE_TRANSACTION_CANCELLED) - return false; - mResponse.setResponseCode(response); - return true; -} - -MtpResponseCode MtpServer::doGetDeviceInfo() { - MtpStringBuffer string; - char prop_value[PROPERTY_VALUE_MAX]; - - MtpObjectFormatList* playbackFormats = mDatabase->getSupportedPlaybackFormats(); - MtpObjectFormatList* captureFormats = mDatabase->getSupportedCaptureFormats(); - MtpDevicePropertyList* deviceProperties = mDatabase->getSupportedDeviceProperties(); - - // fill in device info - mData.putUInt16(MTP_STANDARD_VERSION); - if (mPtp) { - MTPD("doGetDeviceInfo putting 0\n"); - mData.putUInt32(0); - } else { - // MTP Vendor Extension ID - MTPD("doGetDeviceInfo putting 6\n"); - mData.putUInt32(6); - } - mData.putUInt16(MTP_STANDARD_VERSION); - if (mPtp) { - // no extensions - MTPD("doGetDeviceInfo no extensions\n"); - string.set(""); - } else { - // MTP extensions - MTPD("doGetDeviceInfo microsoft.com: 1.0; android.com: 1.0;\n"); - string.set("microsoft.com: 1.0; android.com: 1.0;"); - } - mData.putString(string); // MTP Extensions - mData.putUInt16(0); //Functional Mode - MTPD("doGetDeviceInfo opcodes, %i\n", sizeof(kSupportedOperationCodes) / sizeof(uint16_t)); - MTPD("doGetDeviceInfo eventcodes, %i\n", sizeof(kSupportedEventCodes) / sizeof(uint16_t)); - mData.putAUInt16(kSupportedOperationCodes, - sizeof(kSupportedOperationCodes) / sizeof(uint16_t)); // Operations Supported - mData.putAUInt16(kSupportedEventCodes, - sizeof(kSupportedEventCodes) / sizeof(uint16_t)); // Events Supported - mData.putAUInt16(deviceProperties); // Device Properties Supported - mData.putAUInt16(captureFormats); // Capture Formats - mData.putAUInt16(playbackFormats); // Playback Formats - - property_get("ro.product.manufacturer", prop_value, "unknown manufacturer"); - MTPD("prop: %s\n", prop_value); - string.set(prop_value); - mData.putString(string); // Manufacturer - - property_get("ro.product.model", prop_value, "MTP Device"); - string.set(prop_value); - mData.putString(string); // Model - string.set("1.0"); - mData.putString(string); // Device Version - - property_get("ro.serialno", prop_value, "????????"); - MTPD("sn: %s\n", prop_value); - string.set(prop_value); - mData.putString(string); // Serial Number - - delete playbackFormats; - delete captureFormats; - delete deviceProperties; - - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doOpenSession() { - if (mSessionOpen) { - mResponse.setParameter(1, mSessionID); - return MTP_RESPONSE_SESSION_ALREADY_OPEN; - } - mSessionID = mRequest.getParameter(1); - mSessionOpen = true; - - mDatabase->sessionStarted(); - - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doCloseSession() { - if (!mSessionOpen) - return MTP_RESPONSE_SESSION_NOT_OPEN; - mSessionID = 0; - mSessionOpen = false; - mDatabase->sessionEnded(); - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doGetStorageIDs() { - MTPD("doGetStorageIDs()\n"); - if (!mSessionOpen) - return MTP_RESPONSE_SESSION_NOT_OPEN; - int count = mStorages.size(); - mData.putUInt32(count); - for (int i = 0; i < count; i++) { - MTPD("getting storageid %d\n", mStorages[i]->getStorageID()); - mData.putUInt32(mStorages[i]->getStorageID()); - } - - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doGetStorageInfo() { - MtpStringBuffer string; - MTPD("doGetStorageInfo()\n"); - if (!mSessionOpen) - return MTP_RESPONSE_SESSION_NOT_OPEN; - MtpStorageID id = mRequest.getParameter(1); - MtpStorage* storage = getStorage(id); - if (!storage) { - MTPE("invalid storage id\n"); - return MTP_RESPONSE_INVALID_STORAGE_ID; - } - - mData.putUInt16(storage->getType()); - mData.putUInt16(storage->getFileSystemType()); - mData.putUInt16(storage->getAccessCapability()); - mData.putUInt64(storage->getMaxCapacity()); - mData.putUInt64(storage->getFreeSpace()); - mData.putUInt32(1024*1024*1024); // Free Space in Objects - string.set(storage->getDescription()); - mData.putString(string); - mData.putEmptyString(); // Volume Identifier - - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doGetObjectPropsSupported() { - MTPD("doGetObjectPropsSupported()\n"); - if (!mSessionOpen) - return MTP_RESPONSE_SESSION_NOT_OPEN; - MtpObjectFormat format = mRequest.getParameter(1); - mDatabase->lockMutex(); - MtpObjectPropertyList* properties = mDatabase->getSupportedObjectProperties(format); - mData.putAUInt16(properties); - delete properties; - mDatabase->unlockMutex(); - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doGetObjectHandles() { - if (!mSessionOpen) - return MTP_RESPONSE_SESSION_NOT_OPEN; - MtpStorageID storageID = mRequest.getParameter(1); // 0xFFFFFFFF for all storage - MtpObjectFormat format = mRequest.getParameter(2); // 0 for all formats - MtpObjectHandle parent = mRequest.getParameter(3); // 0xFFFFFFFF for objects with no parent - // 0x00000000 for all objects - - if (!hasStorage(storageID)) - return MTP_RESPONSE_INVALID_STORAGE_ID; - - MTPD("calling MtpDatabase->getObjectList()\n"); - mDatabase->lockMutex(); - MtpObjectHandleList* handles = mDatabase->getObjectList(storageID, format, parent); - mData.putAUInt32(handles); - delete handles; - mDatabase->unlockMutex(); - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doGetNumObjects() { - if (!mSessionOpen) - return MTP_RESPONSE_SESSION_NOT_OPEN; - MtpStorageID storageID = mRequest.getParameter(1); // 0xFFFFFFFF for all storage - MtpObjectFormat format = mRequest.getParameter(2); // 0 for all formats - MtpObjectHandle parent = mRequest.getParameter(3); // 0xFFFFFFFF for objects with no parent - // 0x00000000 for all objects - if (!hasStorage(storageID)) - return MTP_RESPONSE_INVALID_STORAGE_ID; - - mDatabase->lockMutex(); - int count = mDatabase->getNumObjects(storageID, format, parent); - mDatabase->unlockMutex(); - if (count >= 0) { - mResponse.setParameter(1, count); - return MTP_RESPONSE_OK; - } else { - mResponse.setParameter(1, 0); - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - } -} - -MtpResponseCode MtpServer::doGetObjectReferences() { - if (!mSessionOpen) - return MTP_RESPONSE_SESSION_NOT_OPEN; - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpObjectHandle handle = mRequest.getParameter(1); - - // FIXME - check for invalid object handle - mDatabase->lockMutex(); - MtpObjectHandleList* handles = mDatabase->getObjectReferences(handle); - if (handles) { - mData.putAUInt32(handles); - delete handles; - } else { - MTPD("MtpServer::doGetObjectReferences putEmptyArray\n"); - mData.putEmptyArray(); - } - mDatabase->unlockMutex(); - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doSetObjectReferences() { - if (!mSessionOpen) - return MTP_RESPONSE_SESSION_NOT_OPEN; - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpStorageID handle = mRequest.getParameter(1); - - MtpObjectHandleList* references = mData.getAUInt32(); - mDatabase->lockMutex(); - MtpResponseCode result = mDatabase->setObjectReferences(handle, references); - mDatabase->unlockMutex(); - delete references; - return result; -} - -MtpResponseCode MtpServer::doGetObjectPropValue() { - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpObjectHandle handle = mRequest.getParameter(1); - MtpObjectProperty property = mRequest.getParameter(2); - MTPD("GetObjectPropValue %d %s\n", handle, - MtpDebug::getObjectPropCodeName(property)); - - mDatabase->lockMutex(); - MtpResponseCode res = mDatabase->getObjectPropertyValue(handle, property, mData); - mDatabase->unlockMutex(); - return res; -} - -MtpResponseCode MtpServer::doSetObjectPropValue() { - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpObjectHandle handle = mRequest.getParameter(1); - MtpObjectProperty property = mRequest.getParameter(2); - MTPD("SetObjectPropValue %d %s\n", handle, - MtpDebug::getObjectPropCodeName(property)); - - mDatabase->lockMutex(); - MtpResponseCode res = mDatabase->setObjectPropertyValue(handle, property, mData); - mDatabase->unlockMutex(); - return res; -} - -MtpResponseCode MtpServer::doGetDevicePropValue() { - MtpDeviceProperty property = mRequest.getParameter(1); - MTPD("GetDevicePropValue %s\n", - MtpDebug::getDevicePropCodeName(property)); - - mDatabase->lockMutex(); - MtpResponseCode res = mDatabase->getDevicePropertyValue(property, mData); - mDatabase->unlockMutex(); - return res; -} - -MtpResponseCode MtpServer::doSetDevicePropValue() { - MtpDeviceProperty property = mRequest.getParameter(1); - MTPD("SetDevicePropValue %s\n", - MtpDebug::getDevicePropCodeName(property)); - - mDatabase->lockMutex(); - MtpResponseCode res = mDatabase->setDevicePropertyValue(property, mData); - mDatabase->unlockMutex(); - return res; -} - -MtpResponseCode MtpServer::doResetDevicePropValue() { - MtpDeviceProperty property = mRequest.getParameter(1); - MTPD("ResetDevicePropValue %s\n", - MtpDebug::getDevicePropCodeName(property)); - - mDatabase->lockMutex(); - MtpResponseCode res = mDatabase->resetDeviceProperty(property); - mDatabase->unlockMutex(); - return res; -} - -MtpResponseCode MtpServer::doGetObjectPropList() { - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - - MtpObjectHandle handle = mRequest.getParameter(1); - // use uint32_t so we can support 0xFFFFFFFF - uint32_t format = mRequest.getParameter(2); - uint32_t property = mRequest.getParameter(3); - int groupCode = mRequest.getParameter(4); - int depth = mRequest.getParameter(5); - MTPD("GetObjectPropList %d format: %s property: %x group: %d depth: %d\n", - handle, MtpDebug::getFormatCodeName(format), - property, groupCode, depth); - - mDatabase->lockMutex(); - MtpResponseCode res = mDatabase->getObjectPropertyList(handle, format, property, groupCode, depth, mData); - mDatabase->unlockMutex(); - return res; -} - -MtpResponseCode MtpServer::doGetObjectInfo() { - MTPD("inside doGetObjectInfo()\n"); - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpObjectHandle handle = mRequest.getParameter(1); - MtpObjectInfo info(handle); - MTPD("calling mtpdatabase getObjectInfo()\n"); - mDatabase->lockMutex(); - MtpResponseCode result = mDatabase->getObjectInfo(handle, info); - mDatabase->unlockMutex(); - if (result == MTP_RESPONSE_OK) { - char date[20]; - - mData.putUInt32(info.mStorageID); - mData.putUInt16(info.mFormat); - mData.putUInt16(info.mProtectionStatus); - - // if object is being edited the database size may be out of date - uint32_t size = info.mCompressedSize; - ObjectEdit* edit = getEditObject(handle); - if (edit) - size = (edit->mSize > 0xFFFFFFFFLL ? 0xFFFFFFFF : (uint32_t)edit->mSize); - mData.putUInt32(size); - - mData.putUInt16(info.mThumbFormat); - mData.putUInt32(info.mThumbCompressedSize); - mData.putUInt32(info.mThumbPixWidth); - mData.putUInt32(info.mThumbPixHeight); - mData.putUInt32(info.mImagePixWidth); - mData.putUInt32(info.mImagePixHeight); - mData.putUInt32(info.mImagePixDepth); - mData.putUInt32(info.mParent); - mData.putUInt16(info.mAssociationType); - mData.putUInt32(info.mAssociationDesc); - mData.putUInt32(info.mSequenceNumber); - MTPD("info.mName: %s\n", info.mName); - mData.putString(info.mName); - mData.putEmptyString(); // date created - formatDateTime(info.mDateModified, date, sizeof(date)); - mData.putString(date); // date modified - mData.putEmptyString(); // keywords - } - return result; -} - -MtpResponseCode MtpServer::doGetObject() { - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpObjectHandle handle = mRequest.getParameter(1); - MtpString pathBuf; - int64_t fileLength; - MtpObjectFormat format; - MTPD("MtpServer::doGetObject calling getObjectFilePath\n"); - mDatabase->lockMutex(); - int result = mDatabase->getObjectFilePath(handle, pathBuf, fileLength, format); - mDatabase->unlockMutex(); - if (result != MTP_RESPONSE_OK) - return result; - - const char* filePath = (const char *)pathBuf; - MTPD("filePath: %s\n", filePath); - mtp_file_range mfr; - mfr.fd = open(filePath, O_RDONLY); - if (mfr.fd < 0) { - return MTP_RESPONSE_GENERAL_ERROR; - } - mfr.offset = 0; - mfr.length = fileLength; - MTPD("mfr.length: %lld\n", mfr.length); - mfr.command = mRequest.getOperationCode(); - mfr.transaction_id = mRequest.getTransactionID(); - - // then transfer the file - int ret = ioctl(mFD, MTP_SEND_FILE_WITH_HEADER, (unsigned long)&mfr); - MTPD("MTP_SEND_FILE_WITH_HEADER returned %d\n", ret); - close(mfr.fd); - if (ret < 0) { - if (errno == ECANCELED) - return MTP_RESPONSE_TRANSACTION_CANCELLED; - else - return MTP_RESPONSE_GENERAL_ERROR; - } - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doGetThumb() { - MtpObjectHandle handle = mRequest.getParameter(1); - size_t thumbSize; - mDatabase->lockMutex(); - void* thumb = mDatabase->getThumbnail(handle, thumbSize); - mDatabase->unlockMutex(); - if (thumb) { - // send data - mData.setOperationCode(mRequest.getOperationCode()); - mData.setTransactionID(mRequest.getTransactionID()); - mData.writeData(mFD, thumb, thumbSize); - free(thumb); - return MTP_RESPONSE_OK; - } else { - return MTP_RESPONSE_GENERAL_ERROR; - } -} - -MtpResponseCode MtpServer::doGetPartialObject(MtpOperationCode operation) { - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpObjectHandle handle = mRequest.getParameter(1); - uint64_t offset; - uint32_t length; - offset = mRequest.getParameter(2); - if (operation == MTP_OPERATION_GET_PARTIAL_OBJECT_64) { - // android extension with 64 bit offset - uint64_t offset2 = mRequest.getParameter(3); - offset = offset | (offset2 << 32); - length = mRequest.getParameter(4); - } else { - // standard GetPartialObject - length = mRequest.getParameter(3); - } - MtpString pathBuf; - int64_t fileLength; - MtpObjectFormat format; - MTPD("MtpServer::doGetPartialObject calling getObjectFilePath\n"); - mDatabase->lockMutex(); - int result = mDatabase->getObjectFilePath(handle, pathBuf, fileLength, format); - mDatabase->unlockMutex(); - if (result != MTP_RESPONSE_OK) { - return result; - } - if (offset + length > (uint64_t)fileLength) - length = fileLength - offset; - - const char* filePath = (const char *)pathBuf; - mtp_file_range mfr; - mfr.fd = open(filePath, O_RDONLY); - if (mfr.fd < 0) { - return MTP_RESPONSE_GENERAL_ERROR; - } - mfr.offset = offset; - mfr.length = length; - mfr.command = mRequest.getOperationCode(); - mfr.transaction_id = mRequest.getTransactionID(); - mResponse.setParameter(1, length); - - // transfer the file - int ret = ioctl(mFD, MTP_SEND_FILE_WITH_HEADER, (unsigned long)&mfr); - MTPD("MTP_SEND_FILE_WITH_HEADER returned %d\n", ret); - close(mfr.fd); - if (ret < 0) { - if (errno == ECANCELED) - return MTP_RESPONSE_TRANSACTION_CANCELLED; - else - return MTP_RESPONSE_GENERAL_ERROR; - } - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doSendObjectInfo() { - MTPD("MtpServer::doSendObjectInfo starting\n"); - MtpString path; - MtpStorageID storageID = mRequest.getParameter(1); - MtpStorage* storage = getStorage(storageID); - MtpObjectHandle parent = mRequest.getParameter(2); - if (!storage) - return MTP_RESPONSE_INVALID_STORAGE_ID; - - // special case the root - if (parent == MTP_PARENT_ROOT) { - MTPD("MtpServer::doSendObjectInfo special case root\n"); - path = storage->getPath(); - parent = 0; - } else { - int64_t length; - MtpObjectFormat format; - MTPD("MtpServer::doSendObjectInfo calling getObjectFilePath\n"); - mDatabase->lockMutex(); - int result = mDatabase->getObjectFilePath(parent, path, length, format); - mDatabase->unlockMutex(); - if (result != MTP_RESPONSE_OK) { - return result; - } - if (format != MTP_FORMAT_ASSOCIATION) - return MTP_RESPONSE_INVALID_PARENT_OBJECT; - } - - // read only the fields we need - mData.getUInt32(); // storage ID - MtpObjectFormat format = mData.getUInt16(); - mData.getUInt16(); // protection status - mSendObjectFileSize = mData.getUInt32(); - mData.getUInt16(); // thumb format - mData.getUInt32(); // thumb compressed size - mData.getUInt32(); // thumb pix width - mData.getUInt32(); // thumb pix height - mData.getUInt32(); // image pix width - mData.getUInt32(); // image pix height - mData.getUInt32(); // image bit depth - mData.getUInt32(); // parent - uint16_t associationType = mData.getUInt16(); - uint32_t associationDesc = mData.getUInt32(); // association desc - mData.getUInt32(); // sequence number - MtpStringBuffer name, created, modified; - mData.getString(name); // file name - mData.getString(created); // date created - mData.getString(modified); // date modified - // keywords follow - - MTPD("name: %s format: %04X\n", (const char *)name, format); - time_t modifiedTime; - if (!parseDateTime(modified, modifiedTime)) { - modifiedTime = 0; - } - if (path[path.size() - 1] != '/') { - path += "/"; - } - path += (const char *)name; - - // check space first - if (mSendObjectFileSize > storage->getFreeSpace()) - return MTP_RESPONSE_STORAGE_FULL; - uint64_t maxFileSize = storage->getMaxFileSize(); - // check storage max file size - MTPD("maxFileSize: %ld\n", maxFileSize); - if (maxFileSize != 0) { - // if mSendObjectFileSize is 0xFFFFFFFF, then all we know is the file size - // is >= 0xFFFFFFFF - if (mSendObjectFileSize > maxFileSize || mSendObjectFileSize == 0xFFFFFFFF) - return MTP_RESPONSE_OBJECT_TOO_LARGE; - } - - MTPD("MtpServer::doSendObjectInfo path: %s parent: %d storageID: %08X\n", (const char*)path, parent, storageID); - mDatabase->lockMutex(); - MtpObjectHandle handle = mDatabase->beginSendObject((const char*)path, - format, parent, storageID, mSendObjectFileSize, modifiedTime); - mDatabase->unlockMutex(); - if (handle == kInvalidObjectHandle) { - MTPE("MtpServer::doSendObjectInfo returning MTP_RESPONSE_GENERAL_ERROR, handle == kInvalidObjectHandle\n"); - return MTP_RESPONSE_GENERAL_ERROR; - } - - if (format == MTP_FORMAT_ASSOCIATION) { - mode_t mask = umask(0); - MTPD("MtpServer::doSendObjectInfo mkdir '%s'\n", (const char *)path); - int ret = mkdir((const char *)path, mDirectoryPermission); - umask(mask); - if (ret && ret != -EEXIST) { - MTPE("MtpServer::doSendObjectInfo returning MTP_RESPONSE_GENERAL_ERROR, ret && ret != -EEXIST\n"); - return MTP_RESPONSE_GENERAL_ERROR; - } - chown((const char *)path, getuid(), mFileGroup); - tw_set_default_metadata((const char *)path); - - // SendObject does not get sent for directories, so call endSendObject here instead - mDatabase->lockMutex(); - mDatabase->endSendObject(path, handle, MTP_FORMAT_ASSOCIATION, MTP_RESPONSE_OK); - mDatabase->unlockMutex(); - } else { - mSendObjectFilePath = path; - // save the handle for the SendObject call, which should follow - mSendObjectHandle = handle; - mSendObjectFormat = format; - } - - mResponse.setParameter(1, storageID); - mResponse.setParameter(2, parent); - mResponse.setParameter(3, handle); - MTPD("MtpServer::doSendObjectInfo returning MTP_RESPONSE_OK\n"); - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doSendObject() { - if (!hasStorage()) - return MTP_RESPONSE_GENERAL_ERROR; - MtpResponseCode result = MTP_RESPONSE_OK; - mode_t mask; - int ret = 0, initialData; - - if (mSendObjectHandle == kInvalidObjectHandle) { - MTPE("Expected SendObjectInfo before SendObject"); - result = MTP_RESPONSE_NO_VALID_OBJECT_INFO; - goto done; - } - - // read the header, and possibly some data - ret = mData.read(mFD); - if (ret < MTP_CONTAINER_HEADER_SIZE) { - MTPE("MTP_RESPONSE_GENERAL_ERROR\n"); - result = MTP_RESPONSE_GENERAL_ERROR; - goto done; - } - initialData = ret - MTP_CONTAINER_HEADER_SIZE; - - mtp_file_range mfr; - mfr.fd = open(mSendObjectFilePath, O_RDWR | O_CREAT | O_TRUNC, 0640); - if (mfr.fd < 0) { - result = MTP_RESPONSE_GENERAL_ERROR; - MTPE("fd error\n"); - goto done; - } - fchown(mfr.fd, getuid(), mFileGroup); - // set permissions - mask = umask(0); - fchmod(mfr.fd, mFilePermission); - umask(mask); - - if (initialData > 0) - ret = write(mfr.fd, mData.getData(), initialData); - - if (mSendObjectFileSize - initialData > 0) { - mfr.offset = initialData; - if (mSendObjectFileSize == 0xFFFFFFFF) { - // tell driver to read until it receives a short packet - mfr.length = 0xFFFFFFFF; - } else { - mfr.length = mSendObjectFileSize - initialData; - } - - MTPD("receiving %s\n", (const char *)mSendObjectFilePath); - // transfer the file - ret = ioctl(mFD, MTP_RECEIVE_FILE, (unsigned long)&mfr); - } - close(mfr.fd); - tw_set_default_metadata((const char *)mSendObjectFilePath); - - if (ret < 0) { - unlink(mSendObjectFilePath); - if (errno == ECANCELED) - result = MTP_RESPONSE_TRANSACTION_CANCELLED; - else { - MTPD("errno: %d\n", errno); - result = MTP_RESPONSE_GENERAL_ERROR; - } - } - -done: - // reset so we don't attempt to send the data back - MTPD("MTP_RECEIVE_FILE returned %d\n", ret); - mData.reset(); - mDatabase->lockMutex(); - mDatabase->endSendObject(mSendObjectFilePath, mSendObjectHandle, mSendObjectFormat, - result == MTP_RESPONSE_OK); - mDatabase->unlockMutex(); - mSendObjectHandle = kInvalidObjectHandle; - MTPD("result: %d\n", result); - mSendObjectFormat = 0; - return result; -} - -static void deleteRecursive(const char* path) { - char pathbuf[PATH_MAX]; - size_t pathLength = strlen(path); - if (pathLength >= sizeof(pathbuf) - 1) { - MTPE("path too long: %s\n", path); - } - strcpy(pathbuf, path); - if (pathbuf[pathLength - 1] != '/') { - pathbuf[pathLength++] = '/'; - } - char* fileSpot = pathbuf + pathLength; - int pathRemaining = sizeof(pathbuf) - pathLength - 1; - - DIR* dir = opendir(path); - if (!dir) { - MTPE("opendir %s failed: %s", path, strerror(errno)); - return; - } - - struct dirent* entry; - while ((entry = readdir(dir))) { - const char* name = entry->d_name; - - // ignore "." and ".." - if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) { - continue; - } - - int nameLength = strlen(name); - if (nameLength > pathRemaining) { - MTPE("path %s/%s too long\n", path, name); - continue; - } - strcpy(fileSpot, name); - - int type = entry->d_type; - struct stat st; - if (lstat(pathbuf, &st)) { - MTPE("Failed to lstat '%s'\n", pathbuf); - continue; - } - if (st.st_mode & S_IFDIR) { - deleteRecursive(pathbuf); - rmdir(pathbuf); - } else { - unlink(pathbuf); - } - } - closedir(dir); -} - -static void deletePath(const char* path) { - struct stat statbuf; - if (stat(path, &statbuf) == 0) { - if (S_ISDIR(statbuf.st_mode)) { - deleteRecursive(path); - rmdir(path); - } else { - unlink(path); - } - } else { - MTPE("deletePath stat failed for %s: %s", path, strerror(errno)); - } -} - -MtpResponseCode MtpServer::doDeleteObject() { - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpObjectHandle handle = mRequest.getParameter(1); - MtpObjectFormat format = mRequest.getParameter(2); - // FIXME - support deleting all objects if handle is 0xFFFFFFFF - // FIXME - implement deleting objects by format - - MtpString filePath; - int64_t fileLength; - MTPD("MtpServer::doDeleteObject calling getObjectFilePath\n"); - mDatabase->lockMutex(); - int result = mDatabase->getObjectFilePath(handle, filePath, fileLength, format); - if (result == MTP_RESPONSE_OK) { - MTPD("deleting %s", (const char *)filePath); - result = mDatabase->deleteFile(handle); - // Don't delete the actual files unless the database deletion is allowed - if (result == MTP_RESPONSE_OK) { - deletePath((const char *)filePath); - } - } - mDatabase->unlockMutex(); - return result; -} - -MtpResponseCode MtpServer::doGetObjectPropDesc() { - MtpObjectProperty propCode = mRequest.getParameter(1); - MtpObjectFormat format = mRequest.getParameter(2); - MTPD("MtpServer::doGetObjectPropDesc %s %s\n", MtpDebug::getObjectPropCodeName(propCode), - MtpDebug::getFormatCodeName(format)); - mDatabase->lockMutex(); - MtpProperty* property = mDatabase->getObjectPropertyDesc(propCode, format); - mDatabase->unlockMutex(); - if (!property) { - MTPE("MtpServer::doGetObjectPropDesc propery not supported\n"); - return MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED; - } - property->write(mData); - delete property; - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doGetDevicePropDesc() { - MtpDeviceProperty propCode = mRequest.getParameter(1); - MTPD("GetDevicePropDesc %s\n", MtpDebug::getDevicePropCodeName(propCode)); - mDatabase->lockMutex(); - MtpProperty* property = mDatabase->getDevicePropertyDesc(propCode); - mDatabase->unlockMutex(); - if (!property) { - MTPE("MtpServer::doGetDevicePropDesc property not supported\n"); - return MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED; - } - property->write(mData); - delete property; - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doSendPartialObject() { - if (!hasStorage()) - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpObjectHandle handle = mRequest.getParameter(1); - uint64_t offset = mRequest.getParameter(2); - uint64_t offset2 = mRequest.getParameter(3); - offset = offset | (offset2 << 32); - uint32_t length = mRequest.getParameter(4); - - ObjectEdit* edit = getEditObject(handle); - if (!edit) { - MTPE("object not open for edit in doSendPartialObject"); - return MTP_RESPONSE_GENERAL_ERROR; - } - - // can't start writing past the end of the file - if (offset > edit->mSize) { - MTPE("writing past end of object, offset: %lld, edit->mSize: %lld", offset, edit->mSize); - return MTP_RESPONSE_GENERAL_ERROR; - } - - const char* filePath = (const char *)edit->mPath; - MTPD("receiving partial %s %lld %lld\n", filePath, offset, length); - - // read the header, and possibly some data - int ret = mData.read(mFD); - if (ret < MTP_CONTAINER_HEADER_SIZE) - return MTP_RESPONSE_GENERAL_ERROR; - int initialData = ret - MTP_CONTAINER_HEADER_SIZE; - - if (initialData > 0) { - ret = write(edit->mFD, mData.getData(), initialData); - offset += initialData; - length -= initialData; - } - - if (length > 0) { - mtp_file_range mfr; - mfr.fd = edit->mFD; - mfr.offset = offset; - mfr.length = length; - - // transfer the file - ret = ioctl(mFD, MTP_RECEIVE_FILE, (unsigned long)&mfr); - MTPD("MTP_RECEIVE_FILE returned %d", ret); - } - if (ret < 0) { - mResponse.setParameter(1, 0); - if (errno == ECANCELED) - return MTP_RESPONSE_TRANSACTION_CANCELLED; - else - return MTP_RESPONSE_GENERAL_ERROR; - } - - // reset so we don't attempt to send this back - mData.reset(); - mResponse.setParameter(1, length); - uint64_t end = offset + length; - if (end > edit->mSize) { - edit->mSize = end; - } - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doTruncateObject() { - MtpObjectHandle handle = mRequest.getParameter(1); - ObjectEdit* edit = getEditObject(handle); - if (!edit) { - MTPE("object not open for edit in doTruncateObject"); - return MTP_RESPONSE_GENERAL_ERROR; - } - - uint64_t offset = mRequest.getParameter(2); - uint64_t offset2 = mRequest.getParameter(3); - offset |= (offset2 << 32); - if (ftruncate(edit->mFD, offset) != 0) { - return MTP_RESPONSE_GENERAL_ERROR; - } else { - edit->mSize = offset; - return MTP_RESPONSE_OK; - } -} - -MtpResponseCode MtpServer::doBeginEditObject() { - MtpObjectHandle handle = mRequest.getParameter(1); - if (getEditObject(handle)) { - MTPE("object already open for edit in doBeginEditObject"); - return MTP_RESPONSE_GENERAL_ERROR; - } - - MtpString path; - int64_t fileLength; - MtpObjectFormat format; - MTPD("MtpServer::doBeginEditObject calling getObjectFilePath\n"); - mDatabase->lockMutex(); - int result = mDatabase->getObjectFilePath(handle, path, fileLength, format); - mDatabase->unlockMutex(); - if (result != MTP_RESPONSE_OK) - return result; - - int fd = open((const char *)path, O_RDWR | O_EXCL); - if (fd < 0) { - MTPE("open failed for %s in doBeginEditObject (%d)", (const char *)path, errno); - return MTP_RESPONSE_GENERAL_ERROR; - } - - addEditObject(handle, path, fileLength, format, fd); - return MTP_RESPONSE_OK; -} - -MtpResponseCode MtpServer::doEndEditObject() { - MtpObjectHandle handle = mRequest.getParameter(1); - ObjectEdit* edit = getEditObject(handle); - if (!edit) { - MTPE("object not open for edit in doEndEditObject"); - return MTP_RESPONSE_GENERAL_ERROR; - } - - commitEdit(edit); - removeEditObject(handle); - return MTP_RESPONSE_OK; -} diff --git a/mtp/legacy/MtpServer.h b/mtp/legacy/MtpServer.h deleted file mode 100644 index d58cb30a..00000000 --- a/mtp/legacy/MtpServer.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_SERVER_H -#define _MTP_SERVER_H - -#include -#include -#include "MtpRequestPacket.h" -#include "MtpDatabase.h" -#include "MtpDataPacket.h" -#include "MtpResponsePacket.h" -#include "MtpEventPacket.h" -#include "mtp.h" -#include "MtpUtils.h" - - -class MtpDatabase; -class MtpStorage; - -class MtpServer { - -private: - // file descriptor for MTP kernel driver - int mFD; - android::Mutex mMutex; - MtpDatabase* mDatabase; - - // appear as a PTP device - bool mPtp; - - // group to own new files and folders - int mFileGroup; - // permissions for new files and directories - int mFilePermission; - int mDirectoryPermission; - - // current session ID - MtpSessionID mSessionID; - // true if we have an open session and mSessionID is valid - bool mSessionOpen; - - MtpRequestPacket mRequest; - MtpDataPacket mData; - MtpResponsePacket mResponse; - MtpEventPacket mEvent; - - MtpStorageList mStorages; - - // handle for new object, set by SendObjectInfo and used by SendObject - MtpObjectHandle mSendObjectHandle; - MtpObjectFormat mSendObjectFormat; - MtpString mSendObjectFilePath; - size_t mSendObjectFileSize; - - pthread_mutex_t mtpMutex; - - // represents an MTP object that is being edited using the android extensions - // for direct editing (BeginEditObject, SendPartialObject, TruncateObject and EndEditObject) - class ObjectEdit { - public: - MtpObjectHandle mHandle; - MtpString mPath; - uint64_t mSize; - MtpObjectFormat mFormat; - int mFD; - - ObjectEdit(MtpObjectHandle handle, const char* path, uint64_t size, - MtpObjectFormat format, int fd) - : mHandle(handle), mPath(path), mSize(size), mFormat(format), mFD(fd) { - } - - virtual ~ObjectEdit() { - close(mFD); - } - }; - android::Vector mObjectEditList; - -public: - MtpServer(MtpDatabase* database, bool ptp, - int fileGroup, int filePerm, int directoryPerm); - virtual ~MtpServer(); - - MtpStorage* getStorage(MtpStorageID id); - inline bool hasStorage() { return mStorages.size() > 0; } - bool hasStorage(MtpStorageID id); - void addStorage(MtpStorage* storage); - void removeStorage(MtpStorage* storage); - - void run(int fd); - - void sendObjectAdded(MtpObjectHandle handle); - void sendObjectRemoved(MtpObjectHandle handle); - void sendObjectUpdated(MtpObjectHandle handle); - -private: - void sendStoreAdded(MtpStorageID id); - void sendStoreRemoved(MtpStorageID id); - void sendEvent(MtpEventCode code, uint32_t param1); - - void addEditObject(MtpObjectHandle handle, MtpString& path, - uint64_t size, MtpObjectFormat format, int fd); - ObjectEdit* getEditObject(MtpObjectHandle handle); - void removeEditObject(MtpObjectHandle handle); - void commitEdit(ObjectEdit* edit); - - bool handleRequest(); - - MtpResponseCode doGetDeviceInfo(); - MtpResponseCode doOpenSession(); - MtpResponseCode doCloseSession(); - MtpResponseCode doGetStorageIDs(); - MtpResponseCode doGetStorageInfo(); - MtpResponseCode doGetObjectPropsSupported(); - MtpResponseCode doGetObjectHandles(); - MtpResponseCode doGetNumObjects(); - MtpResponseCode doGetObjectReferences(); - MtpResponseCode doSetObjectReferences(); - MtpResponseCode doGetObjectPropValue(); - MtpResponseCode doSetObjectPropValue(); - MtpResponseCode doGetDevicePropValue(); - MtpResponseCode doSetDevicePropValue(); - MtpResponseCode doResetDevicePropValue(); - MtpResponseCode doGetObjectPropList(); - MtpResponseCode doGetObjectInfo(); - MtpResponseCode doGetObject(); - MtpResponseCode doGetThumb(); - MtpResponseCode doGetPartialObject(MtpOperationCode operation); - MtpResponseCode doSendObjectInfo(); - MtpResponseCode doSendObject(); - MtpResponseCode doDeleteObject(); - MtpResponseCode doGetObjectPropDesc(); - MtpResponseCode doGetDevicePropDesc(); - MtpResponseCode doSendPartialObject(); - MtpResponseCode doTruncateObject(); - MtpResponseCode doBeginEditObject(); - MtpResponseCode doEndEditObject(); -}; - -#endif // _MTP_SERVER_H diff --git a/mtp/legacy/MtpStorage.cpp b/mtp/legacy/MtpStorage.cpp deleted file mode 100644 index b22158a1..00000000 --- a/mtp/legacy/MtpStorage.cpp +++ /dev/null @@ -1,856 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include "MtpDebug.h" -#include "MtpStorage.h" -#include "MtpDataPacket.h" -#include "MtpServer.h" -#include "MtpEventPacket.h" -#include "MtpDatabase.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../tw_atomic.hpp" - -#define WATCH_FLAGS ( IN_CREATE | IN_DELETE | IN_MOVE | IN_MODIFY ) - -MtpStorage::MtpStorage(MtpStorageID id, const char* filePath, - const char* description, uint64_t reserveSpace, - bool removable, uint64_t maxFileSize, MtpServer* refserver) - : mStorageID(id), - mFilePath(filePath), - mDescription(description), - mMaxCapacity(0), - mMaxFileSize(maxFileSize), - mReserveSpace(reserveSpace), - mRemovable(removable), - mServer(refserver) -{ - MTPI("MtpStorage id: %d path: %s\n", id, filePath); - inotify_thread = 0; - inotify_fd = -1; - // Threading has not started yet so we should be safe to set these directly instead of using atomics - inotify_thread_kill.set_value(0); - sendEvents = false; - handleCurrentlySending = 0; - use_mutex = true; - if (pthread_mutex_init(&mtpMutex, NULL) != 0) { - MTPE("Failed to init mtpMutex\n"); - use_mutex = false; - } - if (pthread_mutex_init(&inMutex, NULL) != 0) { - MTPE("Failed to init inMutex\n"); - pthread_mutex_destroy(&mtpMutex); - use_mutex = false; - } -} - -MtpStorage::~MtpStorage() { - if (inotify_thread) { - inotify_thread_kill.set_value(1); - MTPD("joining inotify_thread after sending the kill notification.\n"); - pthread_join(inotify_thread, NULL); // There's not much we can do if there's an error here - inotify_thread = 0; - MTPD("~MtpStorage removing inotify watches and closing inotify_fd\n"); - for (std::map::iterator i = inotifymap.begin(); i != inotifymap.end(); i++) { - inotify_rm_watch(inotify_fd, i->first); - } - close(inotify_fd); - inotifymap.clear(); - } - // Deleting the root tree causes a cascade in btree.cpp that ends up - // deleting all of the trees and nodes. - delete mtpmap[0]; - mtpmap.clear(); - if (use_mutex) { - use_mutex = false; - MTPD("~MtpStorage destroying mutexes\n"); - pthread_mutex_destroy(&mtpMutex); - pthread_mutex_destroy(&inMutex); - } -} - -int MtpStorage::getType() const { - return (mRemovable ? MTP_STORAGE_REMOVABLE_RAM : MTP_STORAGE_FIXED_RAM); -} - -int MtpStorage::getFileSystemType() const { - return MTP_STORAGE_FILESYSTEM_HIERARCHICAL; -} - -int MtpStorage::getAccessCapability() const { - return MTP_STORAGE_READ_WRITE; -} - -uint64_t MtpStorage::getMaxCapacity() { - if (mMaxCapacity == 0) { - struct statfs stat; - if (statfs(getPath(), &stat)) - return -1; - mMaxCapacity = (uint64_t)stat.f_blocks * (uint64_t)stat.f_bsize; - } - return mMaxCapacity; -} - -uint64_t MtpStorage::getFreeSpace() { - struct statfs stat; - if (statfs(getPath(), &stat)) - return -1; - uint64_t freeSpace = (uint64_t)stat.f_bavail * (uint64_t)stat.f_bsize; - return (freeSpace > mReserveSpace ? freeSpace - mReserveSpace : 0); -} - -const char* MtpStorage::getDescription() const { - return (const char *)mDescription; -} - -int MtpStorage::createDB() { - std::string mtpParent = ""; - mtpstorageparent = getPath(); - // root directory is special: handle 0, parent 0, and empty path - mtpmap[0] = new Tree(0, 0, ""); - MTPD("MtpStorage::createDB DONE\n"); - if (use_mutex) { - sendEvents = true; - MTPD("inotify_init\n"); - inotify_fd = inotify_init(); - if (inotify_fd < 0) { - MTPE("Can't run inotify_init for mtp server: %s\n", strerror(errno)); - } else { - MTPD("Starting inotify thread\n"); - inotify_thread = inotify(); - } - } else { - MTPD("NOT starting inotify thread\n"); - } - // for debugging and caching purposes, read the root dir already now - readDir(mtpstorageparent, mtpmap[0]); - // all other dirs are read on demand - return 0; -} - -MtpObjectHandleList* MtpStorage::getObjectList(MtpStorageID storageID, MtpObjectHandle parent) { - MTPD("MtpStorage::getObjectList, parent: %u\n", parent); - //append object id (numerical #s) of database to int array - MtpObjectHandleList* list = new MtpObjectHandleList(); - if (parent == MTP_PARENT_ROOT) { - MTPD("parent == MTP_PARENT_ROOT\n"); - parent = 0; - } - - if (mtpmap.find(parent) == mtpmap.end()) { - MTPE("parent handle not found, returning empty list\n"); - return list; - } - - Tree* tree = mtpmap[parent]; - if (!tree->wasAlreadyRead()) - { - std::string path = getNodePath(tree); - MTPD("reading directory on demand for tree %p (%u), path: %s\n", tree, tree->Mtpid(), path.c_str()); - readDir(path, tree); - } - - mtpmap[parent]->getmtpids(list); - MTPD("returning %u objects in %s.\n", list->size(), tree->getName().c_str()); - return list; -} - -int MtpStorage::getObjectInfo(MtpObjectHandle handle, MtpObjectInfo& info) { - struct stat st; - uint64_t size = 0; - MTPD("MtpStorage::getObjectInfo, handle: %u\n", handle); - Node* node = findNode(handle); - if (!node) { - // Item is not on this storage device - return -1; - } - - info.mStorageID = getStorageID(); - MTPD("info.mStorageID: %u\n", info.mStorageID); - info.mParent = node->getMtpParentId(); - MTPD("mParent: %u\n", info.mParent); - // TODO: do we want to lstat again here, or read from the node properties? - if (lstat(getNodePath(node).c_str(), &st) == 0) - size = st.st_size; - MTPD("size is: %llu\n", size); - info.mCompressedSize = (size > 0xFFFFFFFFLL ? 0xFFFFFFFF : size); - info.mDateModified = st.st_mtime; - if (S_ISDIR(st.st_mode)) { - info.mFormat = MTP_FORMAT_ASSOCIATION; - } - else { - info.mFormat = MTP_FORMAT_UNDEFINED; - } - info.mName = strdup(node->getName().c_str()); - MTPD("MtpStorage::getObjectInfo found, Exiting getObjectInfo()\n"); - return 0; -} - -MtpObjectHandle MtpStorage::beginSendObject(const char* path, - MtpObjectFormat format, - MtpObjectHandle parent, - uint64_t size, - time_t modified) { - MTPD("MtpStorage::beginSendObject(), path: '%s', parent: %u, format: %04x\n", path, parent, format); - iter it = mtpmap.find(parent); - if (it == mtpmap.end()) { - MTPE("parent node not found, returning error\n"); - return kInvalidObjectHandle; - } - Tree* tree = it->second; - - std::string pathstr(path); - size_t slashpos = pathstr.find_last_of('/'); - if (slashpos == std::string::npos) { - MTPE("path has no slash, returning error\n"); - return kInvalidObjectHandle; - } - std::string parentdir = pathstr.substr(0, slashpos); - std::string basename = pathstr.substr(slashpos + 1); - if (parent != 0 && parentdir != getNodePath(tree)) { - MTPE("beginSendObject into path '%s' but parent tree has path '%s', returning error\n", parentdir.c_str(), getNodePath(tree).c_str()); - return kInvalidObjectHandle; - } - - MTPD("MtpStorage::beginSendObject() parentdir: %s basename: %s\n", parentdir.c_str(), basename.c_str()); - // note: for directories, the mkdir call is done later in MtpServer, here we just reserve a handle - bool isDir = format == MTP_FORMAT_ASSOCIATION; - Node* node = addNewNode(isDir, tree, basename); - handleCurrentlySending = node->Mtpid(); // suppress inotify for this node while sending - - return node->Mtpid(); -} - -void MtpStorage::endSendObject(const char* path, MtpObjectHandle handle, MtpObjectFormat format, bool succeeded) -{ - Node* node = findNode(handle); - if (!node) - return; // just ignore if this is for another storage - - node->addProperties(path, mStorageID); - handleCurrentlySending = 0; - // TODO: are we supposed to send an event about an upload by the initiator? - if (sendEvents) - mServer->sendObjectAdded(node->Mtpid()); -} - -int MtpStorage::getObjectFilePath(MtpObjectHandle handle, MtpString& outFilePath, int64_t& outFileLength, MtpObjectFormat& outFormat) { - MTPD("MtpStorage::getObjectFilePath handle: %u\n", handle); - Node* node = findNode(handle); - if (!node) - { - // Item is not on this storage device - return -1; - } - // TODO: do we want to lstat here, or just read the info from the node? - struct stat st; - if (lstat(getNodePath(node).c_str(), &st) == 0) - outFileLength = st.st_size; - else - outFileLength = 0; - outFilePath = getNodePath(node).c_str(); - MTPD("outFilePath: %s\n", outFilePath.string()); - outFormat = node->isDir() ? MTP_FORMAT_ASSOCIATION : MTP_FORMAT_UNDEFINED; - return 0; -} - -int MtpStorage::readDir(const std::string& path, Tree* tree) -{ - struct dirent *de; - int storageID = getStorageID(); - MtpObjectHandle parent = tree->Mtpid(); - - DIR *d = opendir(path.c_str()); - MTPD("reading dir '%s', parent handle %u\n", path.c_str(), parent); - if (d == NULL) { - MTPE("error opening '%s' -- error: %s\n", path.c_str(), strerror(errno)); - return -1; - } - // TODO: for refreshing dirs: capture old entries here - while ((de = readdir(d)) != NULL) { - // Because exfat-fuse causes issues with dirent, we will use stat - // for some things that dirent should be able to do - std::string item = path + "/" + de->d_name; - struct stat st; - if (lstat(item.c_str(), &st)) { - MTPE("Error running lstat on '%s'\n", item.c_str()); - return -1; - } - // TODO: if we want to use this for refreshing dirs too, first find existing name and overwrite - if (strcmp(de->d_name, ".") == 0) - continue; - if (strcmp(de->d_name, "..") == 0) - continue; - Node* node = addNewNode(st.st_mode & S_IFDIR, tree, de->d_name); - node->addProperties(item, storageID); - //if (sendEvents) - // mServer->sendObjectAdded(node->Mtpid()); - // sending events here makes simple-mtpfs very slow, and it is probably the wrong thing to do anyway - } - closedir(d); - // TODO: for refreshing dirs: remove entries that no longer exist (with their nodes) - tree->setAlreadyRead(true); - addInotify(tree); - return 0; -} - -int MtpStorage::deleteFile(MtpObjectHandle handle) { - MTPD("MtpStorage::deleteFile handle: %u\n", handle); - Node* node = findNode(handle); - if (!node) { - // Item is not on this storage device - return -1; - } - MtpObjectHandle parent = node->getMtpParentId(); - Tree* tree = mtpmap[parent]; - if (!tree) { - MTPE("parent tree for handle %u not found\n", parent); - return -1; - } - if (node->isDir()) { - MTPD("deleting tree from mtpmap: %u\n", handle); - mtpmap.erase(handle); - } - - MTPD("deleting handle: %u\n", handle); - tree->deleteNode(handle); - MTPD("deleted\n"); - return 0; -} - -void MtpStorage::queryNodeProperties(std::vector& results, Node* node, uint32_t property, int groupCode, MtpStorageID storageID) -{ - MTPD("queryNodeProperties handle %u, path: %s\n", node->Mtpid(), getNodePath(node).c_str()); - PropEntry pe; - pe.handle = node->Mtpid(); - pe.property = property; - - if (property == 0xffffffff) - { - // add all properties - MTPD("MtpStorage::queryNodeProperties for all properties\n"); - std::vector mtpprop = node->getMtpProps(); - for (size_t i = 0; i < mtpprop.size(); ++i) { - pe.property = mtpprop[i].property; - pe.datatype = mtpprop[i].dataType; - pe.intvalue = mtpprop[i].valueInt; - pe.strvalue = mtpprop[i].valueStr; - results.push_back(pe); - } - return; - } - else if (property == 0) - { - // TODO: use groupCode - } - - // single property - // TODO: this should probably be moved to the Node class and/or merged with getObjectPropertyValue - switch (property) { -// case MTP_PROPERTY_OBJECT_FORMAT: -// pe.datatype = MTP_TYPE_UINT16; -// pe.intvalue = node->getIntProperty(MTP_PROPERTY_OBJECT_FORMAT); -// break; - - case MTP_PROPERTY_STORAGE_ID: - pe.datatype = MTP_TYPE_UINT32; - pe.intvalue = storageID; - break; - - case MTP_PROPERTY_PROTECTION_STATUS: - pe.datatype = MTP_TYPE_UINT16; - pe.intvalue = 0; - break; - - case MTP_PROPERTY_OBJECT_SIZE: - { - pe.datatype = MTP_TYPE_UINT64; - struct stat st; - pe.intvalue = 0; - if (lstat(getNodePath(node).c_str(), &st) == 0) - pe.intvalue = st.st_size; - break; - } - - default: - { - const Node::mtpProperty& prop = node->getProperty(property); - if (prop.property != property) - { - MTPD("queryNodeProperties: unknown property %x\n", property); - return; - } - pe.datatype = prop.dataType; - pe.intvalue = prop.valueInt; - pe.strvalue = prop.valueStr; - // TODO: all the special case stuff in MyMtpDatabase::getObjectPropertyValue is missing here - } - - } - results.push_back(pe); -} - -int MtpStorage::getObjectPropertyList(MtpObjectHandle handle, uint32_t format, uint32_t property, int groupCode, int depth, MtpDataPacket& packet) { - MTPD("MtpStorage::getObjectPropertyList handle: %u, format: %x, property: %x\n", handle, format, property); - if (groupCode != 0) - { - MTPE("getObjectPropertyList: groupCode unsupported\n"); - return -1; // TODO: RESPONSE_SPECIFICATION_BY_GROUP_UNSUPPORTED - } - // TODO: support all the special stuff, like: - // handle == 0 -> all objects at the root level - // handle == 0xffffffff -> all objects (on all storages? how could we support that?) - // format == 0 -> all formats, otherwise filter by ObjectFormatCode - // property == 0xffffffff -> all properties except those with group code 0xffffffff - // if property == 0 then use groupCode - // groupCode == 0 -> return Specification_By_Group_Unsupported - // depth == 0xffffffff -> all objects incl. and below handle - - std::vector results; - - if (handle == 0xffffffff) { - // TODO: all object on all storages (needs a different design, result packet needs to be built by server instead of storage) - } else if (handle == 0) { - // all objects at the root level - Tree* root = mtpmap[0]; - MtpObjectHandleList list; - root->getmtpids(&list); - for (MtpObjectHandleList::iterator it = list.begin(); it != list.end(); ++it) { - Node* node = root->findNode(*it); - if (!node) { - MTPE("BUG: node not found for root entry with handle %u\n", *it); - break; - } - queryNodeProperties(results, node, property, groupCode, mStorageID); - } - } else { - // single object - Node* node = findNode(handle); - if (!node) { - // Item is not on this storage device - return -1; - } - queryNodeProperties(results, node, property, groupCode, mStorageID); - } - - MTPD("count: %u\n", results.size()); - packet.putUInt32(results.size()); - - for (size_t i = 0; i < results.size(); ++i) { - PropEntry& p = results[i]; - MTPD("handle: %u, propertyCode: %x = %s, datatype: %x, value: %llu\n", - p.handle, p.property, MtpDebug::getObjectPropCodeName(p.property), - p.datatype, p.intvalue); - packet.putUInt32(p.handle); - packet.putUInt16(p.property); - packet.putUInt16(p.datatype); - switch (p.datatype) { - case MTP_TYPE_INT8: - MTPD("MTP_TYPE_INT8\n"); - packet.putInt8(p.intvalue); - break; - case MTP_TYPE_UINT8: - MTPD("MTP_TYPE_UINT8\n"); - packet.putUInt8(p.intvalue); - break; - case MTP_TYPE_INT16: - MTPD("MTP_TYPE_INT16\n"); - packet.putInt16(p.intvalue); - break; - case MTP_TYPE_UINT16: - MTPD("MTP_TYPE_UINT16\n"); - packet.putUInt16(p.intvalue); - break; - case MTP_TYPE_INT32: - MTPD("MTP_TYPE_INT32\n"); - packet.putInt32(p.intvalue); - break; - case MTP_TYPE_UINT32: - MTPD("MTP_TYPE_UINT32\n"); - packet.putUInt32(p.intvalue); - break; - case MTP_TYPE_INT64: - MTPD("MTP_TYPE_INT64\n"); - packet.putInt64(p.intvalue); - break; - case MTP_TYPE_UINT64: - MTPD("MTP_TYPE_UINT64\n"); - packet.putUInt64(p.intvalue); - break; - case MTP_TYPE_INT128: - MTPD("MTP_TYPE_INT128\n"); - packet.putInt128(p.intvalue); - break; - case MTP_TYPE_UINT128: - MTPD("MTP_TYPE_UINT128\n"); - packet.putUInt128(p.intvalue); - break; - case MTP_TYPE_STR: - MTPD("MTP_TYPE_STR: %s\n", p.strvalue.c_str()); - packet.putString(p.strvalue.c_str()); - break; - default: - MTPE("bad or unsupported data type: %x in MyMtpDatabase::getObjectPropertyList", p.datatype); - break; - } - } - return 0; -} - -int MtpStorage::renameObject(MtpObjectHandle handle, std::string newName) { - MTPD("MtpStorage::renameObject, handle: %u, new name: '%s'\n", handle, newName.c_str()); - if (handle == MTP_PARENT_ROOT) { - MTPE("parent == MTP_PARENT_ROOT, cannot rename root\n"); - return -1; - } else { - for (iter i = mtpmap.begin(); i != mtpmap.end(); i++) { - Node* node = i->second->findNode(handle); - if (node != NULL) { - std::string oldName = getNodePath(node); - std::string parentdir = oldName.substr(0, oldName.find_last_of('/')); - std::string newFullName = parentdir + "/" + newName; - MTPD("old: '%s', new: '%s'\n", oldName.c_str(), newFullName.c_str()); - if (rename(oldName.c_str(), newFullName.c_str()) == 0) { - node->rename(newName); - return 0; - } else { - MTPE("MtpStorage::renameObject failed, handle: %u, new name: '%s'\n", handle, newName.c_str()); - return -1; - } - } - } - } - // handle not found on this storage - return -1; -} - -int MtpStorage::getObjectPropertyValue(MtpObjectHandle handle, MtpObjectProperty property, MtpStorage::PropEntry& pe) { - Node *node; - for (iter i = mtpmap.begin(); i != mtpmap.end(); i++) { - node = i->second->findNode(handle); - if (node != NULL) { - const Node::mtpProperty& prop = node->getProperty(property); - if (prop.property != property) { - MTPD("getObjectPropertyValue: unknown property %x for handle %u\n", property, handle); - return -1; - } - pe.datatype = prop.dataType; - pe.intvalue = prop.valueInt; - pe.strvalue = prop.valueStr; - pe.handle = handle; - pe.property = property; - return 0; - } - } - // handle not found on this storage - return -1; -} - -pthread_t MtpStorage::inotify(void) { - pthread_t thread; - pthread_attr_t tattr; - - if (pthread_attr_init(&tattr)) { - MTPE("Unable to pthread_attr_init\n"); - return 0; - } - if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE)) { - MTPE("Error setting pthread_attr_setdetachstate\n"); - return 0; - } - ThreadPtr inotifyptr = &MtpStorage::inotify_t; - PThreadPtr p = *(PThreadPtr*)&inotifyptr; - pthread_create(&thread, &tattr, p, this); - if (pthread_attr_destroy(&tattr)) { - MTPE("Failed to pthread_attr_destroy\n"); - } - return thread; -} - -int MtpStorage::addInotify(Tree* tree) { - if (inotify_fd < 0) { - MTPE("inotify_fd not set or error: %i\n", inotify_fd); - return -1; - } - std::string path = getNodePath(tree); - MTPD("adding inotify for tree %x, dir: %s\n", tree, path.c_str()); - int wd = inotify_add_watch(inotify_fd, path.c_str(), WATCH_FLAGS); - if (wd < 0) { - MTPE("inotify_add_watch failed: %s\n", strerror(errno)); - return -1; - } - inotifymap[wd] = tree; - return 0; -} - -void MtpStorage::handleInotifyEvent(struct inotify_event* event) -{ - std::map::iterator it = inotifymap.find(event->wd); - if (it == inotifymap.end()) { - MTPE("Unable to locate inotify_wd: %i\n", event->wd); - return; - } - Tree* tree = it->second; - MTPD("inotify_t tree: %x '%s'\n", tree, tree->getName().c_str()); - Node* node = tree->findEntryByName(basename(event->name)); - if (node && node->Mtpid() == handleCurrentlySending) { - MTPD("ignoring inotify event for currently uploading file, handle: %u\n", node->Mtpid()); - return; - } - if (event->mask & IN_CREATE || event->mask & IN_MOVED_TO) { - if (event->mask & IN_ISDIR) { - MTPD("inotify_t create is dir\n"); - } else { - MTPD("inotify_t create is file\n"); - } - if (node == NULL) { - node = addNewNode(event->mask & IN_ISDIR, tree, event->name); - std::string item = getNodePath(tree) + "/" + event->name; - node->addProperties(item, getStorageID()); - mServer->sendObjectAdded(node->Mtpid()); - } else { - MTPD("inotify_t item already exists.\n"); - } - if (event->mask & IN_ISDIR) { - // TODO: do we need to do anything here? probably not until someone reads from the dir... - } - } else if (event->mask & IN_DELETE || event->mask & IN_MOVED_FROM) { - if (event->mask & IN_ISDIR) { - MTPD("inotify_t Directory %s deleted\n", event->name); - } else { - MTPD("inotify_t File %s deleted\n", event->name); - } - if (node) - { - if (event->mask & IN_ISDIR) { - for (std::map::iterator it = inotifymap.begin(); it != inotifymap.end(); ++it) { - if (it->second == node) { - inotify_rm_watch(inotify_fd, it->first); - MTPD("inotify_t removing watch on '%s'\n", getNodePath(it->second).c_str()); - inotifymap.erase(it->first); - break; - } - - } - } - MtpObjectHandle handle = node->Mtpid(); - deleteFile(handle); - mServer->sendObjectRemoved(handle); - } else { - MTPD("inotify_t already removed.\n"); - } - } else if (event->mask & IN_MODIFY) { - MTPD("inotify_t item %s modified.\n", event->name); - if (node != NULL) { - uint64_t orig_size = node->getProperty(MTP_PROPERTY_OBJECT_SIZE).valueInt; - struct stat st; - uint64_t new_size = 0; - if (lstat(getNodePath(node).c_str(), &st) == 0) - new_size = (uint64_t)st.st_size; - if (orig_size != new_size) { - MTPD("size changed from %llu to %llu on mtpid: %u\n", orig_size, new_size, node->Mtpid()); - node->updateProperty(MTP_PROPERTY_OBJECT_SIZE, new_size, "", MTP_TYPE_UINT64); - mServer->sendObjectUpdated(node->Mtpid()); - } - } else { - MTPE("inotify_t modified item not found\n"); - } - } else if (event->mask & IN_DELETE_SELF || event->mask & IN_MOVE_SELF) { - // TODO: is this always already handled by IN_DELETE for the parent dir? - } -} - -int MtpStorage::inotify_t(void) { - #define EVENT_SIZE ( sizeof(struct inotify_event) ) - #define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16) ) - char buf[EVENT_BUF_LEN]; - fd_set fdset; - struct timeval seltmout; - int sel_ret; - - MTPD("inotify thread starting.\n"); - - while (inotify_thread_kill.get_value() == 0) { - FD_ZERO(&fdset); - FD_SET(inotify_fd, &fdset); - seltmout.tv_sec = 0; - seltmout.tv_usec = 25000; - sel_ret = select(inotify_fd + 1, &fdset, NULL, NULL, &seltmout); - if (sel_ret == 0) - continue; - int i = 0; - int len = read(inotify_fd, buf, EVENT_BUF_LEN); - - if (len < 0) { - if (errno == EINTR) - continue; - MTPE("inotify_t Can't read inotify events\n"); - } - - while (i < len && inotify_thread_kill.get_value() == 0) { - struct inotify_event *event = (struct inotify_event *) &buf[i]; - if (event->len) { - MTPD("inotify event: wd: %i, mask: %x, name: %s\n", event->wd, event->mask, event->name); - lockMutex(1); - handleInotifyEvent(event); - unlockMutex(1); - } - i += EVENT_SIZE + event->len; - } - } - MTPD("inotify_thread_kill received!\n"); - // This cleanup is handled in the destructor. - /*for (std::map::iterator i = inotifymap.begin(); i != inotifymap.end(); i++) { - inotify_rm_watch(inotify_fd, i->first); - } - close(inotify_fd);*/ - return 0; -} - -Node* MtpStorage::findNodeByPath(const std::string& path) { - MTPD("findNodeByPath: %s\n", path.c_str()); - std::string match = path.substr(0, mtpstorageparent.size()); - if (match != mtpstorageparent) { - // not on this device - MTPD("no match: %s is not on storage %s\n", match.c_str(), mtpstorageparent.c_str()); - return NULL; - } - - // TODO: fix and test this - std::string p = path.substr(mtpstorageparent.size()+1); // cut off "/" after storage root too - Tree* tree = mtpmap[0]; // start at storage root - - Node* node = NULL; - while (!p.empty()) { - size_t slashpos = p.find('/'); - std::string e; - if (slashpos != std::string::npos) { - e = p; - p.clear(); - } else { - e = p.substr(0, slashpos); - p = p.substr(slashpos + 1); - } - MTPD("path element: %s, rest: %s\n", e.c_str(), p.c_str()); - node = tree->findEntryByName(e); - if (!node) { - MTPE("path element of %s not found: %s\n", path.c_str(), e.c_str()); - return NULL; - } - if (node->isDir()) - tree = static_cast(node); - else if (!p.empty()) { - MTPE("path element of %s is not a directory: %s node: %p\n", path.c_str(), e.c_str(), node); - return NULL; - } - } - MTPD("findNodeByPath: found node %p, handle: %u, name: %s\n", node, node->Mtpid(), node->getName().c_str()); - return node; -} - -Node* MtpStorage::addNewNode(bool isDir, Tree* tree, const std::string& name) -{ - // global counter for new object handles - static MtpObjectHandle mtpid = 0; - - ++mtpid; - MTPD("adding new %s node for %s, new handle: %u\n", isDir ? "dir" : "file", name.c_str(), mtpid); - MtpObjectHandle parent = tree->Mtpid(); - MTPD("parent tree: %x, handle: %u, name: %s\n", tree, parent, tree->getName().c_str()); - Node* node; - if (isDir) - node = mtpmap[mtpid] = new Tree(mtpid, parent, name); - else - node = new Node(mtpid, parent, name); - tree->addEntry(node); - return node; -} - -Node* MtpStorage::findNode(MtpObjectHandle handle) { - for (iter i = mtpmap.begin(); i != mtpmap.end(); i++) { - Node* node = i->second->findNode(handle); - if (node != NULL) { - MTPD("findNode: found node %p for handle %u, name: %s\n", node, handle, node->getName().c_str()); - if (node->Mtpid() != handle) - { - MTPE("BUG: entry for handle %u points to node with handle %u\n", handle, node->Mtpid()); - } - return node; - } - } - // Item is not on this storage device - MTPD("MtpStorage::findNode: no node found for handle %u on storage %u, searched %u trees\n", handle, mStorageID, mtpmap.size()); - return NULL; -} - -std::string MtpStorage::getNodePath(Node* node) { - std::string path; - MTPD("getNodePath: node %p, handle %u\n", node, node->Mtpid()); - while (node) - { - path = "/" + node->getName() + path; - MtpObjectHandle parent = node->getMtpParentId(); - if (parent == 0) // root - break; - node = findNode(parent); - } - path = mtpstorageparent + path; - MTPD("getNodePath: path %s\n", path.c_str()); - return path; -} - -void MtpStorage::lockMutex(int thread_type) { - if (!use_mutex) - return; // mutex is disabled - if (thread_type) { - // inotify thread - pthread_mutex_lock(&inMutex); - while (pthread_mutex_trylock(&mtpMutex)) { - pthread_mutex_unlock(&inMutex); - usleep(32000); - pthread_mutex_lock(&inMutex); - } - } else { - // main mtp thread - pthread_mutex_lock(&mtpMutex); - while (pthread_mutex_trylock(&inMutex)) { - pthread_mutex_unlock(&mtpMutex); - usleep(13000); - pthread_mutex_lock(&mtpMutex); - } - } -} - -void MtpStorage::unlockMutex(int thread_type) { - if (!use_mutex) - return; // mutex is disabled - pthread_mutex_unlock(&inMutex); - pthread_mutex_unlock(&mtpMutex); -} diff --git a/mtp/legacy/MtpStorage.h b/mtp/legacy/MtpStorage.h deleted file mode 100644 index d967b4b9..00000000 --- a/mtp/legacy/MtpStorage.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_STORAGE_H -#define _MTP_STORAGE_H - -#include "mtp.h" -#include "MtpObjectInfo.h" -#include -#include -#include -#include -#include -#include "btree.hpp" -#include "MtpServer.h" -#include "../../tw_atomic.hpp" - -class MtpDatabase; -struct inotify_event; - -class MtpStorage { - -private: - MtpStorageID mStorageID; - MtpString mFilePath; - MtpString mDescription; - uint64_t mMaxCapacity; - uint64_t mMaxFileSize; - // amount of free space to leave unallocated - uint64_t mReserveSpace; - bool mRemovable; - MtpServer* mServer; - typedef std::map maptree; - typedef maptree::iterator iter; - maptree mtpmap; - std::string mtpstorageparent; - android::Mutex mMutex; - -public: - MtpStorage(MtpStorageID id, const char* filePath, - const char* description, uint64_t reserveSpace, - bool removable, uint64_t maxFileSize, MtpServer* refserver); - virtual ~MtpStorage(); - - inline MtpStorageID getStorageID() const { return mStorageID; } - int getType() const; - int getFileSystemType() const; - int getAccessCapability() const; - uint64_t getMaxCapacity(); - uint64_t getFreeSpace(); - const char* getDescription() const; - inline const char* getPath() const { return (const char *)mFilePath; } - inline bool isRemovable() const { return mRemovable; } - inline uint64_t getMaxFileSize() const { return mMaxFileSize; } - - struct PropEntry { - MtpObjectHandle handle; - uint16_t property; - uint16_t datatype; - uint64_t intvalue; - std::string strvalue; - }; - - int readDir(const std::string& path, Tree* tree); - int createDB(); - MtpObjectHandleList* getObjectList(MtpStorageID storageID, MtpObjectHandle parent); - int getObjectInfo(MtpObjectHandle handle, MtpObjectInfo& info); - MtpObjectHandle beginSendObject(const char* path, MtpObjectFormat format, MtpObjectHandle parent, uint64_t size, time_t modified); - void endSendObject(const char* path, MtpObjectHandle handle, MtpObjectFormat format, bool succeeded); - int getObjectPropertyList(MtpObjectHandle handle, uint32_t format, uint32_t property, int groupCode, int depth, MtpDataPacket& packet); - int getObjectFilePath(MtpObjectHandle handle, MtpString& outFilePath, int64_t& outFileLength, MtpObjectFormat& outFormat); - int deleteFile(MtpObjectHandle handle); - int renameObject(MtpObjectHandle handle, std::string newName); - int getObjectPropertyValue(MtpObjectHandle handle, MtpObjectProperty property, PropEntry& prop); - void lockMutex(int thread_type); - void unlockMutex(int thread_type); - -private: - pthread_t inotify(); - int inotify_t(); - typedef int (MtpStorage::*ThreadPtr)(void); - typedef void* (*PThreadPtr)(void *); - std::map inotifymap; // inotify wd -> tree - pthread_t inotify_thread; - int inotify_fd; - int addInotify(Tree* tree); - void handleInotifyEvent(struct inotify_event* event); - - bool sendEvents; - MtpObjectHandle handleCurrentlySending; - - Node* addNewNode(bool isDir, Tree* tree, const std::string& name); - Node* findNode(MtpObjectHandle handle); - Node* findNodeByPath(const std::string& path); - std::string getNodePath(Node* node); - - void queryNodeProperties(std::vector& results, Node* node, uint32_t property, int groupCode, MtpStorageID storageID); - - bool use_mutex; - pthread_mutex_t inMutex; // inotify mutex - pthread_mutex_t mtpMutex; // main mtp mutex - TWAtomicInt inotify_thread_kill; -}; - -#endif // _MTP_STORAGE_H diff --git a/mtp/legacy/MtpStorageInfo.cpp b/mtp/legacy/MtpStorageInfo.cpp deleted file mode 100644 index a2b8ca2a..00000000 --- a/mtp/legacy/MtpStorageInfo.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include "MtpDebug.h" -#include "MtpDataPacket.h" -#include "MtpStorageInfo.h" -#include "MtpStringBuffer.h" - -MtpStorageInfo::MtpStorageInfo(MtpStorageID id) - : mStorageID(id), - mStorageType(0), - mFileSystemType(0), - mAccessCapability(0), - mMaxCapacity(0), - mFreeSpaceBytes(0), - mFreeSpaceObjects(0), - mStorageDescription(NULL), - mVolumeIdentifier(NULL) -{ -} - -MtpStorageInfo::~MtpStorageInfo() { - if (mStorageDescription) - free(mStorageDescription); - if (mVolumeIdentifier) - free(mVolumeIdentifier); -} - -void MtpStorageInfo::read(MtpDataPacket& packet) { - MtpStringBuffer string; - - // read the device info - mStorageType = packet.getUInt16(); - mFileSystemType = packet.getUInt16(); - mAccessCapability = packet.getUInt16(); - mMaxCapacity = packet.getUInt64(); - mFreeSpaceBytes = packet.getUInt64(); - mFreeSpaceObjects = packet.getUInt32(); - - packet.getString(string); - mStorageDescription = strdup((const char *)string); - packet.getString(string); - mVolumeIdentifier = strdup((const char *)string); -} - -void MtpStorageInfo::print() { - MTPI("Storage Info %08X:\n\tmStorageType: %d\n\tmFileSystemType: %d\n\tmAccessCapability: %d\n", - mStorageID, mStorageType, mFileSystemType, mAccessCapability); - MTPI("\tmMaxCapacity: %lld\n\tmFreeSpaceBytes: %lld\n\tmFreeSpaceObjects: %d\n", - mMaxCapacity, mFreeSpaceBytes, mFreeSpaceObjects); - MTPI("\tmStorageDescription: %s\n\tmVolumeIdentifier: %s\n", - mStorageDescription, mVolumeIdentifier); -} - diff --git a/mtp/legacy/MtpStorageInfo.h b/mtp/legacy/MtpStorageInfo.h deleted file mode 100644 index 80f87529..00000000 --- a/mtp/legacy/MtpStorageInfo.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_STORAGE_INFO_H -#define _MTP_STORAGE_INFO_H - -#include "MtpTypes.h" - - -class MtpDataPacket; - -class MtpStorageInfo { -public: - MtpStorageID mStorageID; - uint16_t mStorageType; - uint16_t mFileSystemType; - uint16_t mAccessCapability; - uint64_t mMaxCapacity; - uint64_t mFreeSpaceBytes; - uint32_t mFreeSpaceObjects; - char* mStorageDescription; - char* mVolumeIdentifier; - -public: - MtpStorageInfo(MtpStorageID id); - virtual ~MtpStorageInfo(); - - void read(MtpDataPacket& packet); - - void print(); -}; - - -#endif // _MTP_STORAGE_INFO_H diff --git a/mtp/legacy/MtpStringBuffer.cpp b/mtp/legacy/MtpStringBuffer.cpp deleted file mode 100644 index 8aeb3ca9..00000000 --- a/mtp/legacy/MtpStringBuffer.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include -#include "MtpDataPacket.h" -#include "MtpStringBuffer.h" - -MtpStringBuffer::MtpStringBuffer() - : mCharCount(0), - mByteCount(1) -{ - mBuffer[0] = 0; -} - -MtpStringBuffer::MtpStringBuffer(const char* src) - : mCharCount(0), - mByteCount(1) -{ - set(src); -} - -MtpStringBuffer::MtpStringBuffer(const uint16_t* src) - : mCharCount(0), - mByteCount(1) -{ - set(src); -} - -MtpStringBuffer::MtpStringBuffer(const MtpStringBuffer& src) - : mCharCount(src.mCharCount), - mByteCount(src.mByteCount) -{ - memcpy(mBuffer, src.mBuffer, mByteCount); -} - - -MtpStringBuffer::~MtpStringBuffer() { -} - -void MtpStringBuffer::set(const char* src) { - size_t length = strlen(src); - if (length >= sizeof(mBuffer)) - length = sizeof(mBuffer) - 1; - memcpy(mBuffer, src, length); - - // count the characters - int count = 0; - char ch; - while ((ch = *src++) != 0) { - if ((ch & 0x80) == 0) { - // single byte character - } else if ((ch & 0xE0) == 0xC0) { - // two byte character - if (! *src++) { - // last character was truncated, so ignore last byte - length--; - break; - } - } else if ((ch & 0xF0) == 0xE0) { - // 3 byte char - if (! *src++) { - // last character was truncated, so ignore last byte - length--; - break; - } - if (! *src++) { - // last character was truncated, so ignore last two bytes - length -= 2; - break; - } - } - count++; - } - - mByteCount = length + 1; - mBuffer[length] = 0; - mCharCount = count; -} - -void MtpStringBuffer::set(const uint16_t* src) { - int count = 0; - uint16_t ch; - uint8_t* dest = mBuffer; - - while ((ch = *src++) != 0 && count < 255) { - if (ch >= 0x0800) { - *dest++ = (uint8_t)(0xE0 | (ch >> 12)); - *dest++ = (uint8_t)(0x80 | ((ch >> 6) & 0x3F)); - *dest++ = (uint8_t)(0x80 | (ch & 0x3F)); - } else if (ch >= 0x80) { - *dest++ = (uint8_t)(0xC0 | (ch >> 6)); - *dest++ = (uint8_t)(0x80 | (ch & 0x3F)); - } else { - *dest++ = ch; - } - count++; - } - *dest++ = 0; - mCharCount = count; - mByteCount = dest - mBuffer; -} - -void MtpStringBuffer::readFromPacket(MtpDataPacket* packet) { - int count = packet->getUInt8(); - uint8_t* dest = mBuffer; - for (int i = 0; i < count; i++) { - uint16_t ch = packet->getUInt16(); - if (ch >= 0x0800) { - *dest++ = (uint8_t)(0xE0 | (ch >> 12)); - *dest++ = (uint8_t)(0x80 | ((ch >> 6) & 0x3F)); - *dest++ = (uint8_t)(0x80 | (ch & 0x3F)); - } else if (ch >= 0x80) { - *dest++ = (uint8_t)(0xC0 | (ch >> 6)); - *dest++ = (uint8_t)(0x80 | (ch & 0x3F)); - } else { - *dest++ = ch; - } - } - *dest++ = 0; - mCharCount = count; - mByteCount = dest - mBuffer; -} - -void MtpStringBuffer::writeToPacket(MtpDataPacket* packet) const { - int count = mCharCount; - const uint8_t* src = mBuffer; - packet->putUInt8(count > 0 ? count + 1 : 0); - - // expand utf8 to 16 bit chars - for (int i = 0; i < count; i++) { - uint16_t ch; - uint16_t ch1 = *src++; - if ((ch1 & 0x80) == 0) { - // single byte character - ch = ch1; - } else if ((ch1 & 0xE0) == 0xC0) { - // two byte character - uint16_t ch2 = *src++; - ch = ((ch1 & 0x1F) << 6) | (ch2 & 0x3F); - } else { - // three byte character - uint16_t ch2 = *src++; - uint16_t ch3 = *src++; - ch = ((ch1 & 0x0F) << 12) | ((ch2 & 0x3F) << 6) | (ch3 & 0x3F); - } - packet->putUInt16(ch); - } - // only terminate with zero if string is not empty - if (count > 0) - packet->putUInt16(0); -} - diff --git a/mtp/legacy/MtpStringBuffer.h b/mtp/legacy/MtpStringBuffer.h deleted file mode 100644 index 68c0a0c2..00000000 --- a/mtp/legacy/MtpStringBuffer.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_STRING_BUFFER_H -#define _MTP_STRING_BUFFER_H - -#include - -class MtpDataPacket; - -// Represents a utf8 string, with a maximum of 255 characters -class MtpStringBuffer { - -private: - // mBuffer contains string in UTF8 format - // maximum 3 bytes/character, with 1 extra for zero termination - uint8_t mBuffer[255 * 3 + 1]; - int mCharCount; - int mByteCount; - -public: - MtpStringBuffer(); - MtpStringBuffer(const char* src); - MtpStringBuffer(const uint16_t* src); - MtpStringBuffer(const MtpStringBuffer& src); - virtual ~MtpStringBuffer(); - - void set(const char* src); - void set(const uint16_t* src); - - void readFromPacket(MtpDataPacket* packet); - void writeToPacket(MtpDataPacket* packet) const; - - inline int getCharCount() const { return mCharCount; } - inline int getByteCount() const { return mByteCount; } - - inline operator const char*() const { return (const char *)mBuffer; } -}; - -#endif // _MTP_STRING_BUFFER_H diff --git a/mtp/legacy/MtpTypes.h b/mtp/legacy/MtpTypes.h deleted file mode 100644 index 64e180cb..00000000 --- a/mtp/legacy/MtpTypes.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_TYPES_H -#define _MTP_TYPES_H - -#include -#include -#include -#include - -typedef int32_t int128_t[4]; -typedef uint32_t uint128_t[4]; - -typedef uint16_t MtpOperationCode; -typedef uint16_t MtpResponseCode; -typedef uint16_t MtpEventCode; -typedef uint32_t MtpSessionID; -typedef uint32_t MtpStorageID; -typedef uint32_t MtpTransactionID; -typedef uint16_t MtpPropertyCode; -typedef uint16_t MtpDataType; -typedef uint16_t MtpObjectFormat; -typedef MtpPropertyCode MtpDeviceProperty; -typedef MtpPropertyCode MtpObjectProperty; - -// object handles are unique across all storage but only within a single session. -// object handles cannot be reused after an object is deleted. -// values 0x00000000 and 0xFFFFFFFF are reserved for special purposes. -typedef uint32_t MtpObjectHandle; - -// Special values -#define MTP_PARENT_ROOT 0xFFFFFFFF // parent is root of the storage -#define kInvalidObjectHandle 0xFFFFFFFF - -class MtpStorage; -class MtpDevice; -class MtpProperty; - -typedef android::Vector MtpStorageList; -typedef android::Vector MtpDeviceList; -typedef android::Vector MtpPropertyList; - -typedef android::Vector UInt8List; -typedef android::Vector UInt16List; -typedef android::Vector UInt32List; -typedef android::Vector UInt64List; -typedef android::Vector Int8List; -typedef android::Vector Int16List; -typedef android::Vector Int32List; -typedef android::Vector Int64List; - -typedef UInt16List MtpObjectPropertyList; -typedef UInt16List MtpDevicePropertyList; -typedef UInt16List MtpObjectFormatList; -typedef UInt32List MtpObjectHandleList; -typedef UInt16List MtpObjectPropertyList; -typedef UInt32List MtpStorageIDList; - -typedef android::String8 MtpString; - - -#endif // _MTP_TYPES_H diff --git a/mtp/legacy/MtpUtils.cpp b/mtp/legacy/MtpUtils.cpp deleted file mode 100644 index 4ad59fd4..00000000 --- a/mtp/legacy/MtpUtils.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include -#include -// Not available in 5.0 -//#include -#include "MtpUtils.h" -#include "MtpDebug.h" - - -/* -DateTime strings follow a compatible subset of the definition found in ISO 8601, and -take the form of a Unicode string formatted as: "YYYYMMDDThhmmss.s". In this -representation, YYYY shall be replaced by the year, MM replaced by the month (01-12), -DD replaced by the day (01-31), T is a constant character 'T' delimiting time from date, -hh is replaced by the hour (00-23), mm is replaced by the minute (00-59), and ss by the -second (00-59). The ".s" is optional, and represents tenths of a second. -*/ - -bool parseDateTime(const char* dateTime, time_t& outSeconds) { - int year, month, day, hour, minute, second; - struct tm tm; - - if (sscanf(dateTime, "%04d%02d%02dT%02d%02d%02d", - &year, &month, &day, &hour, &minute, &second) != 6) - return false; - const char* tail = dateTime + 15; - // skip optional tenth of second - if (tail[0] == '.' && tail[1]) - tail += 2; - //FIXME - support +/-hhmm - bool useUTC = (tail[0] == 'Z'); - - // hack to compute timezone - time_t dummy; - localtime_r(&dummy, &tm); - - tm.tm_sec = second; - tm.tm_min = minute; - tm.tm_hour = hour; - tm.tm_mday = day; - tm.tm_mon = month - 1; // mktime uses months in 0 - 11 range - tm.tm_year = year - 1900; - tm.tm_wday = 0; - tm.tm_isdst = -1; - //if (useUTC) { - outSeconds = mktime(&tm); - //} - /* mktime_tz is blocking :P - else { - outSeconds = mktime_tz(&tm, tm.tm_zone); - } - */ - - return true; -} - -void formatDateTime(time_t seconds, char* buffer, int bufferLength) { - struct tm tm; - - localtime_r(&seconds, &tm); - snprintf(buffer, bufferLength, "%04d%02d%02dT%02d%02d%02d", - tm.tm_year + 1900, - tm.tm_mon + 1, // localtime_r uses months in 0 - 11 range - tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); -} - diff --git a/mtp/legacy/MtpUtils.h b/mtp/legacy/MtpUtils.h deleted file mode 100644 index 2bca94b2..00000000 --- a/mtp/legacy/MtpUtils.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_UTILS_H -#define _MTP_UTILS_H - -#include - -bool parseDateTime(const char* dateTime, time_t& outSeconds); -void formatDateTime(time_t seconds, char* buffer, int bufferLength); - -#endif // _MTP_UTILS_H diff --git a/mtp/legacy/btree.cpp b/mtp/legacy/btree.cpp deleted file mode 100644 index b73789bd..00000000 --- a/mtp/legacy/btree.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "btree.hpp" -#include "MtpDebug.h" - -// Constructor -Tree::Tree(MtpObjectHandle handle, MtpObjectHandle parent, const std::string& name) - : Node(handle, parent, name), alreadyRead(false) { -} - -// Destructor -Tree::~Tree() { - for (std::map::iterator it = entries.begin(); it != entries.end(); ++it) - delete it->second; - entries.clear(); -} - -int Tree::getCount(void) { - int count = entries.size(); - MTPD("node count: %d\n", count); - return count; -} - -void Tree::addEntry(Node* node) { - if (node->Mtpid() == 0) { - MTPE("Tree::addEntry: not adding node with 0 handle.\n"); - return; - } - if (node->Mtpid() == node->getMtpParentId()) { - MTPE("Tree::addEntry: not adding node with handle %u == parent.\n", node->Mtpid()); - return; - } - entries[node->Mtpid()] = node; -} - -Node* Tree::findEntryByName(std::string name) { - for (std::map::iterator it = entries.begin(); it != entries.end(); ++it) - { - Node* node = it->second; - if (node->getName().compare(name) == 0 && node->Mtpid() > 0) - return node; - } - return NULL; -} - -Node* Tree::findNode(MtpObjectHandle handle) { - std::map::iterator it = entries.find(handle); - if (it != entries.end()) - return it->second; - return NULL; -} - -void Tree::getmtpids(MtpObjectHandleList* mtpids) { - for (std::map::iterator it = entries.begin(); it != entries.end(); ++it) - mtpids->push_back(it->second->Mtpid()); -} - -void Tree::deleteNode(MtpObjectHandle handle) { - std::map::iterator it = entries.find(handle); - if (it != entries.end()) { - delete it->second; - entries.erase(it); - } -} diff --git a/mtp/legacy/btree.hpp b/mtp/legacy/btree.hpp deleted file mode 100644 index e1aad363..00000000 --- a/mtp/legacy/btree.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BTREE_HPP -#define BTREE_HPP - -#include -#include -#include -#include "MtpTypes.h" - -// A directory entry -class Node { - MtpObjectHandle handle; - MtpObjectHandle parent; - std::string name; // name only without path - -public: - Node(); - Node(MtpObjectHandle handle, MtpObjectHandle parent, const std::string& name); - virtual ~Node() {} - - virtual bool isDir() const { return false; } - - void rename(const std::string& newName); - MtpObjectHandle Mtpid() const; - MtpObjectHandle getMtpParentId() const; - const std::string& getName() const; - - void addProperty(MtpPropertyCode property, uint64_t valueInt, std::string valueStr, MtpDataType dataType); - void updateProperty(MtpPropertyCode property, uint64_t valueInt, std::string valueStr, MtpDataType dataType); - void addProperties(const std::string& path, int storageID); - uint64_t getIntProperty(MtpPropertyCode property); - struct mtpProperty { - MtpPropertyCode property; - MtpDataType dataType; - uint64_t valueInt; - std::string valueStr; - mtpProperty() : property(0), dataType(0), valueInt(0) {} - }; - std::vector& getMtpProps(); - std::vector mtpProp; - const mtpProperty& getProperty(MtpPropertyCode property); -}; - -// A directory -class Tree : public Node { - std::map entries; - bool alreadyRead; -public: - Tree(MtpObjectHandle handle, MtpObjectHandle parent, const std::string& name); - ~Tree(); - - virtual bool isDir() const { return true; } - - void addEntry(Node* node); - Node* findNode(MtpObjectHandle handle); - void getmtpids(MtpObjectHandleList* mtpids); - void deleteNode(MtpObjectHandle handle); - std::string getPath(Node* node); - int getMtpParentId() { return Node::getMtpParentId(); } - int getMtpParentId(Node* node); - Node* findEntryByName(std::string name); - int getCount(); - bool wasAlreadyRead() const { return alreadyRead; } - void setAlreadyRead(bool b) { alreadyRead = b; } -}; - -#endif diff --git a/mtp/legacy/mtp.h b/mtp/legacy/mtp.h deleted file mode 100644 index c3293319..00000000 --- a/mtp/legacy/mtp.h +++ /dev/null @@ -1,607 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef _MTP_H -#define _MTP_H - -#include -#include - -#define MTP_STANDARD_VERSION 100 - -// Container Types -#define MTP_CONTAINER_TYPE_UNDEFINED 0 -#define MTP_CONTAINER_TYPE_COMMAND 1 -#define MTP_CONTAINER_TYPE_DATA 2 -#define MTP_CONTAINER_TYPE_RESPONSE 3 -#define MTP_CONTAINER_TYPE_EVENT 4 - -// Container Offsets -#define MTP_CONTAINER_LENGTH_OFFSET 0 -#define MTP_CONTAINER_TYPE_OFFSET 4 -#define MTP_CONTAINER_CODE_OFFSET 6 -#define MTP_CONTAINER_TRANSACTION_ID_OFFSET 8 -#define MTP_CONTAINER_PARAMETER_OFFSET 12 -#define MTP_CONTAINER_HEADER_SIZE 12 - -// MTP Data Types -#define MTP_TYPE_UNDEFINED 0x0000 // Undefined -#define MTP_TYPE_INT8 0x0001 // Signed 8-bit integer -#define MTP_TYPE_UINT8 0x0002 // Unsigned 8-bit integer -#define MTP_TYPE_INT16 0x0003 // Signed 16-bit integer -#define MTP_TYPE_UINT16 0x0004 // Unsigned 16-bit integer -#define MTP_TYPE_INT32 0x0005 // Signed 32-bit integer -#define MTP_TYPE_UINT32 0x0006 // Unsigned 32-bit integer -#define MTP_TYPE_INT64 0x0007 // Signed 64-bit integer -#define MTP_TYPE_UINT64 0x0008 // Unsigned 64-bit integer -#define MTP_TYPE_INT128 0x0009 // Signed 128-bit integer -#define MTP_TYPE_UINT128 0x000A // Unsigned 128-bit integer -#define MTP_TYPE_AINT8 0x4001 // Array of signed 8-bit integers -#define MTP_TYPE_AUINT8 0x4002 // Array of unsigned 8-bit integers -#define MTP_TYPE_AINT16 0x4003 // Array of signed 16-bit integers -#define MTP_TYPE_AUINT16 0x4004 // Array of unsigned 16-bit integers -#define MTP_TYPE_AINT32 0x4005 // Array of signed 32-bit integers -#define MTP_TYPE_AUINT32 0x4006 // Array of unsigned 32-bit integers -#define MTP_TYPE_AINT64 0x4007 // Array of signed 64-bit integers -#define MTP_TYPE_AUINT64 0x4008 // Array of unsigned 64-bit integers -#define MTP_TYPE_AINT128 0x4009 // Array of signed 128-bit integers -#define MTP_TYPE_AUINT128 0x400A // Array of unsigned 128-bit integers -#define MTP_TYPE_STR 0xFFFF // Variable-length Unicode string - -// MTP Format Codes -#define MTP_FORMAT_UNDEFINED 0x3000 // Undefined object -#define MTP_FORMAT_ASSOCIATION 0x3001 // Association (for example, a folder) -#define MTP_FORMAT_SCRIPT 0x3002 // Device model-specific script -#define MTP_FORMAT_EXECUTABLE 0x3003 // Device model-specific binary executable -#define MTP_FORMAT_TEXT 0x3004 // Text file -#define MTP_FORMAT_HTML 0x3005 // Hypertext Markup Language file (text) -#define MTP_FORMAT_DPOF 0x3006 // Digital Print Order Format file (text) -#define MTP_FORMAT_AIFF 0x3007 // Audio clip -#define MTP_FORMAT_WAV 0x3008 // Audio clip -#define MTP_FORMAT_MP3 0x3009 // Audio clip -#define MTP_FORMAT_AVI 0x300A // Video clip -#define MTP_FORMAT_MPEG 0x300B // Video clip -#define MTP_FORMAT_ASF 0x300C // Microsoft Advanced Streaming Format (video) -#define MTP_FORMAT_DEFINED 0x3800 // Unknown image object -#define MTP_FORMAT_EXIF_JPEG 0x3801 // Exchangeable File Format, JEIDA standard -#define MTP_FORMAT_TIFF_EP 0x3802 // Tag Image File Format for Electronic Photography -#define MTP_FORMAT_FLASHPIX 0x3803 // Structured Storage Image Format -#define MTP_FORMAT_BMP 0x3804 // Microsoft Windows Bitmap file -#define MTP_FORMAT_CIFF 0x3805 // Canon Camera Image File Format -#define MTP_FORMAT_GIF 0x3807 // Graphics Interchange Format -#define MTP_FORMAT_JFIF 0x3808 // JPEG File Interchange Format -#define MTP_FORMAT_CD 0x3809 // PhotoCD Image Pac -#define MTP_FORMAT_PICT 0x380A // Quickdraw Image Format -#define MTP_FORMAT_PNG 0x380B // Portable Network Graphics -#define MTP_FORMAT_TIFF 0x380D // Tag Image File Format -#define MTP_FORMAT_TIFF_IT 0x380E // Tag Image File Format for Information Technology (graphic arts) -#define MTP_FORMAT_JP2 0x380F // JPEG2000 Baseline File Format -#define MTP_FORMAT_JPX 0x3810 // JPEG2000 Extended File Format -#define MTP_FORMAT_UNDEFINED_FIRMWARE 0xB802 -#define MTP_FORMAT_WINDOWS_IMAGE_FORMAT 0xB881 -#define MTP_FORMAT_UNDEFINED_AUDIO 0xB900 -#define MTP_FORMAT_WMA 0xB901 -#define MTP_FORMAT_OGG 0xB902 -#define MTP_FORMAT_AAC 0xB903 -#define MTP_FORMAT_AUDIBLE 0xB904 -#define MTP_FORMAT_FLAC 0xB906 -#define MTP_FORMAT_UNDEFINED_VIDEO 0xB980 -#define MTP_FORMAT_WMV 0xB981 -#define MTP_FORMAT_MP4_CONTAINER 0xB982 // ISO 14496-1 -#define MTP_FORMAT_MP2 0xB983 -#define MTP_FORMAT_3GP_CONTAINER 0xB984 // 3GPP file format. Details: http://www.3gpp.org/ftp/Specs/html-info/26244.htm (page title - \u201cTransparent end-to-end packet switched streaming service, 3GPP file format\u201d). -#define MTP_FORMAT_UNDEFINED_COLLECTION 0xBA00 -#define MTP_FORMAT_ABSTRACT_MULTIMEDIA_ALBUM 0xBA01 -#define MTP_FORMAT_ABSTRACT_IMAGE_ALBUM 0xBA02 -#define MTP_FORMAT_ABSTRACT_AUDIO_ALBUM 0xBA03 -#define MTP_FORMAT_ABSTRACT_VIDEO_ALBUM 0xBA04 -#define MTP_FORMAT_ABSTRACT_AV_PLAYLIST 0xBA05 -#define MTP_FORMAT_ABSTRACT_CONTACT_GROUP 0xBA06 -#define MTP_FORMAT_ABSTRACT_MESSAGE_FOLDER 0xBA07 -#define MTP_FORMAT_ABSTRACT_CHAPTERED_PRODUCTION 0xBA08 -#define MTP_FORMAT_ABSTRACT_AUDIO_PLAYLIST 0xBA09 -#define MTP_FORMAT_ABSTRACT_VIDEO_PLAYLIST 0xBA0A -#define MTP_FORMAT_ABSTRACT_MEDIACAST 0xBA0B // For use with mediacasts; references multimedia enclosures of RSS feeds or episodic content -#define MTP_FORMAT_WPL_PLAYLIST 0xBA10 -#define MTP_FORMAT_M3U_PLAYLIST 0xBA11 -#define MTP_FORMAT_MPL_PLAYLIST 0xBA12 -#define MTP_FORMAT_ASX_PLAYLIST 0xBA13 -#define MTP_FORMAT_PLS_PLAYLIST 0xBA14 -#define MTP_FORMAT_UNDEFINED_DOCUMENT 0xBA80 -#define MTP_FORMAT_ABSTRACT_DOCUMENT 0xBA81 -#define MTP_FORMAT_XML_DOCUMENT 0xBA82 -#define MTP_FORMAT_MS_WORD_DOCUMENT 0xBA83 -#define MTP_FORMAT_MHT_COMPILED_HTML_DOCUMENT 0xBA84 -#define MTP_FORMAT_MS_EXCEL_SPREADSHEET 0xBA85 -#define MTP_FORMAT_MS_POWERPOINT_PRESENTATION 0xBA86 -#define MTP_FORMAT_UNDEFINED_MESSAGE 0xBB00 -#define MTP_FORMAT_ABSTRACT_MESSSAGE 0xBB01 -#define MTP_FORMAT_UNDEFINED_CONTACT 0xBB80 -#define MTP_FORMAT_ABSTRACT_CONTACT 0xBB81 -#define MTP_FORMAT_VCARD_2 0xBB82 - -// MTP Object Property Codes -#define MTP_PROPERTY_STORAGE_ID 0xDC01 -#define MTP_PROPERTY_OBJECT_FORMAT 0xDC02 -#define MTP_PROPERTY_PROTECTION_STATUS 0xDC03 -#define MTP_PROPERTY_OBJECT_SIZE 0xDC04 -#define MTP_PROPERTY_ASSOCIATION_TYPE 0xDC05 -#define MTP_PROPERTY_ASSOCIATION_DESC 0xDC06 -#define MTP_PROPERTY_OBJECT_FILE_NAME 0xDC07 -#define MTP_PROPERTY_DATE_CREATED 0xDC08 -#define MTP_PROPERTY_DATE_MODIFIED 0xDC09 -#define MTP_PROPERTY_KEYWORDS 0xDC0A -#define MTP_PROPERTY_PARENT_OBJECT 0xDC0B -#define MTP_PROPERTY_ALLOWED_FOLDER_CONTENTS 0xDC0C -#define MTP_PROPERTY_HIDDEN 0xDC0D -#define MTP_PROPERTY_SYSTEM_OBJECT 0xDC0E -#define MTP_PROPERTY_PERSISTENT_UID 0xDC41 -#define MTP_PROPERTY_SYNC_ID 0xDC42 -#define MTP_PROPERTY_PROPERTY_BAG 0xDC43 -#define MTP_PROPERTY_NAME 0xDC44 -#define MTP_PROPERTY_CREATED_BY 0xDC45 -#define MTP_PROPERTY_ARTIST 0xDC46 -#define MTP_PROPERTY_DATE_AUTHORED 0xDC47 -#define MTP_PROPERTY_DESCRIPTION 0xDC48 -#define MTP_PROPERTY_URL_REFERENCE 0xDC49 -#define MTP_PROPERTY_LANGUAGE_LOCALE 0xDC4A -#define MTP_PROPERTY_COPYRIGHT_INFORMATION 0xDC4B -#define MTP_PROPERTY_SOURCE 0xDC4C -#define MTP_PROPERTY_ORIGIN_LOCATION 0xDC4D -#define MTP_PROPERTY_DATE_ADDED 0xDC4E -#define MTP_PROPERTY_NON_CONSUMABLE 0xDC4F -#define MTP_PROPERTY_CORRUPT_UNPLAYABLE 0xDC50 -#define MTP_PROPERTY_PRODUCER_SERIAL_NUMBER 0xDC51 -#define MTP_PROPERTY_REPRESENTATIVE_SAMPLE_FORMAT 0xDC81 -#define MTP_PROPERTY_REPRESENTATIVE_SAMPLE_SIZE 0xDC82 -#define MTP_PROPERTY_REPRESENTATIVE_SAMPLE_HEIGHT 0xDC83 -#define MTP_PROPERTY_REPRESENTATIVE_SAMPLE_WIDTH 0xDC84 -#define MTP_PROPERTY_REPRESENTATIVE_SAMPLE_DURATION 0xDC85 -#define MTP_PROPERTY_REPRESENTATIVE_SAMPLE_DATA 0xDC86 -#define MTP_PROPERTY_WIDTH 0xDC87 -#define MTP_PROPERTY_HEIGHT 0xDC88 -#define MTP_PROPERTY_DURATION 0xDC89 -#define MTP_PROPERTY_RATING 0xDC8A -#define MTP_PROPERTY_TRACK 0xDC8B -#define MTP_PROPERTY_GENRE 0xDC8C -#define MTP_PROPERTY_CREDITS 0xDC8D -#define MTP_PROPERTY_LYRICS 0xDC8E -#define MTP_PROPERTY_SUBSCRIPTION_CONTENT_ID 0xDC8F -#define MTP_PROPERTY_PRODUCED_BY 0xDC90 -#define MTP_PROPERTY_USE_COUNT 0xDC91 -#define MTP_PROPERTY_SKIP_COUNT 0xDC92 -#define MTP_PROPERTY_LAST_ACCESSED 0xDC93 -#define MTP_PROPERTY_PARENTAL_RATING 0xDC94 -#define MTP_PROPERTY_META_GENRE 0xDC95 -#define MTP_PROPERTY_COMPOSER 0xDC96 -#define MTP_PROPERTY_EFFECTIVE_RATING 0xDC97 -#define MTP_PROPERTY_SUBTITLE 0xDC98 -#define MTP_PROPERTY_ORIGINAL_RELEASE_DATE 0xDC99 -#define MTP_PROPERTY_ALBUM_NAME 0xDC9A -#define MTP_PROPERTY_ALBUM_ARTIST 0xDC9B -#define MTP_PROPERTY_MOOD 0xDC9C -#define MTP_PROPERTY_DRM_STATUS 0xDC9D -#define MTP_PROPERTY_SUB_DESCRIPTION 0xDC9E -#define MTP_PROPERTY_IS_CROPPED 0xDCD1 -#define MTP_PROPERTY_IS_COLOUR_CORRECTED 0xDCD2 -#define MTP_PROPERTY_IMAGE_BIT_DEPTH 0xDCD3 -#define MTP_PROPERTY_F_NUMBER 0xDCD4 -#define MTP_PROPERTY_EXPOSURE_TIME 0xDCD5 -#define MTP_PROPERTY_EXPOSURE_INDEX 0xDCD6 -#define MTP_PROPERTY_TOTAL_BITRATE 0xDE91 -#define MTP_PROPERTY_BITRATE_TYPE 0xDE92 -#define MTP_PROPERTY_SAMPLE_RATE 0xDE93 -#define MTP_PROPERTY_NUMBER_OF_CHANNELS 0xDE94 -#define MTP_PROPERTY_AUDIO_BIT_DEPTH 0xDE95 -#define MTP_PROPERTY_SCAN_TYPE 0xDE97 -#define MTP_PROPERTY_AUDIO_WAVE_CODEC 0xDE99 -#define MTP_PROPERTY_AUDIO_BITRATE 0xDE9A -#define MTP_PROPERTY_VIDEO_FOURCC_CODEC 0xDE9B -#define MTP_PROPERTY_VIDEO_BITRATE 0xDE9C -#define MTP_PROPERTY_FRAMES_PER_THOUSAND_SECONDS 0xDE9D -#define MTP_PROPERTY_KEYFRAME_DISTANCE 0xDE9E -#define MTP_PROPERTY_BUFFER_SIZE 0xDE9F -#define MTP_PROPERTY_ENCODING_QUALITY 0xDEA0 -#define MTP_PROPERTY_ENCODING_PROFILE 0xDEA1 -#define MTP_PROPERTY_DISPLAY_NAME 0xDCE0 -#define MTP_PROPERTY_BODY_TEXT 0xDCE1 -#define MTP_PROPERTY_SUBJECT 0xDCE2 -#define MTP_PROPERTY_PRIORITY 0xDCE3 -#define MTP_PROPERTY_GIVEN_NAME 0xDD00 -#define MTP_PROPERTY_MIDDLE_NAMES 0xDD01 -#define MTP_PROPERTY_FAMILY_NAME 0xDD02 -#define MTP_PROPERTY_PREFIX 0xDD03 -#define MTP_PROPERTY_SUFFIX 0xDD04 -#define MTP_PROPERTY_PHONETIC_GIVEN_NAME 0xDD05 -#define MTP_PROPERTY_PHONETIC_FAMILY_NAME 0xDD06 -#define MTP_PROPERTY_EMAIL_PRIMARY 0xDD07 -#define MTP_PROPERTY_EMAIL_PERSONAL_1 0xDD08 -#define MTP_PROPERTY_EMAIL_PERSONAL_2 0xDD09 -#define MTP_PROPERTY_EMAIL_BUSINESS_1 0xDD0A -#define MTP_PROPERTY_EMAIL_BUSINESS_2 0xDD0B -#define MTP_PROPERTY_EMAIL_OTHERS 0xDD0C -#define MTP_PROPERTY_PHONE_NUMBER_PRIMARY 0xDD0D -#define MTP_PROPERTY_PHONE_NUMBER_PERSONAL 0xDD0E -#define MTP_PROPERTY_PHONE_NUMBER_PERSONAL_2 0xDD0F -#define MTP_PROPERTY_PHONE_NUMBER_BUSINESS 0xDD10 -#define MTP_PROPERTY_PHONE_NUMBER_BUSINESS_2 0xDD11 -#define MTP_PROPERTY_PHONE_NUMBER_MOBILE 0xDD12 -#define MTP_PROPERTY_PHONE_NUMBER_MOBILE_2 0xDD13 -#define MTP_PROPERTY_FAX_NUMBER_PRIMARY 0xDD14 -#define MTP_PROPERTY_FAX_NUMBER_PERSONAL 0xDD15 -#define MTP_PROPERTY_FAX_NUMBER_BUSINESS 0xDD16 -#define MTP_PROPERTY_PAGER_NUMBER 0xDD17 -#define MTP_PROPERTY_PHONE_NUMBER_OTHERS 0xDD18 -#define MTP_PROPERTY_PRIMARY_WEB_ADDRESS 0xDD19 -#define MTP_PROPERTY_PERSONAL_WEB_ADDRESS 0xDD1A -#define MTP_PROPERTY_BUSINESS_WEB_ADDRESS 0xDD1B -#define MTP_PROPERTY_INSTANT_MESSANGER_ADDRESS 0xDD1C -#define MTP_PROPERTY_INSTANT_MESSANGER_ADDRESS_2 0xDD1D -#define MTP_PROPERTY_INSTANT_MESSANGER_ADDRESS_3 0xDD1E -#define MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_FULL 0xDD1F -#define MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_LINE_1 0xDD20 -#define MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_LINE_2 0xDD21 -#define MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_CITY 0xDD22 -#define MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_REGION 0xDD23 -#define MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_POSTAL_CODE 0xDD24 -#define MTP_PROPERTY_POSTAL_ADDRESS_PERSONAL_COUNTRY 0xDD25 -#define MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_FULL 0xDD26 -#define MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_LINE_1 0xDD27 -#define MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_LINE_2 0xDD28 -#define MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_CITY 0xDD29 -#define MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_REGION 0xDD2A -#define MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_POSTAL_CODE 0xDD2B -#define MTP_PROPERTY_POSTAL_ADDRESS_BUSINESS_COUNTRY 0xDD2C -#define MTP_PROPERTY_POSTAL_ADDRESS_OTHER_FULL 0xDD2D -#define MTP_PROPERTY_POSTAL_ADDRESS_OTHER_LINE_1 0xDD2E -#define MTP_PROPERTY_POSTAL_ADDRESS_OTHER_LINE_2 0xDD2F -#define MTP_PROPERTY_POSTAL_ADDRESS_OTHER_CITY 0xDD30 -#define MTP_PROPERTY_POSTAL_ADDRESS_OTHER_REGION 0xDD31 -#define MTP_PROPERTY_POSTAL_ADDRESS_OTHER_POSTAL_CODE 0xDD32 -#define MTP_PROPERTY_POSTAL_ADDRESS_OTHER_COUNTRY 0xDD33 -#define MTP_PROPERTY_ORGANIZATION_NAME 0xDD34 -#define MTP_PROPERTY_PHONETIC_ORGANIZATION_NAME 0xDD35 -#define MTP_PROPERTY_ROLE 0xDD36 -#define MTP_PROPERTY_BIRTHDATE 0xDD37 -#define MTP_PROPERTY_MESSAGE_TO 0xDD40 -#define MTP_PROPERTY_MESSAGE_CC 0xDD41 -#define MTP_PROPERTY_MESSAGE_BCC 0xDD42 -#define MTP_PROPERTY_MESSAGE_READ 0xDD43 -#define MTP_PROPERTY_MESSAGE_RECEIVED_TIME 0xDD44 -#define MTP_PROPERTY_MESSAGE_SENDER 0xDD45 -#define MTP_PROPERTY_ACTIVITY_BEGIN_TIME 0xDD50 -#define MTP_PROPERTY_ACTIVITY_END_TIME 0xDD51 -#define MTP_PROPERTY_ACTIVITY_LOCATION 0xDD52 -#define MTP_PROPERTY_ACTIVITY_REQUIRED_ATTENDEES 0xDD54 -#define MTP_PROPERTY_ACTIVITY_OPTIONAL_ATTENDEES 0xDD55 -#define MTP_PROPERTY_ACTIVITY_RESOURCES 0xDD56 -#define MTP_PROPERTY_ACTIVITY_ACCEPTED 0xDD57 -#define MTP_PROPERTY_ACTIVITY_TENTATIVE 0xDD58 -#define MTP_PROPERTY_ACTIVITY_DECLINED 0xDD59 -#define MTP_PROPERTY_ACTIVITY_REMAINDER_TIME 0xDD5A -#define MTP_PROPERTY_ACTIVITY_OWNER 0xDD5B -#define MTP_PROPERTY_ACTIVITY_STATUS 0xDD5C -#define MTP_PROPERTY_OWNER 0xDD5D -#define MTP_PROPERTY_EDITOR 0xDD5E -#define MTP_PROPERTY_WEBMASTER 0xDD5F -#define MTP_PROPERTY_URL_SOURCE 0xDD60 -#define MTP_PROPERTY_URL_DESTINATION 0xDD61 -#define MTP_PROPERTY_TIME_BOOKMARK 0xDD62 -#define MTP_PROPERTY_OBJECT_BOOKMARK 0xDD63 -#define MTP_PROPERTY_BYTE_BOOKMARK 0xDD64 -#define MTP_PROPERTY_LAST_BUILD_DATE 0xDD70 -#define MTP_PROPERTY_TIME_TO_LIVE 0xDD71 -#define MTP_PROPERTY_MEDIA_GUID 0xDD72 - -// MTP Device Property Codes -#define MTP_DEVICE_PROPERTY_UNDEFINED 0x5000 -#define MTP_DEVICE_PROPERTY_BATTERY_LEVEL 0x5001 -#define MTP_DEVICE_PROPERTY_FUNCTIONAL_MODE 0x5002 -#define MTP_DEVICE_PROPERTY_IMAGE_SIZE 0x5003 -#define MTP_DEVICE_PROPERTY_COMPRESSION_SETTING 0x5004 -#define MTP_DEVICE_PROPERTY_WHITE_BALANCE 0x5005 -#define MTP_DEVICE_PROPERTY_RGB_GAIN 0x5006 -#define MTP_DEVICE_PROPERTY_F_NUMBER 0x5007 -#define MTP_DEVICE_PROPERTY_FOCAL_LENGTH 0x5008 -#define MTP_DEVICE_PROPERTY_FOCUS_DISTANCE 0x5009 -#define MTP_DEVICE_PROPERTY_FOCUS_MODE 0x500A -#define MTP_DEVICE_PROPERTY_EXPOSURE_METERING_MODE 0x500B -#define MTP_DEVICE_PROPERTY_FLASH_MODE 0x500C -#define MTP_DEVICE_PROPERTY_EXPOSURE_TIME 0x500D -#define MTP_DEVICE_PROPERTY_EXPOSURE_PROGRAM_MODE 0x500E -#define MTP_DEVICE_PROPERTY_EXPOSURE_INDEX 0x500F -#define MTP_DEVICE_PROPERTY_EXPOSURE_BIAS_COMPENSATION 0x5010 -#define MTP_DEVICE_PROPERTY_DATETIME 0x5011 -#define MTP_DEVICE_PROPERTY_CAPTURE_DELAY 0x5012 -#define MTP_DEVICE_PROPERTY_STILL_CAPTURE_MODE 0x5013 -#define MTP_DEVICE_PROPERTY_CONTRAST 0x5014 -#define MTP_DEVICE_PROPERTY_SHARPNESS 0x5015 -#define MTP_DEVICE_PROPERTY_DIGITAL_ZOOM 0x5016 -#define MTP_DEVICE_PROPERTY_EFFECT_MODE 0x5017 -#define MTP_DEVICE_PROPERTY_BURST_NUMBER 0x5018 -#define MTP_DEVICE_PROPERTY_BURST_INTERVAL 0x5019 -#define MTP_DEVICE_PROPERTY_TIMELAPSE_NUMBER 0x501A -#define MTP_DEVICE_PROPERTY_TIMELAPSE_INTERVAL 0x501B -#define MTP_DEVICE_PROPERTY_FOCUS_METERING_MODE 0x501C -#define MTP_DEVICE_PROPERTY_UPLOAD_URL 0x501D -#define MTP_DEVICE_PROPERTY_ARTIST 0x501E -#define MTP_DEVICE_PROPERTY_COPYRIGHT_INFO 0x501F -#define MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER 0xD401 -#define MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME 0xD402 -#define MTP_DEVICE_PROPERTY_VOLUME 0xD403 -#define MTP_DEVICE_PROPERTY_SUPPORTED_FORMATS_ORDERED 0xD404 -#define MTP_DEVICE_PROPERTY_DEVICE_ICON 0xD405 -#define MTP_DEVICE_PROPERTY_PLAYBACK_RATE 0xD410 -#define MTP_DEVICE_PROPERTY_PLAYBACK_OBJECT 0xD411 -#define MTP_DEVICE_PROPERTY_PLAYBACK_CONTAINER_INDEX 0xD412 -#define MTP_DEVICE_PROPERTY_SESSION_INITIATOR_VERSION_INFO 0xD406 -#define MTP_DEVICE_PROPERTY_PERCEIVED_DEVICE_TYPE 0xD407 - -// MTP Operation Codes -#define MTP_OPERATION_GET_DEVICE_INFO 0x1001 -#define MTP_OPERATION_OPEN_SESSION 0x1002 -#define MTP_OPERATION_CLOSE_SESSION 0x1003 -#define MTP_OPERATION_GET_STORAGE_IDS 0x1004 -#define MTP_OPERATION_GET_STORAGE_INFO 0x1005 -#define MTP_OPERATION_GET_NUM_OBJECTS 0x1006 -#define MTP_OPERATION_GET_OBJECT_HANDLES 0x1007 -#define MTP_OPERATION_GET_OBJECT_INFO 0x1008 -#define MTP_OPERATION_GET_OBJECT 0x1009 -#define MTP_OPERATION_GET_THUMB 0x100A -#define MTP_OPERATION_DELETE_OBJECT 0x100B -#define MTP_OPERATION_SEND_OBJECT_INFO 0x100C -#define MTP_OPERATION_SEND_OBJECT 0x100D -#define MTP_OPERATION_INITIATE_CAPTURE 0x100E -#define MTP_OPERATION_FORMAT_STORE 0x100F -#define MTP_OPERATION_RESET_DEVICE 0x1010 -#define MTP_OPERATION_SELF_TEST 0x1011 -#define MTP_OPERATION_SET_OBJECT_PROTECTION 0x1012 -#define MTP_OPERATION_POWER_DOWN 0x1013 -#define MTP_OPERATION_GET_DEVICE_PROP_DESC 0x1014 -#define MTP_OPERATION_GET_DEVICE_PROP_VALUE 0x1015 -#define MTP_OPERATION_SET_DEVICE_PROP_VALUE 0x1016 -#define MTP_OPERATION_RESET_DEVICE_PROP_VALUE 0x1017 -#define MTP_OPERATION_TERMINATE_OPEN_CAPTURE 0x1018 -#define MTP_OPERATION_MOVE_OBJECT 0x1019 -#define MTP_OPERATION_COPY_OBJECT 0x101A -#define MTP_OPERATION_GET_PARTIAL_OBJECT 0x101B -#define MTP_OPERATION_INITIATE_OPEN_CAPTURE 0x101C -#define MTP_OPERATION_GET_OBJECT_PROPS_SUPPORTED 0x9801 -#define MTP_OPERATION_GET_OBJECT_PROP_DESC 0x9802 -#define MTP_OPERATION_GET_OBJECT_PROP_VALUE 0x9803 -#define MTP_OPERATION_SET_OBJECT_PROP_VALUE 0x9804 -#define MTP_OPERATION_GET_OBJECT_PROP_LIST 0x9805 -#define MTP_OPERATION_SET_OBJECT_PROP_LIST 0x9806 -#define MTP_OPERATION_GET_INTERDEPENDENT_PROP_DESC 0x9807 -#define MTP_OPERATION_SEND_OBJECT_PROP_LIST 0x9808 -#define MTP_OPERATION_GET_OBJECT_REFERENCES 0x9810 -#define MTP_OPERATION_SET_OBJECT_REFERENCES 0x9811 -#define MTP_OPERATION_SKIP 0x9820 - -// Android extensions for direct file IO - -// Same as GetPartialObject, but with 64 bit offset -#define MTP_OPERATION_GET_PARTIAL_OBJECT_64 0x95C1 -// Same as GetPartialObject64, but copying host to device -#define MTP_OPERATION_SEND_PARTIAL_OBJECT 0x95C2 -// Truncates file to 64 bit length -#define MTP_OPERATION_TRUNCATE_OBJECT 0x95C3 -// Must be called before using SendPartialObject and TruncateObject -#define MTP_OPERATION_BEGIN_EDIT_OBJECT 0x95C4 -// Called to commit changes made by SendPartialObject and TruncateObject -#define MTP_OPERATION_END_EDIT_OBJECT 0x95C5 - -// MTP Response Codes -#define MTP_RESPONSE_UNDEFINED 0x2000 -#define MTP_RESPONSE_OK 0x2001 -#define MTP_RESPONSE_GENERAL_ERROR 0x2002 -#define MTP_RESPONSE_SESSION_NOT_OPEN 0x2003 -#define MTP_RESPONSE_INVALID_TRANSACTION_ID 0x2004 -#define MTP_RESPONSE_OPERATION_NOT_SUPPORTED 0x2005 -#define MTP_RESPONSE_PARAMETER_NOT_SUPPORTED 0x2006 -#define MTP_RESPONSE_INCOMPLETE_TRANSFER 0x2007 -#define MTP_RESPONSE_INVALID_STORAGE_ID 0x2008 -#define MTP_RESPONSE_INVALID_OBJECT_HANDLE 0x2009 -#define MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED 0x200A -#define MTP_RESPONSE_INVALID_OBJECT_FORMAT_CODE 0x200B -#define MTP_RESPONSE_STORAGE_FULL 0x200C -#define MTP_RESPONSE_OBJECT_WRITE_PROTECTED 0x200D -#define MTP_RESPONSE_STORE_READ_ONLY 0x200E -#define MTP_RESPONSE_ACCESS_DENIED 0x200F -#define MTP_RESPONSE_NO_THUMBNAIL_PRESENT 0x2010 -#define MTP_RESPONSE_SELF_TEST_FAILED 0x2011 -#define MTP_RESPONSE_PARTIAL_DELETION 0x2012 -#define MTP_RESPONSE_STORE_NOT_AVAILABLE 0x2013 -#define MTP_RESPONSE_SPECIFICATION_BY_FORMAT_UNSUPPORTED 0x2014 -#define MTP_RESPONSE_NO_VALID_OBJECT_INFO 0x2015 -#define MTP_RESPONSE_INVALID_CODE_FORMAT 0x2016 -#define MTP_RESPONSE_UNKNOWN_VENDOR_CODE 0x2017 -#define MTP_RESPONSE_CAPTURE_ALREADY_TERMINATED 0x2018 -#define MTP_RESPONSE_DEVICE_BUSY 0x2019 -#define MTP_RESPONSE_INVALID_PARENT_OBJECT 0x201A -#define MTP_RESPONSE_INVALID_DEVICE_PROP_FORMAT 0x201B -#define MTP_RESPONSE_INVALID_DEVICE_PROP_VALUE 0x201C -#define MTP_RESPONSE_INVALID_PARAMETER 0x201D -#define MTP_RESPONSE_SESSION_ALREADY_OPEN 0x201E -#define MTP_RESPONSE_TRANSACTION_CANCELLED 0x201F -#define MTP_RESPONSE_SPECIFICATION_OF_DESTINATION_UNSUPPORTED 0x2020 -#define MTP_RESPONSE_INVALID_OBJECT_PROP_CODE 0xA801 -#define MTP_RESPONSE_INVALID_OBJECT_PROP_FORMAT 0xA802 -#define MTP_RESPONSE_INVALID_OBJECT_PROP_VALUE 0xA803 -#define MTP_RESPONSE_INVALID_OBJECT_REFERENCE 0xA804 -#define MTP_RESPONSE_GROUP_NOT_SUPPORTED 0xA805 -#define MTP_RESPONSE_INVALID_DATASET 0xA806 -#define MTP_RESPONSE_SPECIFICATION_BY_GROUP_UNSUPPORTED 0xA807 -#define MTP_RESPONSE_SPECIFICATION_BY_DEPTH_UNSUPPORTED 0xA808 -#define MTP_RESPONSE_OBJECT_TOO_LARGE 0xA809 -#define MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED 0xA80A - -// MTP Event Codes -#define MTP_EVENT_UNDEFINED 0x4000 -#define MTP_EVENT_CANCEL_TRANSACTION 0x4001 -#define MTP_EVENT_OBJECT_ADDED 0x4002 -#define MTP_EVENT_OBJECT_REMOVED 0x4003 -#define MTP_EVENT_STORE_ADDED 0x4004 -#define MTP_EVENT_STORE_REMOVED 0x4005 -#define MTP_EVENT_DEVICE_PROP_CHANGED 0x4006 -#define MTP_EVENT_OBJECT_INFO_CHANGED 0x4007 -#define MTP_EVENT_DEVICE_INFO_CHANGED 0x4008 -#define MTP_EVENT_REQUEST_OBJECT_TRANSFER 0x4009 -#define MTP_EVENT_STORE_FULL 0x400A -#define MTP_EVENT_DEVICE_RESET 0x400B -#define MTP_EVENT_STORAGE_INFO_CHANGED 0x400C -#define MTP_EVENT_CAPTURE_COMPLETE 0x400D -#define MTP_EVENT_UNREPORTED_STATUS 0x400E -#define MTP_EVENT_OBJECT_PROP_CHANGED 0xC801 -#define MTP_EVENT_OBJECT_PROP_DESC_CHANGED 0xC802 -#define MTP_EVENT_OBJECT_REFERENCES_CHANGED 0xC803 - -// Storage Type -#define MTP_STORAGE_FIXED_ROM 0x0001 -#define MTP_STORAGE_REMOVABLE_ROM 0x0002 -#define MTP_STORAGE_FIXED_RAM 0x0003 -#define MTP_STORAGE_REMOVABLE_RAM 0x0004 - -// Storage File System -#define MTP_STORAGE_FILESYSTEM_FLAT 0x0001 -#define MTP_STORAGE_FILESYSTEM_HIERARCHICAL 0x0002 -#define MTP_STORAGE_FILESYSTEM_DCF 0x0003 - -// Storage Access Capability -#define MTP_STORAGE_READ_WRITE 0x0000 -#define MTP_STORAGE_READ_ONLY_WITHOUT_DELETE 0x0001 -#define MTP_STORAGE_READ_ONLY_WITH_DELETE 0x0002 - -// Association Type -#define MTP_ASSOCIATION_TYPE_UNDEFINED 0x0000 -#define MTP_ASSOCIATION_TYPE_GENERIC_FOLDER 0x0001 - -// Supported Playback Formats -#define SUPPORTED_PLAYBACK_FORMAT_UNDEFINED 0x3000 -/** Format code for associations (folders and directories) */ -#define SUPPORTED_PLAYBACK_FORMAT_ASSOCIATION 0x3001 -/** Format code for script files */ -#define SUPPORTED_PLAYBACK_FORMAT_SCRIPT 0x3002 -/** Format code for executable files */ -#define SUPPORTED_PLAYBACK_FORMAT_EXECUTABLE 0x3003 -/** Format code for text files */ -#define SUPPORTED_PLAYBACK_FORMAT_TEXT 0x3004 -/** Format code for HTML files */ -#define SUPPORTED_PLAYBACK_FORMAT_HTML 0x3005 -/** Format code for DPOF files */ -#define SUPPORTED_PLAYBACK_FORMAT_DPOF 0x3006 -/** Format code for AIFF audio files */ -#define SUPPORTED_PLAYBACK_FORMAT_AIFF 0x3007 -/** Format code for WAV audio files */ -#define SUPPORTED_PLAYBACK_FORMAT_WAV 0x3008 -/** Format code for MP3 audio files */ -#define SUPPORTED_PLAYBACK_FORMAT_MP3 0x3009 -/** Format code for AVI video files */ -#define SUPPORTED_PLAYBACK_FORMAT_AVI 0x300A -/** Format code for MPEG video files */ -#define SUPPORTED_PLAYBACK_FORMAT_MPEG 0x300B -/** Format code for ASF files */ -#define SUPPORTED_PLAYBACK_FORMAT_ASF 0x300C -/** Format code for JPEG image files */ -#define SUPPORTED_PLAYBACK_FORMAT_EXIF_JPEG 0x3801 -/** Format code for TIFF EP image files */ -#define SUPPORTED_PLAYBACK_FORMAT_TIFF_EP 0x3802 -/** Format code for BMP image files */ -#define SUPPORTED_PLAYBACK_FORMAT_BMP 0x3804 -/** Format code for GIF image files */ -#define SUPPORTED_PLAYBACK_FORMAT_GIF 0x3807 -/** Format code for JFIF image files */ -#define SUPPORTED_PLAYBACK_FORMAT_JFIF 0x3808 -/** Format code for PICT image files */ -#define SUPPORTED_PLAYBACK_FORMAT_PICT 0x380A -/** Format code for PNG image files */ -#define SUPPORTED_PLAYBACK_FORMAT_PNG 0x380B -/** Format code for TIFF image files */ -#define SUPPORTED_PLAYBACK_FORMAT_TIFF 0x380D -/** Format code for JP2 files */ -#define SUPPORTED_PLAYBACK_FORMAT_JP2 0x380F -/** Format code for JPX files */ -#define SUPPORTED_PLAYBACK_FORMAT_JPX 0x3810 -/** Format code for firmware files */ -#define SUPPORTED_PLAYBACK_FORMAT_UNDEFINED_FIRMWARE 0xB802 -/** Format code for Windows image files */ -#define SUPPORTED_PLAYBACK_FORMAT_WINDOWS_IMAGE_FORMAT 0xB881 -/** Format code for undefined audio files files */ -#define SUPPORTED_PLAYBACK_FORMAT_UNDEFINED_AUDIO 0xB900 -/** Format code for WMA audio files */ -#define SUPPORTED_PLAYBACK_FORMAT_WMA 0xB901 -/** Format code for OGG audio files */ -#define SUPPORTED_PLAYBACK_FORMAT_OGG 0xB902 -/** Format code for AAC audio files */ -#define SUPPORTED_PLAYBACK_FORMAT_AAC 0xB903 -/** Format code for Audible audio files */ -#define SUPPORTED_PLAYBACK_FORMAT_AUDIBLE 0xB904 -/** Format code for FLAC audio files */ -#define SUPPORTED_PLAYBACK_FORMAT_FLAC 0xB906 -/** Format code for undefined video files */ -#define SUPPORTED_PLAYBACK_FORMAT_UNDEFINED_VIDEO 0xB980 -/** Format code for WMV video files */ -#define SUPPORTED_PLAYBACK_FORMAT_WMV 0xB981 -/** Format code for MP4 files */ -#define SUPPORTED_PLAYBACK_FORMAT_MP4_CONTAINER 0xB982 -/** Format code for MP2 files */ -#define SUPPORTED_PLAYBACK_FORMAT_MP2 0xB983 -/** Format code for 3GP files */ -#define SUPPORTED_PLAYBACK_FORMAT_3GP_CONTAINER 0xB984 -/** Format code for undefined collections */ -#define SUPPORTED_PLAYBACK_FORMAT_UNDEFINED_COLLECTION 0xBA00 -/** Format code for multimedia albums */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_MULTIMEDIA_ALBUM 0xBA01 -/** Format code for image albums */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_IMAGE_ALBUM 0xBA02 -/** Format code for audio albums */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_AUDIO_ALBUM 0xBA03 -/** Format code for video albums */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_VIDEO_ALBUM 0xBA04 -/** Format code for abstract AV playlists */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_AV_PLAYLIST 0xBA05 -/** Format code for abstract audio playlists */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_AUDIO_PLAYLIST 0xBA09 -/** Format code for abstract video playlists */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_VIDEO_PLAYLIST 0xBA0A -/** Format code for abstract mediacasts */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_MEDIACAST 0xBA0B -/** Format code for WPL playlist files */ -#define SUPPORTED_PLAYBACK_FORMAT_WPL_PLAYLIST 0xBA10 -/** Format code for M3u playlist files */ -#define SUPPORTED_PLAYBACK_FORMAT_M3U_PLAYLIST 0xBA11 -/** Format code for MPL playlist files */ -#define SUPPORTED_PLAYBACK_FORMAT_MPL_PLAYLIST 0xBA12 -/** Format code for ASX playlist files */ -#define SUPPORTED_PLAYBACK_FORMAT_ASX_PLAYLIST 0xBA13 -/** Format code for PLS playlist files */ -#define SUPPORTED_PLAYBACK_FORMAT_PLS_PLAYLIST 0xBA14 -/** Format code for undefined document files */ -#define SUPPORTED_PLAYBACK_FORMAT_UNDEFINED_DOCUMENT 0xBA80 -/** Format code for abstract documents */ -#define SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_DOCUMENT 0xBA81 -/** Format code for XML documents */ -#define SUPPORTED_PLAYBACK_FORMAT_XML_DOCUMENT 0xBA82 -/** Format code for MS Word documents */ -#define SUPPORTED_PLAYBACK_FORMAT_MS_WORD_DOCUMENT 0xBA83 -/** Format code for MS Excel spreadsheets */ -#define SUPPORTED_PLAYBACK_FORMAT_MS_EXCEL_SPREADSHEET 0xBA85 -/** Format code for MS PowerPoint presentatiosn */ -#define SUPPORTED_PLAYBACK_FORMAT_MS_POWERPOINT_PRESENTATION 0xBA86 - -#endif // _MTP_H diff --git a/mtp/legacy/mtp_MtpDatabase.cpp b/mtp/legacy/mtp_MtpDatabase.cpp deleted file mode 100644 index 5eb7d8e6..00000000 --- a/mtp/legacy/mtp_MtpDatabase.cpp +++ /dev/null @@ -1,871 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "MtpDatabase.h" -#include "MtpStorage.h" -#include "MtpDataPacket.h" -#include "MtpObjectInfo.h" -#include "MtpProperty.h" -#include "MtpDebug.h" -#include "MtpStringBuffer.h" -#include "MtpUtils.h" -#include "mtp.h" -#include "mtp_MtpDatabase.hpp" -//#include "btree.hpp" - -MyMtpDatabase::MyMtpDatabase() -{ - storagenum = 0; - count = -1; -} - -MyMtpDatabase::~MyMtpDatabase() { - std::map::iterator i; - for (i = storagemap.begin(); i != storagemap.end(); i++) { - delete i->second; - } -} - -int MyMtpDatabase::DEVICE_PROPERTIES[3] = { - MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER, - MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME, - MTP_DEVICE_PROPERTY_IMAGE_SIZE -}; - -int MyMtpDatabase::FILE_PROPERTIES[10] = { - // NOTE must match beginning of AUDIO_PROPERTIES, VIDEO_PROPERTIES - // and IMAGE_PROPERTIES below - MTP_PROPERTY_STORAGE_ID, - MTP_PROPERTY_OBJECT_FORMAT, - MTP_PROPERTY_PROTECTION_STATUS, - MTP_PROPERTY_OBJECT_SIZE, - MTP_PROPERTY_OBJECT_FILE_NAME, - MTP_PROPERTY_DATE_MODIFIED, - MTP_PROPERTY_PARENT_OBJECT, - MTP_PROPERTY_PERSISTENT_UID, - MTP_PROPERTY_NAME, - // TODO: why is DISPLAY_NAME not here? - MTP_PROPERTY_DATE_ADDED -}; - -int MyMtpDatabase::AUDIO_PROPERTIES[19] = { - // NOTE must match FILE_PROPERTIES above - MTP_PROPERTY_STORAGE_ID, - MTP_PROPERTY_OBJECT_FORMAT, - MTP_PROPERTY_PROTECTION_STATUS, - MTP_PROPERTY_OBJECT_SIZE, - MTP_PROPERTY_OBJECT_FILE_NAME, - MTP_PROPERTY_DATE_MODIFIED, - MTP_PROPERTY_PARENT_OBJECT, - MTP_PROPERTY_PERSISTENT_UID, - MTP_PROPERTY_NAME, - MTP_PROPERTY_DISPLAY_NAME, - MTP_PROPERTY_DATE_ADDED, - - // audio specific properties - MTP_PROPERTY_ARTIST, - MTP_PROPERTY_ALBUM_NAME, - MTP_PROPERTY_ALBUM_ARTIST, - MTP_PROPERTY_TRACK, - MTP_PROPERTY_ORIGINAL_RELEASE_DATE, - MTP_PROPERTY_DURATION, - MTP_PROPERTY_GENRE, - MTP_PROPERTY_COMPOSER -}; - -int MyMtpDatabase::VIDEO_PROPERTIES[15] = { - // NOTE must match FILE_PROPERTIES above - MTP_PROPERTY_STORAGE_ID, - MTP_PROPERTY_OBJECT_FORMAT, - MTP_PROPERTY_PROTECTION_STATUS, - MTP_PROPERTY_OBJECT_SIZE, - MTP_PROPERTY_OBJECT_FILE_NAME, - MTP_PROPERTY_DATE_MODIFIED, - MTP_PROPERTY_PARENT_OBJECT, - MTP_PROPERTY_PERSISTENT_UID, - MTP_PROPERTY_NAME, - MTP_PROPERTY_DISPLAY_NAME, - MTP_PROPERTY_DATE_ADDED, - - // video specific properties - MTP_PROPERTY_ARTIST, - MTP_PROPERTY_ALBUM_NAME, - MTP_PROPERTY_DURATION, - MTP_PROPERTY_DESCRIPTION -}; - -int MyMtpDatabase::IMAGE_PROPERTIES[12] = { - // NOTE must match FILE_PROPERTIES above - MTP_PROPERTY_STORAGE_ID, - MTP_PROPERTY_OBJECT_FORMAT, - MTP_PROPERTY_PROTECTION_STATUS, - MTP_PROPERTY_OBJECT_SIZE, - MTP_PROPERTY_OBJECT_FILE_NAME, - MTP_PROPERTY_DATE_MODIFIED, - MTP_PROPERTY_PARENT_OBJECT, - MTP_PROPERTY_PERSISTENT_UID, - MTP_PROPERTY_NAME, - MTP_PROPERTY_DISPLAY_NAME, - MTP_PROPERTY_DATE_ADDED, - - // image specific properties - MTP_PROPERTY_DESCRIPTION -}; - -int MyMtpDatabase::ALL_PROPERTIES[25] = { - // NOTE must match FILE_PROPERTIES above - MTP_PROPERTY_STORAGE_ID, - MTP_PROPERTY_OBJECT_FORMAT, - MTP_PROPERTY_PROTECTION_STATUS, - MTP_PROPERTY_OBJECT_SIZE, - MTP_PROPERTY_OBJECT_FILE_NAME, - MTP_PROPERTY_DATE_MODIFIED, - MTP_PROPERTY_PARENT_OBJECT, - MTP_PROPERTY_PERSISTENT_UID, - MTP_PROPERTY_NAME, - MTP_PROPERTY_DISPLAY_NAME, - MTP_PROPERTY_DATE_ADDED, - - // image specific properties - MTP_PROPERTY_DESCRIPTION, - - // audio specific properties - MTP_PROPERTY_ARTIST, - MTP_PROPERTY_ALBUM_NAME, - MTP_PROPERTY_ALBUM_ARTIST, - MTP_PROPERTY_TRACK, - MTP_PROPERTY_ORIGINAL_RELEASE_DATE, - MTP_PROPERTY_DURATION, - MTP_PROPERTY_GENRE, - MTP_PROPERTY_COMPOSER, - - // video specific properties - MTP_PROPERTY_ARTIST, - MTP_PROPERTY_ALBUM_NAME, - MTP_PROPERTY_DURATION, - MTP_PROPERTY_DESCRIPTION, - - // image specific properties - MTP_PROPERTY_DESCRIPTION -}; - -int MyMtpDatabase::SUPPORTED_PLAYBACK_FORMATS[26] = { - SUPPORTED_PLAYBACK_FORMAT_UNDEFINED, - SUPPORTED_PLAYBACK_FORMAT_ASSOCIATION, - SUPPORTED_PLAYBACK_FORMAT_TEXT, - SUPPORTED_PLAYBACK_FORMAT_HTML, - SUPPORTED_PLAYBACK_FORMAT_WAV, - SUPPORTED_PLAYBACK_FORMAT_MP3, - SUPPORTED_PLAYBACK_FORMAT_MPEG, - SUPPORTED_PLAYBACK_FORMAT_EXIF_JPEG, - SUPPORTED_PLAYBACK_FORMAT_TIFF_EP, - SUPPORTED_PLAYBACK_FORMAT_BMP, - SUPPORTED_PLAYBACK_FORMAT_GIF, - SUPPORTED_PLAYBACK_FORMAT_JFIF, - SUPPORTED_PLAYBACK_FORMAT_PNG, - SUPPORTED_PLAYBACK_FORMAT_TIFF, - SUPPORTED_PLAYBACK_FORMAT_WMA, - SUPPORTED_PLAYBACK_FORMAT_OGG, - SUPPORTED_PLAYBACK_FORMAT_AAC, - SUPPORTED_PLAYBACK_FORMAT_MP4_CONTAINER, - SUPPORTED_PLAYBACK_FORMAT_MP2, - SUPPORTED_PLAYBACK_FORMAT_3GP_CONTAINER, - SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_AV_PLAYLIST, - SUPPORTED_PLAYBACK_FORMAT_WPL_PLAYLIST, - SUPPORTED_PLAYBACK_FORMAT_M3U_PLAYLIST, - SUPPORTED_PLAYBACK_FORMAT_PLS_PLAYLIST, - SUPPORTED_PLAYBACK_FORMAT_XML_DOCUMENT, - SUPPORTED_PLAYBACK_FORMAT_FLAC -}; - -MtpObjectHandle MyMtpDatabase::beginSendObject(const char* path, - MtpObjectFormat format, - MtpObjectHandle parent, - MtpStorageID storage, - uint64_t size, - time_t modified) { - if (storagemap.find(storage) == storagemap.end()) - return kInvalidObjectHandle; - return storagemap[storage]->beginSendObject(path, format, parent, size, modified); -} - -void MyMtpDatabase::endSendObject(const char* path, MtpObjectHandle handle, - MtpObjectFormat format, bool succeeded) { - MTPD("endSendObject() %s\n", path); - if (!succeeded) { - MTPE("endSendObject() failed, unlinking %s\n", path); - unlink(path); - } - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) - storit->second->endSendObject(path, handle, format, succeeded); -} - -void MyMtpDatabase::createDB(MtpStorage* storage, MtpStorageID storageID) { - MTPD("MyMtpDatabase::createDB called\n"); - storagemap[storageID] = storage; - storage->createDB(); -} - -void MyMtpDatabase::destroyDB(MtpStorageID storageID) { - MtpStorage* storage = storagemap[storageID]; - storagemap.erase(storageID); - delete storage; -} - -MtpObjectHandleList* MyMtpDatabase::getObjectList(MtpStorageID storageID, - MtpObjectFormat format, - MtpObjectHandle parent) { - MTPD("storageID: %d\n", storageID); - MtpObjectHandleList* list = storagemap[storageID]->getObjectList(storageID, parent); - MTPD("list: %d\n", list->size()); - return list; -} - -int MyMtpDatabase::getNumObjects(MtpStorageID storageID, - MtpObjectFormat format, - MtpObjectHandle parent) { - MtpObjectHandleList* list = storagemap[storageID]->getObjectList(storageID, parent); - int size = list->size(); - delete list; - return size; -} - -MtpObjectFormatList* MyMtpDatabase::getSupportedPlaybackFormats() { - // This function tells the host PC which file formats the device supports - MtpObjectFormatList* list = new MtpObjectFormatList(); - int length = sizeof(SUPPORTED_PLAYBACK_FORMATS) / sizeof(SUPPORTED_PLAYBACK_FORMATS[0]); - MTPD("MyMtpDatabase::getSupportedPlaybackFormats length: %i\n", length); - for (int i = 0; i < length; i++) { - MTPD("supported playback format: %x\n", SUPPORTED_PLAYBACK_FORMATS[i]); - list->push(SUPPORTED_PLAYBACK_FORMATS[i]); - } - return list; -} - -MtpObjectFormatList* MyMtpDatabase::getSupportedCaptureFormats() { - // Android OS implementation of this function returns NULL - // so we are not implementing this function either. - MTPD("MyMtpDatabase::getSupportedCaptureFormats returning NULL (This is what Android does as well).\n"); - return NULL; -} - -MtpObjectPropertyList* MyMtpDatabase::getSupportedObjectProperties(MtpObjectFormat format) { - int* properties; - MtpObjectPropertyList* list = new MtpObjectPropertyList(); - int length = 0; - switch (format) { - case MTP_FORMAT_MP3: - case MTP_FORMAT_WAV: - case MTP_FORMAT_WMA: - case MTP_FORMAT_OGG: - case MTP_FORMAT_AAC: - properties = AUDIO_PROPERTIES; - length = sizeof(AUDIO_PROPERTIES) / sizeof(AUDIO_PROPERTIES[0]); - break; - case MTP_FORMAT_MPEG: - case MTP_FORMAT_3GP_CONTAINER: - case MTP_FORMAT_WMV: - properties = VIDEO_PROPERTIES; - length = sizeof(VIDEO_PROPERTIES) / sizeof(VIDEO_PROPERTIES[0]); - break; - case MTP_FORMAT_EXIF_JPEG: - case MTP_FORMAT_GIF: - case MTP_FORMAT_PNG: - case MTP_FORMAT_BMP: - properties = IMAGE_PROPERTIES; - length = sizeof(IMAGE_PROPERTIES) / sizeof(IMAGE_PROPERTIES[0]); - break; - case 0: - properties = ALL_PROPERTIES; - length = sizeof(ALL_PROPERTIES) / sizeof(ALL_PROPERTIES[0]); - break; - default: - properties = FILE_PROPERTIES; - length = sizeof(FILE_PROPERTIES) / sizeof(FILE_PROPERTIES[0]); - } - MTPD("MyMtpDatabase::getSupportedObjectProperties length is: %i, format: %x", length, format); - for (int i = 0; i < length; i++) { - MTPD("supported object property: %x\n", properties[i]); - list->push(properties[i]); - } - return list; -} - -MtpDevicePropertyList* MyMtpDatabase::getSupportedDeviceProperties() { - MtpDevicePropertyList* list = new MtpDevicePropertyList(); - int length = sizeof(DEVICE_PROPERTIES) / sizeof(DEVICE_PROPERTIES[0]); - MTPD("MyMtpDatabase::getSupportedDeviceProperties length was: %i\n", length); - for (int i = 0; i < length; i++) - list->push(DEVICE_PROPERTIES[i]); - return list; -} - -MtpResponseCode MyMtpDatabase::getObjectPropertyValue(MtpObjectHandle handle, - MtpObjectProperty property, - MtpDataPacket& packet) { - MTPD("MyMtpDatabase::getObjectPropertyValue mtpid: %u, property: %x\n", handle, property); - int type; - MtpResponseCode result = MTP_RESPONSE_INVALID_OBJECT_HANDLE; - MtpStorage::PropEntry prop; - if (!getObjectPropertyInfo(property, type)) { - MTPE("MyMtpDatabase::getObjectPropertyValue returning MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED\n"); - return MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED; - } - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) { - if (storit->second->getObjectPropertyValue(handle, property, prop) == 0) { - result = MTP_RESPONSE_OK; - break; - } - } - - if (result != MTP_RESPONSE_OK) { - MTPE("MyMtpDatabase::getObjectPropertyValue unable to locate handle: %u\n", handle); - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; - } - - uint64_t longValue = prop.intvalue; - // special case date properties, which are strings to MTP - // but stored internally as a uint64 - if (property == MTP_PROPERTY_DATE_MODIFIED || property == MTP_PROPERTY_DATE_ADDED) { - char date[20]; - formatDateTime(longValue, date, sizeof(date)); - packet.putString(date); - goto out; - } - // release date is stored internally as just the year - if (property == MTP_PROPERTY_ORIGINAL_RELEASE_DATE) { - char date[20]; - snprintf(date, sizeof(date), "%04lld0101T000000", longValue); - packet.putString(date); - goto out; - } - - switch (type) { - case MTP_TYPE_INT8: - packet.putInt8(longValue); - break; - case MTP_TYPE_UINT8: - packet.putUInt8(longValue); - break; - case MTP_TYPE_INT16: - packet.putInt16(longValue); - break; - case MTP_TYPE_UINT16: - packet.putUInt16(longValue); - break; - case MTP_TYPE_INT32: - packet.putInt32(longValue); - break; - case MTP_TYPE_UINT32: - packet.putUInt32(longValue); - break; - case MTP_TYPE_INT64: - packet.putInt64(longValue); - break; - case MTP_TYPE_UINT64: - packet.putUInt64(longValue); - break; - case MTP_TYPE_INT128: - packet.putInt128(longValue); - break; - case MTP_TYPE_UINT128: - packet.putUInt128(longValue); - break; - case MTP_TYPE_STR: - { - /*std::string stringValue = (string)stringValuesArray[0]; - if (stringValue) { - const char* str = stringValue.c_str(); - if (str == NULL) { - return MTP_RESPONSE_GENERAL_ERROR; - } - packet.putString(str); - } else { - packet.putEmptyString(); - }*/ - packet.putString(prop.strvalue.c_str()); - MTPD("MTP_TYPE_STR: %x = %s\n", prop.property, prop.strvalue.c_str()); - //MTPE("STRING unsupported type in getObjectPropertyValue\n"); - //result = MTP_RESPONSE_INVALID_OBJECT_PROP_FORMAT; - break; - } - default: - MTPE("unsupported type in getObjectPropertyValue\n"); - result = MTP_RESPONSE_INVALID_OBJECT_PROP_FORMAT; - } -out: - return result; -} - -MtpResponseCode MyMtpDatabase::setObjectPropertyValue(MtpObjectHandle handle, - MtpObjectProperty property, - MtpDataPacket& packet) { - int type; - MTPD("MyMtpDatabase::setObjectPropertyValue start\n"); - if (!getObjectPropertyInfo(property, type)) { - MTPE("MyMtpDatabase::setObjectPropertyValue returning MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED\n"); - return MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED; - } - MTPD("MyMtpDatabase::setObjectPropertyValue continuing\n"); - long longValue = 0; - std::string stringValue; - - switch (type) { - case MTP_TYPE_INT8: - MTPD("int8\n"); - longValue = packet.getInt8(); - break; - case MTP_TYPE_UINT8: - MTPD("uint8\n"); - longValue = packet.getUInt8(); - break; - case MTP_TYPE_INT16: - MTPD("int16\n"); - longValue = packet.getInt16(); - break; - case MTP_TYPE_UINT16: - MTPD("uint16\n"); - longValue = packet.getUInt16(); - break; - case MTP_TYPE_INT32: - MTPD("int32\n"); - longValue = packet.getInt32(); - break; - case MTP_TYPE_UINT32: - MTPD("uint32\n"); - longValue = packet.getUInt32(); - break; - case MTP_TYPE_INT64: - MTPD("int64\n"); - longValue = packet.getInt64(); - break; - case MTP_TYPE_UINT64: - MTPD("uint64\n"); - longValue = packet.getUInt64(); - break; - case MTP_TYPE_STR: - { - MTPD("string\n"); - MtpStringBuffer buffer; - packet.getString(buffer); - stringValue = (const char *)buffer; - break; - } - default: - MTPE("MyMtpDatabase::setObjectPropertyValue unsupported type %i in getObjectPropertyValue\n", type); - return MTP_RESPONSE_INVALID_OBJECT_PROP_FORMAT; - } - - int result = MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED; - - switch (property) { - case MTP_PROPERTY_OBJECT_FILE_NAME: - { - MTPD("MyMtpDatabase::setObjectPropertyValue renaming file, handle: %d, new name: '%s'\n", handle, stringValue.c_str()); - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) { - if (storit->second->renameObject(handle, stringValue) == 0) { - MTPD("MTP_RESPONSE_OK\n"); - result = MTP_RESPONSE_OK; - break; - } - } - } - break; - - default: - MTPE("MyMtpDatabase::setObjectPropertyValue property %x not supported.\n", property); - result = MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED; - } - MTPD("MyMtpDatabase::setObjectPropertyValue returning %d\n", result); - return result; -} - -MtpResponseCode MyMtpDatabase::getDevicePropertyValue(MtpDeviceProperty property, - MtpDataPacket& packet) { - int type, result = 0; - char prop_value[PROPERTY_VALUE_MAX]; - MTPD("property %s\n", - MtpDebug::getDevicePropCodeName(property)); - if (!getDevicePropertyInfo(property, type)) { - MTPE("MyMtpDatabase::getDevicePropertyValue MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED\n"); - return MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED; - } - MTPD("property %s\n", - MtpDebug::getDevicePropCodeName(property)); - MTPD("property %x\n", property); - MTPD("MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME %x\n", MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME); - switch (property) { - case MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER: - case MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME: - result = MTP_RESPONSE_OK; - break; - default: - { - MTPE("MyMtpDatabase::getDevicePropertyValue property %x not supported\n", property); - result = MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED; - break; - } - } - - if (result != MTP_RESPONSE_OK) { - MTPD("MTP_REPONSE_OK NOT OK\n"); - return result; - } - - long longValue = 0; - property_get("ro.build.product", prop_value, "unknown manufacturer"); - switch (type) { - case MTP_TYPE_INT8: { - MTPD("MTP_TYPE_INT8\n"); - packet.putInt8(longValue); - break; - } - case MTP_TYPE_UINT8: - { - MTPD("MTP_TYPE_UINT8\n"); - packet.putUInt8(longValue); - break; - } - case MTP_TYPE_INT16: - { - MTPD("MTP_TYPE_INT16\n"); - packet.putInt16(longValue); - break; - } - case MTP_TYPE_UINT16: - { - MTPD("MTP_TYPE_UINT16\n"); - packet.putUInt16(longValue); - break; - } - case MTP_TYPE_INT32: - { - MTPD("MTP_TYPE_INT32\n"); - packet.putInt32(longValue); - break; - } - case MTP_TYPE_UINT32: - { - MTPD("MTP_TYPE_UINT32\n"); - packet.putUInt32(longValue); - break; - } - case MTP_TYPE_INT64: - { - MTPD("MTP_TYPE_INT64\n"); - packet.putInt64(longValue); - break; - } - case MTP_TYPE_UINT64: - { - MTPD("MTP_TYPE_UINT64\n"); - packet.putUInt64(longValue); - break; - } - case MTP_TYPE_INT128: - { - MTPD("MTP_TYPE_INT128\n"); - packet.putInt128(longValue); - break; - } - case MTP_TYPE_UINT128: - { - MTPD("MTP_TYPE_UINT128\n"); - packet.putInt128(longValue); - break; - } - case MTP_TYPE_STR: - { - MTPD("MTP_TYPE_STR\n"); - char* str = prop_value; - packet.putString(str); - break; - } - default: - MTPE("MyMtpDatabase::getDevicePropertyValue unsupported type %i in getDevicePropertyValue\n", type); - return MTP_RESPONSE_INVALID_DEVICE_PROP_FORMAT; - } - - return MTP_RESPONSE_OK; -} - -MtpResponseCode MyMtpDatabase::setDevicePropertyValue(MtpDeviceProperty property, MtpDataPacket& packet) { - int type; - MTPE("MyMtpDatabase::setDevicePropertyValue not implemented, returning 0\n"); - return 0; -} - -MtpResponseCode MyMtpDatabase::resetDeviceProperty(MtpDeviceProperty property) { - MTPE("MyMtpDatabase::resetDeviceProperty not implemented, returning -1\n"); - return -1; -} - -MtpResponseCode MyMtpDatabase::getObjectPropertyList(MtpObjectHandle handle, uint32_t format, uint32_t property, int groupCode, int depth, MtpDataPacket& packet) { - MTPD("getObjectPropertyList()\n"); - MTPD("property: %x\n", property); - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) { - MTPD("MyMtpDatabase::getObjectPropertyList calling getObjectPropertyList\n"); - if (storit->second->getObjectPropertyList(handle, format, property, groupCode, depth, packet) == 0) { - MTPD("MTP_RESPONSE_OK\n"); - return MTP_RESPONSE_OK; - } - } - MTPE("MyMtpDatabase::getObjectPropertyList MTP_RESPOSNE_INVALID_OBJECT_HANDLE %i\n", handle); - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; -} - -MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle, MtpObjectInfo& info) { - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) { - if (storit->second->getObjectInfo(handle, info) == 0) { - MTPD("MTP_RESPONSE_OK\n"); - return MTP_RESPONSE_OK; - } - } - MTPE("MyMtpDatabase::getObjectInfo MTP_RESPONSE_INVALID_OBJECT_HANDLE %i\n", handle); - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; -} - -void* MyMtpDatabase::getThumbnail(MtpObjectHandle handle, size_t& outThumbSize) { - MtpString path; - int64_t length; - MtpObjectFormat format; - void* result = NULL; - outThumbSize = 0; - MTPE("MyMtpDatabase::getThumbnail not implemented, returning 0\n"); - return 0; -} - -MtpResponseCode MyMtpDatabase::getObjectFilePath(MtpObjectHandle handle, MtpString& outFilePath, int64_t& outFileLength, MtpObjectFormat& outFormat) { - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) { - MTPD("MyMtpDatabase::getObjectFilePath calling getObjectFilePath\n"); - if (storit->second->getObjectFilePath(handle, outFilePath, outFileLength, outFormat) == 0) { - MTPD("MTP_RESPONSE_OK\n"); - return MTP_RESPONSE_OK; - } - } - MTPE("MyMtpDatabase::getObjectFilePath MTP_RESPOSNE_INVALID_OBJECT_HANDLE %i\n", handle); - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; -} - -MtpResponseCode MyMtpDatabase::deleteFile(MtpObjectHandle handle) { - MTPD("deleteFile\n"); - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) { - if (storit->second->deleteFile(handle) == 0) { - MTPD("MTP_RESPONSE_OK\n"); - return MTP_RESPONSE_OK; - } - } - MTPE("MyMtpDatabase::deleteFile MTP_RESPONSE_INVALID_OBJECT_HANDLE %i\n", handle); - return MTP_RESPONSE_INVALID_OBJECT_HANDLE; -} - -struct PropertyTableEntry { - MtpObjectProperty property; - int type; -}; - -static const PropertyTableEntry kObjectPropertyTable[] = { - { MTP_PROPERTY_STORAGE_ID, MTP_TYPE_UINT32 }, - { MTP_PROPERTY_OBJECT_FORMAT, MTP_TYPE_UINT16 }, - { MTP_PROPERTY_PROTECTION_STATUS, MTP_TYPE_UINT16 }, - { MTP_PROPERTY_OBJECT_SIZE, MTP_TYPE_UINT64 }, - { MTP_PROPERTY_OBJECT_FILE_NAME, MTP_TYPE_STR }, - { MTP_PROPERTY_DATE_MODIFIED, MTP_TYPE_STR }, - { MTP_PROPERTY_PARENT_OBJECT, MTP_TYPE_UINT32 }, - { MTP_PROPERTY_PERSISTENT_UID, MTP_TYPE_UINT128 }, - { MTP_PROPERTY_NAME, MTP_TYPE_STR }, - { MTP_PROPERTY_DISPLAY_NAME, MTP_TYPE_STR }, - { MTP_PROPERTY_DATE_ADDED, MTP_TYPE_STR }, - { MTP_PROPERTY_ARTIST, MTP_TYPE_STR }, - { MTP_PROPERTY_ALBUM_NAME, MTP_TYPE_STR }, - { MTP_PROPERTY_ALBUM_ARTIST, MTP_TYPE_STR }, - { MTP_PROPERTY_TRACK, MTP_TYPE_UINT16 }, - { MTP_PROPERTY_ORIGINAL_RELEASE_DATE, MTP_TYPE_STR }, - { MTP_PROPERTY_GENRE, MTP_TYPE_STR }, - { MTP_PROPERTY_COMPOSER, MTP_TYPE_STR }, - { MTP_PROPERTY_DURATION, MTP_TYPE_UINT32 }, - { MTP_PROPERTY_DESCRIPTION, MTP_TYPE_STR }, -}; - -static const PropertyTableEntry kDevicePropertyTable[] = { - { MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER, MTP_TYPE_STR }, - { MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME, MTP_TYPE_STR }, - { MTP_DEVICE_PROPERTY_IMAGE_SIZE, MTP_TYPE_STR }, -}; - -bool MyMtpDatabase::getObjectPropertyInfo(MtpObjectProperty property, int& type) { - int count = sizeof(kObjectPropertyTable) / sizeof(kObjectPropertyTable[0]); - const PropertyTableEntry* entry = kObjectPropertyTable; - MTPD("MyMtpDatabase::getObjectPropertyInfo size is: %i\n", count); - for (int i = 0; i < count; i++, entry++) { - if (entry->property == property) { - type = entry->type; - return true; - } - } - return false; -} - -bool MyMtpDatabase::getDevicePropertyInfo(MtpDeviceProperty property, int& type) { - int count = sizeof(kDevicePropertyTable) / sizeof(kDevicePropertyTable[0]); - const PropertyTableEntry* entry = kDevicePropertyTable; - MTPD("MyMtpDatabase::getDevicePropertyInfo count is: %i\n", count); - for (int i = 0; i < count; i++, entry++) { - if (entry->property == property) { - type = entry->type; - MTPD("type: %x\n", type); - return true; - } - } - return false; -} - -MtpObjectHandleList* MyMtpDatabase::getObjectReferences(MtpObjectHandle handle) { - // call function and place files with associated handles into int array - MTPD("MyMtpDatabase::getObjectReferences returning null, this seems to be what Android always does.\n"); - MTPD("handle: %d\n", handle); - // Windows + Android seems to always return a NULL in this function, c == null path - // The way that this is handled in Android then is to do this: - return NULL; -} - -MtpResponseCode MyMtpDatabase::setObjectReferences(MtpObjectHandle handle, - MtpObjectHandleList* references) { - int count = references->size(); - MTPE("MyMtpDatabase::setObjectReferences not implemented, returning 0\n"); - return 0; -} - -MtpProperty* MyMtpDatabase::getObjectPropertyDesc(MtpObjectProperty property, - MtpObjectFormat format) { - MTPD("MyMtpDatabase::getObjectPropertyDesc start\n"); - MtpProperty* result = NULL; - switch (property) { - case MTP_PROPERTY_OBJECT_FORMAT: - // use format as default value - result = new MtpProperty(property, MTP_TYPE_UINT16, false, format); - break; - case MTP_PROPERTY_PROTECTION_STATUS: - case MTP_PROPERTY_TRACK: - result = new MtpProperty(property, MTP_TYPE_UINT16); - break; - case MTP_PROPERTY_STORAGE_ID: - case MTP_PROPERTY_PARENT_OBJECT: - case MTP_PROPERTY_DURATION: - result = new MtpProperty(property, MTP_TYPE_UINT32); - break; - case MTP_PROPERTY_OBJECT_SIZE: - result = new MtpProperty(property, MTP_TYPE_UINT64); - break; - case MTP_PROPERTY_PERSISTENT_UID: - result = new MtpProperty(property, MTP_TYPE_UINT128); - break; - case MTP_PROPERTY_NAME: - case MTP_PROPERTY_DISPLAY_NAME: - case MTP_PROPERTY_ARTIST: - case MTP_PROPERTY_ALBUM_NAME: - case MTP_PROPERTY_ALBUM_ARTIST: - case MTP_PROPERTY_GENRE: - case MTP_PROPERTY_COMPOSER: - case MTP_PROPERTY_DESCRIPTION: - result = new MtpProperty(property, MTP_TYPE_STR); - break; - case MTP_PROPERTY_DATE_MODIFIED: - case MTP_PROPERTY_DATE_ADDED: - case MTP_PROPERTY_ORIGINAL_RELEASE_DATE: - result = new MtpProperty(property, MTP_TYPE_STR); - result->setFormDateTime(); - break; - case MTP_PROPERTY_OBJECT_FILE_NAME: - // We allow renaming files and folders - result = new MtpProperty(property, MTP_TYPE_STR, true); - break; - } - return result; -} - -MtpProperty* MyMtpDatabase::getDevicePropertyDesc(MtpDeviceProperty property) { - MtpProperty* result = NULL; - int ret; - bool writable = false; - switch (property) { - case MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER: - case MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME: - writable = true; - // fall through - case MTP_DEVICE_PROPERTY_IMAGE_SIZE: - result = new MtpProperty(property, MTP_TYPE_STR, writable); - - // get current value - // TODO: add actual values - result->setCurrentValue(0); - result->setDefaultValue(0); - break; - } - - return result; -} - -void MyMtpDatabase::sessionStarted() { - MTPD("MyMtpDatabase::sessionStarted not implemented or does nothing, returning\n"); - return; -} - -void MyMtpDatabase::sessionEnded() { - MTPD("MyMtpDatabase::sessionEnded not implemented or does nothing, returning\n"); - return; -} - -// ---------------------------------------------------------------------------- - -void MyMtpDatabase::lockMutex(void) { - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) { - storit->second->lockMutex(0); - } -} - -void MyMtpDatabase::unlockMutex(void) { - std::map::iterator storit; - for (storit = storagemap.begin(); storit != storagemap.end(); storit++) { - storit->second->unlockMutex(0); - } -} diff --git a/mtp/legacy/mtp_MtpDatabase.hpp b/mtp/legacy/mtp_MtpDatabase.hpp deleted file mode 100644 index 931ba158..00000000 --- a/mtp/legacy/mtp_MtpDatabase.hpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef MTP_MTPDATABASE_HPP -#define MTP_MTPDATABASE_HPP - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "MtpDatabase.h" -#include "MtpDataPacket.h" -#include "MtpObjectInfo.h" -#include "MtpProperty.h" -#include "MtpStringBuffer.h" -#include "MtpUtils.h" -#include "mtp.h" - -class MyMtpDatabase : public MtpDatabase { -private: - int* getSupportedObjectProperties(int format); - - static int FILE_PROPERTIES[10]; - static int DEVICE_PROPERTIES[3]; - static int AUDIO_PROPERTIES[19]; - static int VIDEO_PROPERTIES[15]; - static int IMAGE_PROPERTIES[12]; - static int ALL_PROPERTIES[25]; - static int SUPPORTED_PLAYBACK_FORMATS[26]; - int storagenum; - int count; - std::string lastfile; - std::map storagemap; - void countDirs(std::string path); - int readParentDirs(std::string path, int storageID); - -public: - MyMtpDatabase(); - virtual ~MyMtpDatabase(); - - void createDB(MtpStorage* storage, MtpStorageID storageID); - void destroyDB(MtpStorageID storageID); - virtual MtpObjectHandle beginSendObject(const char* path, - MtpObjectFormat format, - MtpObjectHandle parent, - MtpStorageID storage, - uint64_t size, - time_t modified); - - virtual void endSendObject(const char* path, - MtpObjectHandle handle, - MtpObjectFormat format, - bool succeeded); - - virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID, - MtpObjectFormat format, - MtpObjectHandle parent); - - virtual int getNumObjects(MtpStorageID storageID, - MtpObjectFormat format, - MtpObjectHandle parent); - - // callee should delete[] the results from these - // results can be NULL - virtual MtpObjectFormatList* getSupportedPlaybackFormats(); - virtual MtpObjectFormatList* getSupportedCaptureFormats(); - virtual MtpObjectPropertyList* getSupportedObjectProperties(MtpObjectFormat format); - virtual MtpDevicePropertyList* getSupportedDeviceProperties(); - - virtual MtpResponseCode getObjectPropertyValue(MtpObjectHandle handle, - MtpObjectProperty property, - MtpDataPacket& packet); - - virtual MtpResponseCode setObjectPropertyValue(MtpObjectHandle handle, - MtpObjectProperty property, - MtpDataPacket& packet); - - virtual MtpResponseCode getDevicePropertyValue(MtpDeviceProperty property, - MtpDataPacket& packet); - - virtual MtpResponseCode setDevicePropertyValue(MtpDeviceProperty property, - MtpDataPacket& packet); - - virtual MtpResponseCode resetDeviceProperty(MtpDeviceProperty property); - - virtual MtpResponseCode getObjectPropertyList(MtpObjectHandle handle, - uint32_t format, uint32_t property, - int groupCode, int depth, - MtpDataPacket& packet); - - virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle, - MtpObjectInfo& info); - - virtual void* getThumbnail(MtpObjectHandle handle, size_t& outThumbSize); - - virtual MtpResponseCode getObjectFilePath(MtpObjectHandle handle, - MtpString& outFilePath, - int64_t& outFileLength, - MtpObjectFormat& outFormat); - virtual MtpResponseCode deleteFile(MtpObjectHandle handle); - - bool getObjectPropertyInfo(MtpObjectProperty property, int& type); - bool getDevicePropertyInfo(MtpDeviceProperty property, int& type); - - virtual MtpObjectHandleList* getObjectReferences(MtpObjectHandle handle); - - virtual MtpResponseCode setObjectReferences(MtpObjectHandle handle, - MtpObjectHandleList* references); - - virtual MtpProperty* getObjectPropertyDesc(MtpObjectProperty property, - MtpObjectFormat format); - - virtual MtpProperty* getDevicePropertyDesc(MtpDeviceProperty property); - - virtual void sessionStarted(); - - virtual void sessionEnded(); - virtual void lockMutex(); - virtual void unlockMutex(); -}; -#endif diff --git a/mtp/legacy/mtp_MtpServer.cpp b/mtp/legacy/mtp_MtpServer.cpp deleted file mode 100644 index 1ebe5f55..00000000 --- a/mtp/legacy/mtp_MtpServer.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mtp_MtpServer.hpp" -#include "MtpServer.h" -#include "MtpStorage.h" -#include "MtpDebug.h" -#include "MtpMessage.hpp" - -#include - -void twmtp_MtpServer::start() -{ - usePtp = false; - MyMtpDatabase* mtpdb = new MyMtpDatabase(); - /* Sleep for a bit before we open the MTP USB device because some - * devices are not ready due to the kernel not responding to our - * sysfs requests right away. - */ - usleep(800000); -#ifdef USB_MTP_DEVICE -#define STRINGIFY(x) #x -#define EXPAND(x) STRINGIFY(x) - const char* mtp_device = EXPAND(USB_MTP_DEVICE); - MTPI("Using '%s' for MTP device.\n", EXPAND(USB_MTP_DEVICE)); -#else - const char* mtp_device = "/dev/mtp_usb"; -#endif - int fd = open(mtp_device, O_RDWR); - if (fd < 0) { - MTPE("could not open MTP driver, errno: %d\n", errno); - return; - } - MTPD("fd: %d\n", fd); - server = new MtpServer(mtpdb, usePtp, 0, 0664, 0775); - refserver = server; - MTPI("created new mtpserver object\n"); - add_storage(); - MTPD("Starting add / remove mtppipe monitor thread\n"); - pthread_t thread; - ThreadPtr mtpptr = &twmtp_MtpServer::mtppipe_thread; - PThreadPtr p = *(PThreadPtr*)&mtpptr; - pthread_create(&thread, NULL, p, this); - // This loop restarts the MTP process if the device is unplugged and replugged in - while (true) { - server->run(fd); - fd = open(mtp_device, O_RDWR); - usleep(800000); - } -} - -void twmtp_MtpServer::set_storages(storages* mtpstorages) { - stores = mtpstorages; -} - -void twmtp_MtpServer::cleanup() -{ - android::Mutex sMutex; - android::Mutex::Autolock autoLock(sMutex); - - if (server) { - delete server; - } else { - MTPD("server is null in cleanup"); - } -} - -void twmtp_MtpServer::send_object_added(int handle) -{ - android::Mutex sMutex; - android::Mutex::Autolock autoLock(sMutex); - - if (server) - server->sendObjectAdded(handle); - else - MTPD("server is null in send_object_added"); -} - -void twmtp_MtpServer::send_object_removed(int handle) -{ - android::Mutex sMutex; - android::Mutex::Autolock autoLock(sMutex); - - if (server) - server->sendObjectRemoved(handle); - else - MTPD("server is null in send_object_removed"); -} - -void twmtp_MtpServer::add_storage() -{ - android::Mutex sMutex; - android::Mutex::Autolock autoLock(sMutex); - - MTPD("twmtp_MtpServer::add_storage count of storage devices: %i\n", stores->size()); - for (unsigned int i = 0; i < stores->size(); ++i) { - std::string pathStr = stores->at(i)->mount; - - if (!pathStr.empty()) { - std::string descriptionStr = stores->at(i)->display; - int storageID = stores->at(i)->mtpid; - long reserveSpace = 1; - bool removable = false; - uint64_t maxFileSize = stores->at(i)->maxFileSize; - if (descriptionStr != "") { - MtpStorage* storage = new MtpStorage(storageID, &pathStr[0], &descriptionStr[0], reserveSpace, removable, maxFileSize, refserver); - server->addStorage(storage); - } - } - } -} - -void twmtp_MtpServer::remove_storage(int storageId) -{ - android::Mutex sMutex; - android::Mutex::Autolock autoLock(sMutex); - - if (server) { - MtpStorage* storage = server->getStorage(storageId); - if (storage) { - MTPD("twmtp_MtpServer::remove_storage calling removeStorage\n"); - server->removeStorage(storage); - } - } else - MTPD("server is null in remove_storage"); - MTPD("twmtp_MtpServer::remove_storage DONE\n"); -} - -int twmtp_MtpServer::mtppipe_thread(void) -{ - if (mtp_read_pipe == -1) { - MTPD("mtppipe_thread exiting because mtp_read_pipe not set\n"); - return 0; - } - MTPD("Starting twmtp_MtpServer::mtppipe_thread\n"); - int read_count; - struct mtpmsg mtp_message; - while (1) { - read_count = ::read(mtp_read_pipe, &mtp_message, sizeof(mtp_message)); - MTPD("read %i from mtppipe\n", read_count); - if (read_count == sizeof(mtp_message)) { - if (mtp_message.message_type == MTP_MESSAGE_ADD_STORAGE) { - MTPI("mtppipe add storage %i '%s'\n", mtp_message.storage_id, mtp_message.path); - if (mtp_message.storage_id) { - long reserveSpace = 1; - bool removable = false; - MtpStorage* storage = new MtpStorage(mtp_message.storage_id, &mtp_message.path[0], &mtp_message.display[0], reserveSpace, removable, mtp_message.maxFileSize, refserver); - server->addStorage(storage); - MTPD("mtppipe done adding storage\n"); - } else { - MTPE("Invalid storage ID %i specified\n", mtp_message.storage_id); - } - } else if (mtp_message.message_type == MTP_MESSAGE_REMOVE_STORAGE) { - MTPI("mtppipe remove storage %i\n", mtp_message.storage_id); - remove_storage(mtp_message.storage_id); - MTPD("mtppipe done removing storage\n"); - } else { - MTPE("Unknown mtppipe message value: %i\n", mtp_message.message_type); - } - } else { - MTPE("twmtp_MtpServer::mtppipe_thread unexpected read_count %i\n", read_count); - close(mtp_read_pipe); - break; - } - } - MTPD("twmtp_MtpServer::mtppipe_thread closing\n"); - return 0; -} - -void twmtp_MtpServer::set_read_pipe(int pipe) -{ - mtp_read_pipe = pipe; -} diff --git a/mtp/legacy/mtp_MtpServer.hpp b/mtp/legacy/mtp_MtpServer.hpp deleted file mode 100644 index 99f63d51..00000000 --- a/mtp/legacy/mtp_MtpServer.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - */ - -#ifndef MTP_MTPSERVER_HPP -#define MTP_MTPSERVER_HPP -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "MtpServer.h" -#include "MtpStorage.h" -#include "mtp_MtpDatabase.hpp" - -typedef struct Storage { - std::string display; - std::string mount; - int mtpid; - uint64_t maxFileSize; -} storage; - -typedef std::vector storages; - -class twmtp_MtpServer { - public: - void start(); - void cleanup(); - void send_object_added(int handle); - void send_object_removed(int handle); - void add_storage(); - void remove_storage(int storageId); - void set_storages(storages* mtpstorages); - void set_read_pipe(int pipe); - storages *stores; - private: - typedef int (twmtp_MtpServer::*ThreadPtr)(void); - typedef void* (*PThreadPtr)(void *); - int mtppipe_thread(void); - bool usePtp; - MtpServer* server; - MtpServer* refserver; - int mtp_read_pipe; - -}; -#endif diff --git a/mtp/legacy/node.cpp b/mtp/legacy/node.cpp deleted file mode 100644 index 207a37a0..00000000 --- a/mtp/legacy/node.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "btree.hpp" -#include "mtp.h" -#include "MtpDebug.h" - - -Node::Node() - : handle(-1), parent(0), name("") -{ -} - -Node::Node(MtpObjectHandle handle, MtpObjectHandle parent, const std::string& name) - : handle(handle), parent(parent), name(name) -{ -} - -void Node::rename(const std::string& newName) { - name = newName; - updateProperty(MTP_PROPERTY_OBJECT_FILE_NAME, 0, name.c_str(), MTP_TYPE_STR); - updateProperty(MTP_PROPERTY_NAME, 0, name.c_str(), MTP_TYPE_STR); - updateProperty(MTP_PROPERTY_DISPLAY_NAME, 0, name.c_str(), MTP_TYPE_STR); -} - -MtpObjectHandle Node::Mtpid() const { return handle; } -MtpObjectHandle Node::getMtpParentId() const { return parent; } -const std::string& Node::getName() const { return name; } - -uint64_t Node::getIntProperty(MtpPropertyCode property) { - for (unsigned index = 0; index < mtpProp.size(); ++index) { - if (mtpProp[index].property == property) - return mtpProp[index].valueInt; - } - MTPE("Node::getIntProperty failed to find property %x, returning -1\n", (unsigned)property); - return -1; -} - -const Node::mtpProperty& Node::getProperty(MtpPropertyCode property) { - static const mtpProperty dummyProp; - for (size_t i = 0; i < mtpProp.size(); ++i) { - if (mtpProp[i].property == property) - return mtpProp[i]; - } - MTPE("Node::getProperty failed to find property %x, returning dummy property\n", (unsigned)property); - return dummyProp; -} - -void Node::addProperty(MtpPropertyCode property, uint64_t valueInt, std::string valueStr, MtpDataType dataType) { -// MTPD("adding property: %lld, valueInt: %lld, valueStr: %s, dataType: %d\n", property, valueInt, valueStr.c_str(), dataType); - struct mtpProperty prop; - prop.property = property; - prop.valueInt = valueInt; - prop.valueStr = valueStr; - prop.dataType = dataType; - mtpProp.push_back(prop); -} - -void Node::updateProperty(MtpPropertyCode property, uint64_t valueInt, std::string valueStr, MtpDataType dataType) { - for (unsigned i = 0; i < mtpProp.size(); i++) { - if (mtpProp[i].property == property) { - mtpProp[i].valueInt = valueInt; - mtpProp[i].valueStr = valueStr; - mtpProp[i].dataType = dataType; - return; - } - } - addProperty(property, valueInt, valueStr, dataType); -} - -std::vector& Node::getMtpProps() { - return mtpProp; -} - -void Node::addProperties(const std::string& path, int storageID) { - MTPD("addProperties: handle: %u, filename: '%s'\n", handle, getName().c_str()); - struct stat st; - int mFormat = 0; - uint64_t puid = ((uint64_t)storageID << 32) + handle; - off_t file_size = 0; - - mFormat = MTP_FORMAT_UNDEFINED; // file - if (lstat(path.c_str(), &st) == 0) { - file_size = st.st_size; - if (S_ISDIR(st.st_mode)) - mFormat = MTP_FORMAT_ASSOCIATION; // folder - } - - // TODO: don't store properties with constant values at all, add them at query time instead - addProperty(MTP_PROPERTY_STORAGE_ID, storageID, "", MTP_TYPE_UINT32); - addProperty(MTP_PROPERTY_OBJECT_FORMAT, mFormat, "", MTP_TYPE_UINT16); - addProperty(MTP_PROPERTY_PROTECTION_STATUS, 0, "", MTP_TYPE_UINT16); - addProperty(MTP_PROPERTY_OBJECT_SIZE, file_size, "", MTP_TYPE_UINT64); - addProperty(MTP_PROPERTY_OBJECT_FILE_NAME, 0, getName().c_str(), MTP_TYPE_STR); - addProperty(MTP_PROPERTY_DATE_MODIFIED, st.st_mtime, "", MTP_TYPE_UINT64); - addProperty(MTP_PROPERTY_PARENT_OBJECT, parent, "", MTP_TYPE_UINT32); - addProperty(MTP_PROPERTY_PERSISTENT_UID, puid, "", MTP_TYPE_UINT128); - // TODO: we can't really support persistent UIDs without a persistent DB. - // probably a combination of volume UUID + st_ino would come close. - // doesn't help for fs with no native inodes numbers like fat though... - // however, Microsoft's own impl (Zune, etc.) does not support persistent UIDs either - addProperty(MTP_PROPERTY_NAME, 0, getName().c_str(), MTP_TYPE_STR); - addProperty(MTP_PROPERTY_DISPLAY_NAME, 0, getName().c_str(), MTP_TYPE_STR); - addProperty(MTP_PROPERTY_DATE_ADDED, st.st_mtime, "", MTP_TYPE_UINT64); - addProperty(MTP_PROPERTY_DESCRIPTION, 0, "", MTP_TYPE_STR); - addProperty(MTP_PROPERTY_ARTIST, 0, "", MTP_TYPE_STR); - addProperty(MTP_PROPERTY_ALBUM_NAME, 0, "", MTP_TYPE_STR); - addProperty(MTP_PROPERTY_ALBUM_ARTIST, 0, "", MTP_TYPE_STR); - addProperty(MTP_PROPERTY_TRACK, 0, "", MTP_TYPE_UINT16); - addProperty(MTP_PROPERTY_ORIGINAL_RELEASE_DATE, 2014, "", MTP_TYPE_UINT64); // TODO: extract year from st.st_mtime? - addProperty(MTP_PROPERTY_DURATION, 0, "", MTP_TYPE_UINT32); - addProperty(MTP_PROPERTY_GENRE, 0, "", MTP_TYPE_STR); - addProperty(MTP_PROPERTY_COMPOSER, 0, "", MTP_TYPE_STR); - addProperty(MTP_PROPERTY_ARTIST, 0, "", MTP_TYPE_STR); - addProperty(MTP_PROPERTY_ALBUM_NAME, 0, "", MTP_TYPE_STR); - addProperty(MTP_PROPERTY_DURATION, 0, "", MTP_TYPE_UINT32); - addProperty(MTP_PROPERTY_DESCRIPTION, 0, "", MTP_TYPE_STR); -} diff --git a/mtp/legacy/twrpMtp.cpp b/mtp/legacy/twrpMtp.cpp deleted file mode 100644 index 2b2de01c..00000000 --- a/mtp/legacy/twrpMtp.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include -#include -#include "MtpTypes.h" -#include "MtpPacket.h" -#include "MtpDataPacket.h" -#include "MtpDatabase.h" -#include "MtpRequestPacket.h" -#include "MtpResponsePacket.h" -#include "mtp_MtpDatabase.hpp" -#include "mtp_MtpServer.hpp" -#include "twrpMtp.hpp" -#include "MtpDebug.h" - -#ifdef TWRPMTP -static void usage(std::string prg) { - printf("Usage: %s \n", prg.c_str()); - printf("Options:\n"); - printf("\t-h, --help\t\tShow Usage\n"); - printf("\t-s1, --storage1 /path/to/dir\t\tDestination to first storage directory\n"); - printf("\t-s2, --storage2 /path/to/dir\t\tDestination to first storage directory\n"); - printf("\t-sN, --storageN /path/to/dir\t\tDestination to first storage directory\n"); -} - -int main(int argc, char* argv[]) { - printf("argc: %d\n", argc); - if (argc < 2) { - usage(argv[0]); - return 1; - } - - std::vector storages; - - for (int i = 1; i < argc; ++i) { - std::string arg = argv[i]; - if ((arg == "-h") || (arg == "--help")) { - usage(argv[0]); - } - else { - storages.push_back(arg); - } - } - printf("starting\n"); - twmtp_MtpServer* mtp = new twmtp_MtpServer(); - mtp->set_storages(storages); - mtp->start(); - return 0; -} -#endif //def TWRPMTP - -twrpMtp::twrpMtp(int debug_enabled) { - if (debug_enabled) - MtpDebug::enableDebug(); - mtpstorages = new storages; - mtp_read_pipe = -1; -} - -int twrpMtp::start(void) { - MTPI("Starting MTP\n"); - twmtp_MtpServer *mtp = new twmtp_MtpServer(); - mtp->set_storages(mtpstorages); - mtp->set_read_pipe(mtp_read_pipe); - mtp->start(); - return 0; -} - -pthread_t twrpMtp::threadserver(void) { - pthread_t thread; - ThreadPtr mtpptr = &twrpMtp::start; - PThreadPtr p = *(PThreadPtr*)&mtpptr; - pthread_create(&thread, NULL, p, this); - return thread; -} - -pid_t twrpMtp::forkserver(int mtppipe[2]) { - pid_t pid; - if ((pid = fork()) == -1) { - MTPE("MTP fork failed.\n"); - return 0; - } - if (pid == 0) { - // Child process - close(mtppipe[1]); // Child closes write side - mtp_read_pipe = mtppipe[0]; - start(); - MTPD("MTP child process exited.\n"); - close(mtppipe[0]); - _exit(0); - } else { - return pid; - } - return 0; -} - -void twrpMtp::addStorage(std::string display, std::string path, int mtpid, uint64_t maxFileSize) { - s = new storage; - s->display = display; - s->mount = path; - s->mtpid = mtpid; - s->maxFileSize = maxFileSize; - MTPD("twrpMtp mtpid: %d\n", s->mtpid); - mtpstorages->push_back(s); -} diff --git a/mtp/legacy/twrpMtp.hpp b/mtp/legacy/twrpMtp.hpp deleted file mode 100644 index 9ad270c7..00000000 --- a/mtp/legacy/twrpMtp.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TWRPMTP_HPP -#define TWRPMTP_HPP - -#include -#include -#include -#include -#include -#include -#include "MtpTypes.h" -#include "MtpPacket.h" -#include "MtpDataPacket.h" -#include "MtpDatabase.h" -#include "MtpRequestPacket.h" -#include "MtpResponsePacket.h" -#include "mtp_MtpDatabase.hpp" - -class twrpMtp { - public: - twrpMtp(int debug_enabled = 0); - pthread_t threadserver(void); - pid_t forkserver(int mtppipe[2]); - void addStorage(std::string display, std::string path, int mtpid, uint64_t maxFileSize); - private: - int start(void); - typedef int (twrpMtp::*ThreadPtr)(void); - typedef void* (*PThreadPtr)(void *); - storages *mtpstorages; - storage *s; - int mtp_read_pipe; -}; -#endif diff --git a/openaes/Android.mk b/openaes/Android.mk old mode 100644 new mode 100755 index a628784a..d74ea3bc --- a/openaes/Android.mk +++ b/openaes/Android.mk @@ -11,7 +11,7 @@ ifneq ($(TW_EXCLUDE_ENCRYPTED_BACKUPS), true) LOCAL_MODULE:=openaes LOCAL_MODULE_TAGS:= optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SHARED_LIBRARIES = libopenaes libc include $(BUILD_EXECUTABLE) diff --git a/orscmd/Android.mk b/orscmd/Android.mk old mode 100644 new mode 100755 index ad7c67be..42f918ac --- a/orscmd/Android.mk +++ b/orscmd/Android.mk @@ -15,5 +15,5 @@ LOCAL_MODULE_STEM := twrp LOCAL_MODULE_TAGS:= optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES LOCAL_PACK_MODULE_RELOCATIONS := false -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin include $(BUILD_EXECUTABLE) diff --git a/orscmd/orscmd.h b/orscmd/orscmd.h old mode 100644 new mode 100755 index f186add8..e88d9a5a --- a/orscmd/orscmd.h +++ b/orscmd/orscmd.h @@ -16,7 +16,7 @@ #ifndef __ORSCMD_H #define __ORSCMD_H -#define ORS_INPUT_FILE "/sbin/orsin" -#define ORS_OUTPUT_FILE "/sbin/orsout" +#define ORS_INPUT_FILE "/system/bin/orsin" +#define ORS_OUTPUT_FILE "/system/bin/orsout" #endif //__ORSCMD_H diff --git a/ozip_decrypt/Android.mk b/ozip_decrypt/Android.mk old mode 100644 new mode 100755 index 161cae88..8d5da483 --- a/ozip_decrypt/Android.mk +++ b/ozip_decrypt/Android.mk @@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := ozip_decrypt -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := ozip_decrypt.cpp diff --git a/partition.cpp b/partition.cpp index e76e9553..a8a8e459 100755 --- a/partition.cpp +++ b/partition.cpp @@ -1460,11 +1460,11 @@ bool TWPartition::Mount(bool Display_Error) { // Check the current file system before mounting Check_FS_Type(); - if (Current_File_System == "exfat" && TWFunc::Path_Exists("/sbin/exfat-fuse")) { - string cmd = "/sbin/exfat-fuse -o big_writes,max_read=131072,max_write=131072 " + Actual_Block_Device + " " + Mount_Point; + if (Current_File_System == "exfat" && TWFunc::Path_Exists("/system/bin/exfat-fuse")) { + string cmd = "/system/bin/exfat-fuse -o big_writes,max_read=131072,max_write=131072 " + Actual_Block_Device + " " + Mount_Point; LOGINFO("cmd: %s\n", cmd.c_str()); string result; - if (TWFunc::Exec_Cmd(cmd, result) != 0) { + if (TWFunc::Exec_Cmd(cmd, result, false) != 0) { LOGINFO("exfat-fuse failed to mount with result '%s', trying vfat\n", result.c_str()); Current_File_System = "vfat"; } else { @@ -1478,19 +1478,19 @@ bool TWPartition::Mount(bool Display_Error) { } } - if (Current_File_System == "ntfs" && (TWFunc::Path_Exists("/sbin/ntfs-3g") || TWFunc::Path_Exists("/sbin/mount.ntfs"))) { + if (Current_File_System == "ntfs" && (TWFunc::Path_Exists("/system/bin/ntfs-3g") || TWFunc::Path_Exists("/system/bin/mount.ntfs"))) { string cmd; string Ntfsmount_Binary = ""; - if (TWFunc::Path_Exists("/sbin/ntfs-3g")) + if (TWFunc::Path_Exists("/system/bin/ntfs-3g")) Ntfsmount_Binary = "ntfs-3g"; - else if (TWFunc::Path_Exists("/sbin/mount.ntfs")) + else if (TWFunc::Path_Exists("/system/bin/mount.ntfs")) Ntfsmount_Binary = "mount.ntfs"; if (Mount_Read_Only) - cmd = "/sbin/" + Ntfsmount_Binary + " -o ro " + Actual_Block_Device + " " + Mount_Point; + cmd = "/system/bin/" + Ntfsmount_Binary + " -o ro " + Actual_Block_Device + " " + Mount_Point; else - cmd = "/sbin/" + Ntfsmount_Binary + " " + Actual_Block_Device + " " + Mount_Point; + cmd = "/system/bin/" + Ntfsmount_Binary + " " + Actual_Block_Device + " " + Mount_Point; LOGINFO("cmd: '%s'\n", cmd.c_str()); if (TWFunc::Exec_Cmd(cmd) == 0) { @@ -1579,7 +1579,7 @@ bool TWPartition::Mount(bool Display_Error) { Update_Size(Display_Error); if (!Symlink_Mount_Point.empty() && TWFunc::Path_Exists(Symlink_Path)) { - string Command = "mount -o bind '" + Symlink_Path + "' '" + Symlink_Mount_Point + "'"; + string Command = "/system/bin/mount -o bind '" + Symlink_Path + "' '" + Symlink_Mount_Point + "'"; TWFunc::Exec_Cmd(Command); } @@ -1747,15 +1747,15 @@ bool TWPartition::Wipe_AndSec(void) { bool TWPartition::Can_Repair() { if (Mount_Read_Only) return false; - if (Current_File_System == "vfat" && TWFunc::Path_Exists("/sbin/fsck.fat")) + if (Current_File_System == "vfat" && TWFunc::Path_Exists("/system/bin/fsck.fat")) return true; - else if ((Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") && TWFunc::Path_Exists("/sbin/e2fsck")) + else if ((Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") && TWFunc::Path_Exists("/system/bin/e2fsck")) return true; - else if (Current_File_System == "exfat" && TWFunc::Path_Exists("/sbin/fsck.exfat")) + else if (Current_File_System == "exfat" && TWFunc::Path_Exists("/system/bin/fsck.exfat")) return true; - else if (Current_File_System == "f2fs" && TWFunc::Path_Exists("/sbin/fsck.f2fs")) + else if (Current_File_System == "f2fs" && TWFunc::Path_Exists("/system/bin/fsck.f2fs")) return true; - else if (Current_File_System == "ntfs" && (TWFunc::Path_Exists("/sbin/ntfsfix") || TWFunc::Path_Exists("/sbin/fsck.ntfs"))) + else if (Current_File_System == "ntfs" && (TWFunc::Path_Exists("/system/bin/ntfsfix") || TWFunc::Path_Exists("/system/bin/fsck.ntfs"))) return true; return false; } @@ -1764,7 +1764,7 @@ bool TWPartition::Repair() { string command; if (Current_File_System == "vfat") { - if (!TWFunc::Path_Exists("/sbin/fsck.fat")) { + if (!TWFunc::Path_Exists("/system/bin/fsck.fat")) { gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("fsck.fat")); return false; } @@ -1772,7 +1772,7 @@ bool TWPartition::Repair() { return false; gui_msg(Msg("repairing_using=Repairing {1} using {2}...")(Display_Name)("fsck.fat")); Find_Actual_Block_Device(); - command = "/sbin/fsck.fat -y " + Actual_Block_Device; + command = "/system/bin/fsck.fat -y " + Actual_Block_Device; LOGINFO("Repair command: %s\n", command.c_str()); if (TWFunc::Exec_Cmd(command) == 0) { gui_msg("done=Done."); @@ -1783,7 +1783,7 @@ bool TWPartition::Repair() { } } if (Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") { - if (!TWFunc::Path_Exists("/sbin/e2fsck")) { + if (!TWFunc::Path_Exists("/system/bin/e2fsck")) { gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("e2fsck")); return false; } @@ -1791,7 +1791,7 @@ bool TWPartition::Repair() { return false; gui_msg(Msg("repairing_using=Repairing {1} using {2}...")(Display_Name)("e2fsck")); Find_Actual_Block_Device(); - command = "/sbin/e2fsck -fp " + Actual_Block_Device; + command = "/system/bin/e2fsck -fp " + Actual_Block_Device; LOGINFO("Repair command: %s\n", command.c_str()); if (TWFunc::Exec_Cmd(command) == 0) { gui_msg("done=Done."); @@ -1802,7 +1802,7 @@ bool TWPartition::Repair() { } } if (Current_File_System == "exfat") { - if (!TWFunc::Path_Exists("/sbin/fsck.exfat")) { + if (!TWFunc::Path_Exists("/system/bin/fsck.exfat")) { gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("fsck.exfat")); return false; } @@ -1810,7 +1810,7 @@ bool TWPartition::Repair() { return false; gui_msg(Msg("repairing_using=Repairing {1} using {2}...")(Display_Name)("fsck.exfat")); Find_Actual_Block_Device(); - command = "/sbin/fsck.exfat " + Actual_Block_Device; + command = "/system/bin/fsck.exfat " + Actual_Block_Device; LOGINFO("Repair command: %s\n", command.c_str()); if (TWFunc::Exec_Cmd(command) == 0) { gui_msg("done=Done."); @@ -1821,7 +1821,7 @@ bool TWPartition::Repair() { } } if (Current_File_System == "f2fs") { - if (!TWFunc::Path_Exists("/sbin/fsck.f2fs")) { + if (!TWFunc::Path_Exists("/system/bin/fsck.f2fs")) { gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("fsck.f2fs")); return false; } @@ -1829,7 +1829,7 @@ bool TWPartition::Repair() { return false; gui_msg(Msg("repairing_using=Repairing {1} using {2}...")(Display_Name)("fsck.f2fs")); Find_Actual_Block_Device(); - command = "/sbin/fsck.f2fs " + Actual_Block_Device; + command = "/system/bin/fsck.f2fs " + Actual_Block_Device; LOGINFO("Repair command: %s\n", command.c_str()); if (TWFunc::Exec_Cmd(command) == 0) { gui_msg("done=Done."); @@ -1841,9 +1841,9 @@ bool TWPartition::Repair() { } if (Current_File_System == "ntfs") { string Ntfsfix_Binary; - if (TWFunc::Path_Exists("/sbin/ntfsfix")) + if (TWFunc::Path_Exists("/system/bin/ntfsfix")) Ntfsfix_Binary = "ntfsfix"; - else if (TWFunc::Path_Exists("/sbin/fsck.ntfs")) + else if (TWFunc::Path_Exists("/system/bin/fsck.ntfs")) Ntfsfix_Binary = "fsck.ntfs"; else { gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("ntfsfix")); @@ -1853,7 +1853,7 @@ bool TWPartition::Repair() { return false; gui_msg(Msg("repairing_using=Repairing {1} using {2}...")(Display_Name)(Ntfsfix_Binary)); Find_Actual_Block_Device(); - command = "/sbin/" + Ntfsfix_Binary + " " + Actual_Block_Device; + command = "/system/bin/" + Ntfsfix_Binary + " " + Actual_Block_Device; LOGINFO("Repair command: %s\n", command.c_str()); if (TWFunc::Exec_Cmd(command) == 0) { gui_msg("done=Done."); @@ -1869,7 +1869,7 @@ bool TWPartition::Repair() { bool TWPartition::Can_Resize() { if (Mount_Read_Only) return false; - if ((Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") && TWFunc::Path_Exists("/sbin/resize2fs")) + if ((Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") && TWFunc::Path_Exists("/system/bin/resize2fs")) return true; return false; } @@ -1883,7 +1883,7 @@ bool TWPartition::Resize() { gui_msg(Msg(msg::kError, "cannot_resize=Cannot resize {1}.")(Display_Name)); return false; } - if (!TWFunc::Path_Exists("/sbin/resize2fs")) { + if (!TWFunc::Path_Exists("/system/bin/resize2fs")) { LOGINFO("resize2fs does not exist! Cannot resize!\n"); gui_msg(Msg(msg::kError, "cannot_resize=Cannot resize {1}.")(Display_Name)); return false; @@ -1894,7 +1894,7 @@ bool TWPartition::Resize() { return false; gui_msg(Msg("resizing=Resizing {1} using {2}...")(Display_Name)("resize2fs")); Find_Actual_Block_Device(); - command = "/sbin/resize2fs " + Actual_Block_Device; + command = "/system/bin/resize2fs " + Actual_Block_Device; if (Length != 0) { unsigned long long Actual_Size = IOCTL_Get_Block_Size(); if (Actual_Size == 0) @@ -2101,9 +2101,9 @@ bool TWPartition::Wipe_EXTFS(string File_System) { return false; #if PLATFORM_SDK_VERSION < 28 - if (!TWFunc::Path_Exists("/sbin/mke2fs")) + if (!TWFunc::Path_Exists("/system/bin/mke2fs")) #else - if (!TWFunc::Path_Exists("/sbin/mke2fs") || !TWFunc::Path_Exists("/sbin/e2fsdroid")) + if (!TWFunc::Path_Exists("/system/bin/mke2fs") || !TWFunc::Path_Exists("/system/bin/e2fsdroid")) #endif return Wipe_RMRF(); @@ -2151,7 +2151,7 @@ bool TWPartition::Wipe_EXTFS(string File_System) { return false; } - if (TWFunc::Path_Exists("/sbin/e2fsdroid")) { + if (TWFunc::Path_Exists("/system/bin/e2fsdroid")) { const string& File_Contexts_Entry = (Mount_Point == "/system_root" ? "/" : Mount_Point); char *secontext = NULL; if (!selinux_handle || selabel_lookup(selinux_handle, &secontext, File_Contexts_Entry.c_str(), S_IFDIR) < 0) { @@ -2247,7 +2247,7 @@ bool TWPartition::Wipe_FAT() { if (!UnMount(true)) return false; - if (TWFunc::Path_Exists("/sbin/mkfs.fat")) { + if (TWFunc::Path_Exists("/system/bin/mkfs.fat")) { gui_msg(Msg("formatting_using=Formatting {1} using {2}...")(Display_Name)("mkfs.fat")); Find_Actual_Block_Device(); command = "mkfs.fat " + Actual_Block_Device; @@ -2273,7 +2273,7 @@ bool TWPartition::Wipe_EXFAT() { if (!UnMount(true)) return false; - if (TWFunc::Path_Exists("/sbin/mkexfatfs")) { + if (TWFunc::Path_Exists("/system/bin/mkexfatfs")) { gui_msg(Msg("formatting_using=Formatting {1} using {2}...")(Display_Name)("mkexfatfs")); Find_Actual_Block_Device(); command = "mkexfatfs " + Actual_Block_Device; @@ -2345,10 +2345,10 @@ bool TWPartition::Wipe_F2FS() { if (!UnMount(true)) return false; - if (TWFunc::Path_Exists("/sbin/mkfs.f2fs")) - f2fs_bin = "/sbin/mkfs.f2fs"; - else if (TWFunc::Path_Exists("/sbin/make_f2fs")) - f2fs_bin = "/sbin/make_f2fs"; + if (TWFunc::Path_Exists("/system/bin/mkfs.f2fs")) + f2fs_bin = "/system/bin/mkfs.f2fs"; + else if (TWFunc::Path_Exists("/system/bin/make_f2fs")) + f2fs_bin = "/system/bin/make_f2fs"; else { LOGINFO("mkfs.f2fs binary not found, using rm -rf to wipe.\n"); return Wipe_RMRF(); @@ -2373,7 +2373,7 @@ bool TWPartition::Wipe_F2FS() { char dev_sz_str[48]; sprintf(dev_sz_str, "%llu", (dev_sz / 4096)); command = f2fs_bin + " -d1 -f -O encrypt -O quota -O verity -w 4096 " + Actual_Block_Device + " " + dev_sz_str; - if (TWFunc::Path_Exists("/sbin/sload.f2fs")) { + if (TWFunc::Path_Exists("/system/bin/sload.f2fs")) { command += " && sload.f2fs -t /data " + Actual_Block_Device; } @@ -2406,16 +2406,16 @@ bool TWPartition::Wipe_NTFS() { if (!UnMount(true)) return false; - if (TWFunc::Path_Exists("/sbin/mkntfs")) + if (TWFunc::Path_Exists("/system/bin/mkntfs")) Ntfsmake_Binary = "mkntfs"; - else if (TWFunc::Path_Exists("/sbin/mkfs.ntfs")) + else if (TWFunc::Path_Exists("/system/bin/mkfs.ntfs")) Ntfsmake_Binary = "mkfs.ntfs"; else return false; gui_msg(Msg("formatting_using=Formatting {1} using {2}...")(Display_Name)(Ntfsmake_Binary)); Find_Actual_Block_Device(); - command = "/sbin/" + Ntfsmake_Binary + " " + Actual_Block_Device; + command = "/system/bin/" + Ntfsmake_Binary + " " + Actual_Block_Device; if (TWFunc::Exec_Cmd(command) == 0) { Recreate_AndSec_Folder(); gui_msg("done=Done."); @@ -3398,4 +3398,16 @@ void TWPartition::Set_Can_Be_Backed_Up(bool val) { void TWPartition::Set_Can_Be_Wiped(bool val) { Can_Be_Wiped = val; Wipe_Available_in_GUI = val; +} + +std::string TWPartition::Get_Backup_FileName() { + return Backup_FileName; +} + +std::string TWPartition::Get_Display_Name() { + return Display_Name; +} + +bool TWPartition::Is_SlotSelect() { + return SlotSelect; } \ No newline at end of file diff --git a/partitionmanager.cpp b/partitionmanager.cpp index efcaed88..7cc126f4 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -67,6 +67,7 @@ #include "gui/gui.hpp" #include "progresstracking.hpp" #include "twrpDigestDriver.hpp" +#include "twrpRepacker.hpp" #include "adbbu/libtwadbbu.hpp" #ifdef TW_HAS_MTP @@ -1420,7 +1421,7 @@ int TWPartitionManager::Factory_Reset(void) { ret = false; } } - TWFunc::check_and_run_script("/sbin/factoryreset.sh", "Factory Reset Script"); + TWFunc::check_and_run_script("/system/bin/factoryreset.sh", "Factory Reset Script"); return ret; } @@ -2584,6 +2585,7 @@ bool TWPartitionManager::Remove_MTP_Storage(unsigned int Storage_ID) { } bool TWPartitionManager::Flash_Image(string& path, string& filename) { + twrpRepacker repacker; int partition_count = 0; TWPartition* flash_part = NULL; string Flash_List, flash_path, full_filename; @@ -2617,7 +2619,7 @@ bool TWPartitionManager::Flash_Image(string& path, string& filename) { Repack_Options.Disable_Verity = false; Repack_Options.Disable_Force_Encrypt = false; Repack_Options.Backup_First = DataManager::GetIntValue("tw_repack_backup_first") != 0; - return Repack_Images(full_filename, Repack_Options); + return repacker.Repack_Image_And_Flash(full_filename, Repack_Options); } PartitionSettings part_settings; part_settings.Backup_Folder = path; @@ -3108,162 +3110,6 @@ bool TWPartitionManager::Prepare_Empty_Folder(const std::string& Folder) { return TWFunc::Recursive_Mkdir(Folder); } -bool TWPartitionManager::Prepare_Repack(TWPartition* Part, const std::string& Temp_Folder_Destination, const bool Create_Backup, const std::string& Backup_Name) { - if (!Part) { - LOGERR("Partition was null!\n"); - return false; - } - if (!Prepare_Empty_Folder(Temp_Folder_Destination)) - return false; - std::string target_image = Temp_Folder_Destination + "boot.img"; - PartitionSettings part_settings; - part_settings.Part = Part; - if (Create_Backup) { - if (Check_Backup_Name(Backup_Name, true, false) != 0) - return false; - DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, part_settings.Backup_Folder); - part_settings.Backup_Folder = part_settings.Backup_Folder + "/" + TWFunc::Get_Current_Date() + " " + Backup_Name + "/"; - if (!TWFunc::Recursive_Mkdir(part_settings.Backup_Folder)) - return false; - } else - part_settings.Backup_Folder = Temp_Folder_Destination; - part_settings.adbbackup = false; - part_settings.generate_digest = false; - part_settings.generate_md5 = false; - part_settings.PM_Method = PM_BACKUP; - part_settings.progress = NULL; - pid_t not_a_pid = 0; - if (!Part->Backup(&part_settings, ¬_a_pid)) - return false; - std::string backed_up_image = part_settings.Backup_Folder; - backed_up_image += Part->Backup_FileName; - target_image = Temp_Folder_Destination + "boot.img"; - if (Create_Backup) { - std::string source = part_settings.Backup_Folder + Part->Backup_FileName; - if (TWFunc::copy_file(source, target_image, 0644) != 0) { - LOGERR("Failed to copy backup file '%s' to temp folder target '%s'\n", source.c_str(), target_image.c_str()); - return false; - } - } else { - if (rename(backed_up_image.c_str(), target_image.c_str()) != 0) { - LOGERR("Failed to rename '%s' to '%s'\n", backed_up_image.c_str(), target_image.c_str()); - return false; - } - } - return Prepare_Repack(target_image, Temp_Folder_Destination, false, false); -} - -bool TWPartitionManager::Prepare_Repack(const std::string& Source_Path, const std::string& Temp_Folder_Destination, const bool Copy_Source, const bool Create_Destination) { - if (Create_Destination) { - if (!Prepare_Empty_Folder(Temp_Folder_Destination)) - return false; - } - if (Copy_Source) { - std::string destination = Temp_Folder_Destination + "/boot.img"; - if (TWFunc::copy_file(Source_Path, destination, 0644)) - return false; - } - std::string command = "cd " + Temp_Folder_Destination + " && /sbin/magiskboot unpack -h '" + Source_Path +"'"; - if (TWFunc::Exec_Cmd(command) != 0) { - LOGINFO("Error unpacking %s!\n", Source_Path.c_str()); - gui_msg(Msg(msg::kError, "unpack_error=Error unpacking image.")); - return false; - } - return true; -} - -bool TWPartitionManager::Repack_Images(const std::string& Target_Image, const struct Repack_Options_struct& Repack_Options) { - if (!TWFunc::Path_Exists("/sbin/magiskboot")) { - LOGERR("Image repacking tool not present in this TWRP build!"); - return false; - } - DataManager::SetProgress(0); - TWPartition* part = PartitionManager.Find_Partition_By_Path("/boot"); - if (part) - gui_msg(Msg("unpacking_image=Unpacking {1}...")(part->Display_Name)); - else { - gui_msg(Msg(msg::kError, "unable_to_locate=Unable to locate {1}.")("/boot")); - return false; - } - if (!PartitionManager.Prepare_Repack(part, REPACK_ORIG_DIR, Repack_Options.Backup_First, gui_lookup("repack", "Repack"))) - return false; - DataManager::SetProgress(.25); - gui_msg(Msg("unpacking_image=Unpacking {1}...")(Target_Image)); - if (!PartitionManager.Prepare_Repack(Target_Image, REPACK_NEW_DIR, true)) - return false; - DataManager::SetProgress(.5); - gui_msg(Msg("repacking_image=Repacking {1}...")(part->Display_Name)); - std::string path = REPACK_NEW_DIR; - if (Repack_Options.Type == REPLACE_KERNEL) { - // When we replace the kernel, what we really do is copy the boot partition ramdisk into the new image's folder - if (TWFunc::copy_file(REPACK_ORIG_DIR "ramdisk.cpio", REPACK_NEW_DIR "ramdisk.cpio", 0644)) { - LOGERR("Failed to copy ramdisk\n"); - return false; - } - } else if (Repack_Options.Type == REPLACE_RAMDISK) { - // Repack the ramdisk - if (TWFunc::copy_file(REPACK_NEW_DIR "ramdisk.cpio", REPACK_ORIG_DIR "ramdisk.cpio", 0644)) { - LOGERR("Failed to copy ramdisk\n"); - return false; - } - path = REPACK_ORIG_DIR; - } else { - LOGERR("Invalid repacking options specified\n"); - return false; - } - if (Repack_Options.Disable_Verity) - LOGERR("Disabling verity is not implemented yet\n"); - if (Repack_Options.Disable_Force_Encrypt) - LOGERR("Disabling force encrypt is not implemented yet\n"); - std::string command = "cd " + path + " && /sbin/magiskboot repack " + path + "boot.img"; - if (TWFunc::Exec_Cmd(command) != 0) { - gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); - return false; - } - DataManager::SetProgress(.75); - std::string file = "new-boot.img"; - DataManager::SetValue("tw_flash_partition", "/boot;"); - if (!PartitionManager.Flash_Image(path, file)) { - LOGINFO("Error flashing new image\n"); - return false; - } - DataManager::SetProgress(1); - TWFunc::removeDir(REPACK_ORIG_DIR, false); - if (part->SlotSelect && Repack_Options.Type == REPLACE_RAMDISK) { - LOGINFO("Switching slots to flash ramdisk to both partitions\n"); - string Current_Slot = Get_Active_Slot_Display(); - if (Current_Slot == "A") - Set_Active_Slot("B"); - else - Set_Active_Slot("A"); - DataManager::SetProgress(.25); - if (!PartitionManager.Prepare_Repack(part, REPACK_ORIG_DIR, Repack_Options.Backup_First, gui_lookup("repack", "Repack"))) - return false; - if (TWFunc::copy_file(REPACK_NEW_DIR "ramdisk.cpio", REPACK_ORIG_DIR "ramdisk.cpio", 0644)) { - LOGERR("Failed to copy ramdisk\n"); - return false; - } - path = REPACK_ORIG_DIR; - command = "cd " + path + " && /sbin/magiskboot repack " + path + "boot.img"; - if (TWFunc::Exec_Cmd(command) != 0) { - gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); - return false; - } - DataManager::SetProgress(.75); - std::string file = "new-boot.img"; - DataManager::SetValue("tw_flash_partition", "/boot;"); - if (!PartitionManager.Flash_Image(path, file)) { - LOGINFO("Error flashing new image\n"); - return false; - } - DataManager::SetProgress(1); - TWFunc::removeDir(REPACK_ORIG_DIR, false); - Set_Active_Slot(Current_Slot); - } - TWFunc::removeDir(REPACK_NEW_DIR, false); - return true; -} - bool TWPartitionManager::Prepare_Super_Volume(TWPartition* twrpPart) { Fstab fstab; std::string bare_partition_name; diff --git a/partitions.hpp b/partitions.hpp index 53d40ac0..55a0ac17 100755 --- a/partitions.hpp +++ b/partitions.hpp @@ -76,19 +76,6 @@ struct Flags_Map { char* fstab_line; }; -enum Repack_Type { - REPLACE_NONE = 0, - REPLACE_RAMDISK = 1, - REPLACE_KERNEL = 2, -}; - -struct Repack_Options_struct { - Repack_Type Type; - bool Backup_First; - bool Disable_Verity; - bool Disable_Force_Encrypt; -}; - enum PartitionManager_Op { // PartitionManager Restore Mode for Raw_Read_Write() PM_BACKUP = 0, PM_RESTORE = 1, @@ -160,13 +147,16 @@ public: int Decrypt_Adopted(); void Revert_Adopted(); void Partition_Post_Processing(bool Display_Error); // Apply partition specific settings after fstab processed - void Set_Backup_FileName(string fname); // Set Backup_FileName for partition + void Set_Backup_FileName(string fname); // Set backup filename for partition + std::string Get_Backup_FileName(); // Get the backup filename for the partition string Get_Backup_Name(); // Get Backup_Name for partition bool Decrypt_FBE_DE(); // If FBE is present, backup exclusions are set up and DE decrypt is attempted string Get_Mount_Point(); // Return Mount_Point or directory the current partition is mounted on bool Get_Super_Status(); // Returns true if partition is a super volume mounted partitions void Set_Can_Be_Backed_Up(bool val); // Update whether the partition can be backed up or not void Set_Can_Be_Wiped(bool val); // Update whether the partition can be wiped or not + std::string Get_Display_Name(); // Get the display name in the gui for the partition + bool Is_SlotSelect(); // Return whether the partition is a slot partition or not public: string Current_File_System; // Current file system @@ -384,9 +374,6 @@ public: void read_uevent(); // Reads uevent data into a buffer void close_uevent(); // Closes the uevent netlink socket void Add_Partition(TWPartition* Part); // Adds a new partition to the Partitions vector - bool Prepare_Repack(TWPartition* Part, const std::string& Temp_Folder_Destination, const bool Create_Backup, const std::string& Backup_Name); // Prepares an image for repacking by unpacking it to the temp folder destination - bool Prepare_Repack(const std::string& Source_Path, const std::string& Temp_Folder_Destination, const bool Copy_Source, const bool Create_Destination = true); // Prepares an image for repacking by unpacking it to the temp folder destination - bool Repack_Images(const std::string& Target_Image, const struct Repack_Options_struct& Repack_Options); // Repacks the boot image with a new kernel or a new ramdisk bool Prepare_Super_Volume(TWPartition* twrpPart); // Prepare logical super partition volume for mounting std::string Get_Super_Partition(); // Get Super Partition block device path void Setup_Super_Devices(); // Setup logical dm devices on super partition @@ -411,6 +398,8 @@ private: int mtp_write_fd; pid_t tar_fork_pid; // PID of twrpTar fork Backup_Method_enum Backup_Method; // Method used for backup + std::string original_ramdisk_format; // Ramdisk format of boot partition + std::string repacked_ramdisk_format; // Ramdisk format of boot image to repack from private: std::vector Partitions; // Vector list of all partitions diff --git a/pigz/Android.mk b/pigz/Android.mk old mode 100644 new mode 100755 index ad7f39dd..2875fd1b --- a/pigz/Android.mk +++ b/pigz/Android.mk @@ -5,7 +5,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := pigz LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_CFLAGS := LOCAL_SRC_FILES = pigz.c yarn.c LOCAL_C_INCLUDES += $(LOCAL_PATH) \ @@ -13,9 +13,9 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH) \ LOCAL_SHARED_LIBRARIES += libz libc LOCAL_POST_INSTALL_CMD := \ - $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sbin && \ - ln -sf pigz $(TARGET_RECOVERY_ROOT_OUT)/sbin/gunzip && \ - ln -sf pigz $(TARGET_RECOVERY_ROOT_OUT)/sbin/gzip && \ - ln -sf pigz $(TARGET_RECOVERY_ROOT_OUT)/sbin/unpigz + $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system/bin && \ + ln -sf pigz $(TARGET_RECOVERY_ROOT_OUT)/system/bin/gunzip && \ + ln -sf pigz $(TARGET_RECOVERY_ROOT_OUT)/system/bin/gzip && \ + ln -sf pigz $(TARGET_RECOVERY_ROOT_OUT)/system/bin/unpigz include $(BUILD_EXECUTABLE) diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk index b81c32ba..acb5b78c 100755 --- a/prebuilt/Android.mk +++ b/prebuilt/Android.mk @@ -8,672 +8,436 @@ include $(CLEAR_VARS) LOCAL_MODULE := teamwin LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ # Manage list -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/dump_image -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/flash_image -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/erase_image -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/bu +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/dump_image +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/flash_image +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/erase_image +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/bu -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/sh -else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/sh +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/sh + +LOCAL_POST_INSTALL_CMD += $(hide) if [ -e "$(TARGET_RECOVERY_ROOT_OUT)/system/bin/egrep" ]; then \ + rm $(TARGET_RECOVERY_ROOT_OUT)/system/bin/egrep; fi; ln -s $(TARGET_RECOVERY_ROOT_OUT)/system/bin/grep $(TARGET_RECOVERY_ROOT_OUT)/system/bin/egrep; \ + if [ -e "$(TARGET_RECOVERY_ROOT_OUT)/system/bin/fgrep" ]; then \ + rm $(TARGET_RECOVERY_ROOT_OUT)/system/bin/fgrep; fi; ln -s $(TARGET_RECOVERY_ROOT_OUT)/system/bin/grep $(TARGET_RECOVERY_ROOT_OUT)/system/bin/fgrep; + +ifneq ($(wildcard external/zip/Android.mk),) + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_OPTIONAL_EXECUTABLES)/zip endif -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 23; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/grep - else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/grep - endif - LOCAL_POST_INSTALL_CMD += $(hide) if [ -e "$(TARGET_RECOVERY_ROOT_OUT)/sbin/egrep" ]; then \ - rm $(TARGET_RECOVERY_ROOT_OUT)/sbin/egrep; fi; ln -s $(TARGET_RECOVERY_ROOT_OUT)/sbin/grep $(TARGET_RECOVERY_ROOT_OUT)/sbin/egrep; \ - if [ -e "$(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep" ]; then \ - rm $(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep; fi; ln -s $(TARGET_RECOVERY_ROOT_OUT)/sbin/grep $(TARGET_RECOVERY_ROOT_OUT)/sbin/fgrep; - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 23; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/dd - endif - endif - ifneq ($(wildcard external/zip/Android.mk),) - RELINK_SOURCE_FILES += $(TARGET_OUT_OPTIONAL_EXECUTABLES)/zip - endif - ifneq ($(wildcard external/unzip/Android.mk),) - RELINK_SOURCE_FILES += $(TARGET_OUT_OPTIONAL_EXECUTABLES)/unzip - endif - ifneq ($(wildcard system/core/libziparchive/Android.bp),) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/unzip - else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/unzip - endif - endif - ifneq ($(wildcard external/one-true-awk/Android.bp),) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/awk - endif +ifneq ($(wildcard external/unzip/Android.mk),) + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_OPTIONAL_EXECUTABLES)/unzip +endif +ifneq ($(wildcard system/core/libziparchive/Android.bp),) + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/unzip +endif +ifneq ($(wildcard external/one-true-awk/Android.bp),) + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/awk endif -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/pigz -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/fsck.fat -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/fatlabel -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/mkfs.fat -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 27; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -le 28; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/adbd - else - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/adbd - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/fastbootd - endif -endif -RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/e2fsck -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/e2fsdroid -endif -RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mke2fs -RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/tune2fs -RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/resize2fs -RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/simg2img -ifneq ($(TW_OZIP_DECRYPT_KEY),) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/ozip_decrypt -endif -ifneq ($(TARGET_ARCH), x86_64) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/linker -endif -ifeq ($(TARGET_ARCH), x86_64) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/linker64 -endif -ifeq ($(TARGET_ARCH), arm64) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/linker64 - else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/linker64 - endif -endif +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/adbd +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/fastbootd +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/e2fsck +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/e2fsdroid +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mke2fs +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/tune2fs +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/resize2fs + #RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/twrpmtp -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libc.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libdl.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libm.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libbootloader_message.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libfs_mgr.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libfscrypt.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libgsi.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libkeyutils.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/liblogwrap.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/liblp.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libprocessgroup.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libprocessgroup_setup.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libadbd.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libadbd_services.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libcap.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libminijail.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libunwindstack.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libasyncio.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libcgrouprc.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libbinderthreadstate.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libsquashfs_utils.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libjsoncpp.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libmdnssd.so - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libfec.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libinit.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libdl_android.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libprotobuf-cpp-lite.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libbinder.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libchrome.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libevent.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/keystore - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/keystore_cli_v2 - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/hwservicemanager - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/servicemanager - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/vold_prepare_subdirs - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../vendor/bin/vndservicemanager - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/toybox -else - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libc.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libdl.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libm.so -endif -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcutils.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrecovery.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libusbhost.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libutils.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_com_err.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_e2p.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2fs.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_profile.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_uuid.so -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 27; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_misc.so -endif +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/android.hardware.fastboot@1.0.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/android.hardware.health@1.0.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/android.hardware.health@2.0.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/ld-android.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libc.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libdl.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libm.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libfs_mgr.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libfscrypt.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libgsi.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libkeyutils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/liblogwrap.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/liblp.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libprocessgroup.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libprocessgroup_setup.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libadbd.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libadbd_services.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libcap.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libminijail.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libunwindstack.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libasyncio.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libbinderthreadstate.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libmdnssd.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libinit.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libdl_android.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libprotobuf-cpp-lite.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libbinder.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libchrome.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libevent.so +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/keystore +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/keystore_cli_v2 +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/hwservicemanager +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/servicemanager +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/vold_prepare_subdirs +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../vendor/bin/vndservicemanager +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/toybox +# RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/charger +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/ueventd +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/watchdogd + +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcutils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrecovery.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libusbhost.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libutils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_com_err.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_e2p.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2fs.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_profile.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_uuid.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_misc.so ifneq ($(wildcard external/e2fsprogs/lib/quota/Android.mk),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_quota.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_quota.so endif ifneq ($(wildcard external/e2fsprogs/lib/ext2fs/Android.*),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2fs.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2fs.so endif ifneq ($(wildcard external/e2fsprogs/lib/blkid/Android.*),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_blkid.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_blkid.so endif -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpng.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblog.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libstdc++.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libz.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libminuitwrp.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libminadbd.so -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libminzip.so -endif -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmtdutils.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtar.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtwadbbu.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtwrpdigest.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libutil-linux.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libblkid.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmmcutils.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbmlutils.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libflashutils.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libfusesideload.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbootloader_message_twrp.so -ifeq ($(PLATFORM_SDK_VERSION), 22) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libc++.so -endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0) - # These libraries are no longer present in M - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libstlport.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libgccdemangle.so -endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 23; echo $$?),0) +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpng.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblog.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libstdc++.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libminuitwrp.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libminadbd.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libz.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmtdutils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtar.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtwadbbu.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtwrpdigest.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libutil-linux.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libblkid.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmmcutils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbmlutils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libflashutils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libfusesideload.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbootloader_message_twrp.so + +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so \ +$(if $(WITH_CRYPTO_UTILS),$(TARGET_OUT_SHARED_LIBRARIES)/libcrypto_utils.so) + +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libbacktrace.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libunwind.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbase.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libc++.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libnetd_client.so + +RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/toolbox - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so \ - $(if $(WITH_CRYPTO_UTILS),$(TARGET_OUT_SHARED_LIBRARIES)/libcrypto_utils.so) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpackagelistparser.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblzma.so -endif -ifneq (,$(filter $(PLATFORM_SDK_VERSION), 21 22)) - # libraries from lollipop - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbacktrace.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libunwind.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libunwind-ptrace.so - # Dynamically loaded by lollipop libc and may prevent unmounting system if it is not present in sbin - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libnetd_client.so -else - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 23; echo $$?),0) - # Android M libraries - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/libbacktrace.so - else - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbacktrace.so - endif - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libunwind.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbase.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libc++.so - # Dynamically loaded by libc and may prevent unmounting system if it is not present in sbin - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libnetd_client.so - else - # Not available in lollipop - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcorkscrew.so - endif -endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmincrypttwrp.so -endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/toolbox -else - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/toolbox -endif ifneq ($(TW_OEM_BUILD),true) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/twrp + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/twrp else TW_EXCLUDE_MTP := true endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) -ifneq ($(TW_EXCLUDE_MTP), true) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtwrpmtp-ffs.so -endif -else -ifneq ($(TW_EXCLUDE_MTP), true) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtwrpmtp-legacy.so -endif -endif - -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext4_utils.so -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libaosprecovery.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtwrpmtp-ffs.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext4_utils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libaosprecovery.so ifneq ($(TW_INCLUDE_JPEG),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libjpeg.so -endif -RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libselinux.so -ifeq ($(BUILD_ID), GINGERBREAD) - TW_NO_EXFAT := true + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libjpeg.so endif +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libselinux.so + ifneq ($(TW_NO_EXFAT), true) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/mkexfatfs - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/fsck.exfat - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libexfat_twrp.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libexfat_twrp.so else TW_NO_EXFAT_FUSE := true endif -ifneq ($(TW_NO_EXFAT_FUSE), true) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/exfat-fuse -endif -ifeq ($(TW_INCLUDE_BLOBPACK), true) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/blobpack -endif -ifeq ($(TW_INCLUDE_INJECTTWRP), true) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/injecttwrp -endif -ifeq ($(TW_INCLUDE_DUMLOCK), true) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/htcdumlock -endif + ifeq ($(TW_INCLUDE_CRYPTO), true) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libcryptfsfde.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libdexfile_support.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libf2fs_sparseblock.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../vendor/lib64/libnos_transport.so - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../vendor/lib64/libnos_datagram.so - else - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcryptfsfde.so - endif - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhardware.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libgpt_twrp.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libcryptfsfde.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libdexfile_support.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libf2fs_sparseblock.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libhardware.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/android.hardware.authsecret@1.0.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/android.hardware.oemlock@1.0.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../vendor/lib64/libnos_transport.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../vendor/lib64/libnos_datagram.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.keymaster@3.0.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libgpt_twrp.so ifeq ($(TARGET_HW_DISK_ENCRYPTION),true) ifeq ($(TARGET_CRYPTFS_HW_PATH),) - RELINK_SOURCE_FILES += $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/libcryptfs_hw.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/libcryptfs_hw.so else - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcryptfs_hw.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcryptfs_hw.so endif endif # FBE files ifeq ($(TW_INCLUDE_CRYPTO_FBE), true) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libtwrpfscrypt.so - else - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libe4crypt.so - endif - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libgatekeeper.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_messages.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeystore_binder.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbinder.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libprotobuf-cpp-lite.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libsoftkeymasterdevice.so - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.gatekeeper@1.0.so - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/hwservicemanager - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/avbctl - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/keystore - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/keystore_cli - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/servicemanager - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.system.wifi.keystore@1.0.so - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.0.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.1.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.2.so - endif + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/lib64/libtwrpfscrypt.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libgatekeeper.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_messages.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeystore_binder.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libbinder.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libprotobuf-cpp-lite.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libsoftkeymasterdevice.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.gatekeeper@1.0.so + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/hwservicemanager + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/avbctl + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/keystore + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/keystore_cli + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/servicemanager + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.system.wifi.keystore@1.0.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.0.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.1.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.2.so - ifneq ($(wildcard system/keymaster/keymaster_stl.cpp),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_portable.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_staging.so - endif - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libwifikeystorehal.so - ifneq ($(wildcard hardware/interfaces/weaver/Android.bp),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.weaver@1.0.so - endif - ifneq ($(wildcard hardware/interfaces/weaver/1.0/Android.bp),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.weaver@1.0.so - endif - ifneq ($(wildcard hardware/interfaces/confirmationui/1.0/Android.bp),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.confirmationui@1.0.so - endif - - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhardware_legacy.so - else - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster1.so + ifneq ($(wildcard system/keymaster/keymaster_stl.cpp),) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_portable.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_staging.so endif - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 28; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libsoftkeymaster.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libwifikeystorehal.so + ifneq ($(wildcard hardware/interfaces/weaver/Android.bp),) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.weaver@1.0.so endif - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.keymaster@4.0.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster4support.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeystore_aidl.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeystore_parcelables.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libutilscallstack.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libunwindstack.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libdexfile.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libservices.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_portable.so - endif + ifneq ($(wildcard hardware/interfaces/weaver/1.0/Android.bp),) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.weaver@1.0.so + endif + ifneq ($(wildcard hardware/interfaces/confirmationui/1.0/Android.bp),) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.confirmationui@1.0.so + endif + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libsoftkeymaster.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.keymaster@4.0.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster4support.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeystore_aidl.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeystore_parcelables.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libutilscallstack.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libdexfile.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libservices.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_portable.so # lshal can be useful for seeing if you have things like the keymaster working properly, but it isn't needed for TWRP to work - #RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/lshal - #RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblshal.so - #RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libssl.so - #RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhidl-gen-hash.so + #RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/lshal + #RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblshal.so + #RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libssl.so + #RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhidl-gen-hash.so endif endif ifeq ($(AB_OTA_UPDATER), true) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/update_engine_sideload - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.boot@1.0.so - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/bootctl - ifneq ($(TW_INCLUDE_CRYPTO), true) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhardware.so - endif -endif -ifeq ($(TARGET_USERIMAGES_USE_EXT4), true) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 28; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/make_ext4fs - endif + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/update_engine_sideload + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.boot@1.0.so + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/bootctl endif + ifneq ($(wildcard system/core/libsparse/Android.*),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libsparse.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libsparse.so endif ifneq ($(TW_EXCLUDE_ENCRYPTED_BACKUPS), true) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/openaes - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libopenaes.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libopenaes.so endif ifeq ($(TARGET_USERIMAGES_USE_F2FS), true) - ifeq ($(shell test $(CM_PLATFORM_SDK_VERSION) -ge 4; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkfs.f2fs - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libf2fs.so - else ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/make_f2fs - else - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/mkfs.f2fs - endif - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/sload_f2fs - else - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/sload.f2fs - endif - endif - else ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkfs.f2fs - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libf2fs.so - else ifeq ($(shell test $(PLATFORM_SDK_VERSION) -eq 23; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/mkfs.f2fs - else ifneq (,$(filter $(PLATFORM_SDK_VERSION), 21 22)) - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT_SBIN)/mkfs.f2fs - else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkfs.f2fs - endif - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/fsck.f2fs + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/make_f2fs + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/sload_f2fs endif ifneq ($(wildcard system/core/reboot/Android.*),) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/reboot - else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/reboot - endif + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/reboot endif ifneq ($(TW_DISABLE_TTF), true) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libft2.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libft2.so endif -ifneq ($(TW_RECOVERY_ADDITIONAL_RELINK_FILES),) - RELINK_SOURCE_FILES += $(TW_RECOVERY_ADDITIONAL_RELINK_FILES) +ifneq ($(TW_RECOVERY_ADDITIONAL_RELINK_BINARY_FILES),) + RECOVERY_BINARY_SOURCE_FILES += $(TW_RECOVERY_ADDITIONAL_RELINK_BINARY_FILES) +endif +ifneq ($(TW_RECOVERY_ADDITIONAL_RELINK_LIBRARY_FILES),) + RECOVERY_LIBRARY_SOURCE_FILES += $(TW_RECOVERY_ADDITIONAL_RELINK_LIBRARY_FILES) endif ifneq ($(wildcard external/pcre/Android.mk),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpcre.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpcre.so endif ifeq ($(TW_INCLUDE_NTFS_3G),true) -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mount.ntfs - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/fsck.ntfs - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkfs.ntfs - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libntfs-3g.so - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libfuse-lite.so - else - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libfuse.so - endif + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mount.ntfs + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/fsck.ntfs + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkfs.ntfs + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libntfs-3g.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libfuse-lite.so else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/ntfs-3g - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/ntfsfix - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkntfs -endif + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/ntfs-3g + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/ntfsfix + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkntfs endif ifeq ($(BOARD_HAS_NO_REAL_SDCARD),) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/sgdisk - endif + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/sgdisk endif ifeq ($(TWRP_INCLUDE_LOGCAT), true) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/logcat - else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/logcat - endif + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/logcat ifeq ($(TARGET_USES_LOGD), true) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/logd - else - RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/logd - endif - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libsysutils.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libnl.so - endif - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpcrecpp.so - endif - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblogcat.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcap.so + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_ROOT_OUT)/../system/bin/logd + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libsysutils.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libnl.so endif + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpcrecpp.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblogcat.so + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcap.so endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25; echo $$?),0) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpcre2.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libvndksupport.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhwbinder.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhidlbase.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhidltransport.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.keymaster@3.0.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libziparchive.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_blkid.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_quota.so - - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhidl-gen-utils.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libvintf.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtinyxml2.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hidl.token@1.0.so - ifneq ($(wildcard system/core/libkeyutils/Android.bp),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeyutils.so - endif - ifeq ($(wildcard system/libhidl/transport/HidlTransportUtils.cpp),) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hidl.base@1.0.so - endif +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libvndksupport.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhidlbase.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhidltransport.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.frameworks.stats@1.0.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libziparchive.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_blkid.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_quota.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhidl-gen-utils.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libvintf.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtinyxml2.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hidl.token@1.0.so +ifneq ($(wildcard system/core/libkeyutils/Android.bp),) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeyutils.so endif -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 27; echo $$?),0) - ifeq ($(TARGET_ARCH), arm64) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-aarch64-android.so - endif - ifeq ($(TARGET_ARCH), arm) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-arm-android.so - endif - ifeq ($(TARGET_ARCH), x86_64) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-x86_64-android.so - endif - ifeq ($(TARGET_ARCH), x86) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-i686-android.so - endif - ifeq ($(TARGET_ARCH), mips) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-mips-android.so - endif - ifeq ($(TARGET_ARCH), mips64) - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-mips64-android.so - endif - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblogwrap.so - RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_misc.so +ifeq ($(wildcard system/libhidl/transport/HidlTransportUtils.cpp),) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hidl.base@1.0.so endif +ifeq ($(TARGET_ARCH), arm64) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-aarch64-android.so +endif +ifeq ($(TARGET_ARCH), arm) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-arm-android.so +endif +ifeq ($(TARGET_ARCH), x86_64) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-x86_64-android.so +endif +ifeq ($(TARGET_ARCH), x86) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-i686-android.so +endif +ifeq ($(TARGET_ARCH), mips) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-mips-android.so +endif +ifeq ($(TARGET_ARCH), mips64) + RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libclang_rt.ubsan_standalone-mips64-android.so +endif +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblogwrap.so +RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext2_misc.so -#toybox links -toybox_links := acpi base64 basename bc blockdev cal cat chcon chgrp chmod chown chroot chrt cksum clear \ - cmp comm cp cpio cut date dd devmem df diff dirname dmesg dos2unix du echo env expand expr fallocate \ - false file find flock fmt free fsync getconf getenforce getprop groups gunzip gzip head hostname hwclock i2cdetect \ - i2cdump i2cget i2cset iconv id ifconfig inotifyd insmod install ionice iorenice kill killall ln load_policy \ - log logname losetup ls lsmod lsof lspci lsusb md5sum microcom mkdir mkfifo mknod mkswap mktemp modinfo modprobe \ - more mount mountpoint mv nc netcat netstat nice nl nohup nproc nsenter od paste patch pgrep pidof pkill pmap \ - printenv printf ps pwd readlink realpath renice restorecon rm rmdir rmmod runcon sed sendevent seq setenforce \ - setprop setsid sha1sum sha224sum sha256sum sha384sum sha512sum sleep sort split start stat stop strings stty \ - swapoff swapon sync sysctl tac tail tar taskset tee time timeout top touch tr true truncate tty ulimit \ - umount uname uniq unix2dos unlink unshare uptime usleep uudecode uuencode uuidgen vmstat watch wc which whoami \ - xargs xxd yes zcat -TOYBOX_LINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/system/bin/, $(toybox_links)) - -#relink recovery executables linker to /sbin and move symlinks include $(CLEAR_VARS) -LOCAL_MODULE := relink +LOCAL_MODULE := relink_libraries LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin -LOCAL_POST_INSTALL_CMD += $(RELINK) $(TARGET_RECOVERY_ROOT_OUT)/sbin $(RELINK_SOURCE_FILES) && \ - cp $(TOYBOX_LINKS) $(TARGET_RECOVERY_ROOT_OUT)/sbin/ -TARGET_RELINK_FILES := $(notdir $(RELINK_SOURCE_FILES)) -TARGET_BASE_RELINK_MODULES := $(basename $(TARGET_RELINK_FILES)) -TARGET_RELINK_MODULES := $(filter-out libdexfile, $(TARGET_BASE_RELINK_MODULES)) -LOCAL_REQUIRED_MODULES += $(TARGET_RELINK_MODULES) +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ +LOCAL_POST_INSTALL_CMD += $(RELINK) $(TARGET_RECOVERY_ROOT_OUT)/system/lib64 $(RECOVERY_LIBRARY_SOURCE_FILES) +TARGET_LIBRARY_RELINK_FILES := $(notdir $(RECOVERY_LIBRARY_SOURCE_FILES)) +TARGET_BASE_LIBRARY_RELINK_MODULES := $(basename $(TARGET_LIBRARY_RELINK_FILES)) +TARGET_RELINK_LIBRARY_MODULES := $(filter-out libdexfile, $(TARGET_BASE_LIBRARY_RELINK_MODULES)) +LOCAL_REQUIRED_MODULES += $(TARGET_RELINK_LIBRARY_MODULES) include $(BUILD_PHONY_PACKAGE) -#relink init + +include $(CLEAR_VARS) +LOCAL_MODULE := relink_binaries +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ +LOCAL_POST_INSTALL_CMD += $(RELINK) $(TARGET_RECOVERY_ROOT_OUT)/system/bin $(RECOVERY_BINARY_SOURCE_FILES) +TARGET_BINARY_RELINK_FILES := $(notdir $(RECOVERY_BINARY_SOURCE_FILES)) +LOCAL_REQUIRED_MODULES += $(TARGET_BINARY_RELINK_FILES) +include $(BUILD_PHONY_PACKAGE) + +#build out TWRP ramdisk include $(CLEAR_VARS) LOCAL_MODULE := twrp_ramdisk LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT) -RELINK_INIT := $(TARGET_RECOVERY_ROOT_OUT)/system/bin/init -LOCAL_POST_INSTALL_CMD += $(RELINK) $(TARGET_RECOVERY_ROOT_OUT)/ $(RELINK_INIT) && \ - cp $(TARGET_RECOVERY_ROOT_OUT)/system/bin/ueventd $(TARGET_RECOVERY_ROOT_OUT)/sbin/ && \ - ln -sf /init $(TARGET_RECOVERY_ROOT_OUT)/sbin/init && \ - ln -sf /init $(TARGET_RECOVERY_ROOT_OUT)/system/bin/init && \ +LOCAL_POST_INSTALL_CMD += \ + mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sbin; ln -sf /system/bin/sh $(TARGET_RECOVERY_ROOT_OUT)/sbin/sh && \ mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system/etc/selinux/ && \ cp $(TARGET_ROOT_OUT)/../system/etc/selinux/plat_service_contexts $(TARGET_RECOVERY_ROOT_OUT)/system/etc/selinux/plat_service_contexts && \ cp $(TARGET_ROOT_OUT)/../system/etc/selinux/plat_hwservice_contexts $(TARGET_RECOVERY_ROOT_OUT)/system/etc/selinux/plat_hwservice_contexts && \ cp $(TARGET_ROOT_OUT)/../vendor/etc/selinux/vndservice_contexts $(TARGET_RECOVERY_ROOT_OUT)/system/etc/selinux/vndservice_contexts && \ cp $(TARGET_ROOT_OUT)/../vendor/etc/selinux/vendor_hwservice_contexts $(TARGET_RECOVERY_ROOT_OUT)/system/etc/selinux/vendor_hwservice_contexts -LOCAL_REQUIRED_MODULES := init_second_stage.recovery reboot.recovery plat_service_contexts plat_hardware_contexts vndservice_contexts +LOCAL_REQUIRED_MODULES += init_second_stage.recovery reboot.recovery plat_service_contexts plat_hardware_contexts vndservice_contexts include $(BUILD_PHONY_PACKAGE) -#mke2fs.conf -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 26; echo $$?),0) - include $(CLEAR_VARS) - LOCAL_MODULE := mke2fs.conf - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/etc - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) -endif - -ifeq ($(BOARD_HAS_NO_REAL_SDCARD),) - ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0) - #prebuilt, static sgdisk - include $(CLEAR_VARS) - LOCAL_MODULE := sgdisk_static - LOCAL_MODULE_STEM := sgdisk - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) - endif - #parted - #include $(CLEAR_VARS) - #LOCAL_MODULE := parted - #LOCAL_MODULE_TAGS := optional - #LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - #LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin - #LOCAL_SRC_FILES := $(LOCAL_MODULE) - #include $(BUILD_PREBUILT) -endif - # copy license file for OpenAES ifneq ($(TW_EXCLUDE_ENCRYPTED_BACKUPS), true) - include $(CLEAR_VARS) - LOCAL_MODULE := openaes_license - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/license/openaes - LOCAL_SRC_FILES := ../openaes/LICENSE - include $(BUILD_PREBUILT) + include $(CLEAR_VARS) + LOCAL_MODULE := openaes_license + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/license/openaes + LOCAL_SRC_FILES := ../openaes/LICENSE + include $(BUILD_PREBUILT) endif ifeq ($(TW_INCLUDE_DUMLOCK), true) - #htcdumlock for /system for dumlock - include $(CLEAR_VARS) - LOCAL_MODULE := htcdumlocksys - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) + #htcdumlock for /system for dumlock + include $(CLEAR_VARS) + LOCAL_MODULE := htcdumlocksys + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) - #flash_image for /system for dumlock - include $(CLEAR_VARS) - LOCAL_MODULE := flash_imagesys - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) + #flash_image for /system for dumlock + include $(CLEAR_VARS) + LOCAL_MODULE := flash_imagesys + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) - #dump_image for /system for dumlock - include $(CLEAR_VARS) - LOCAL_MODULE := dump_imagesys - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) + #dump_image for /system for dumlock + include $(CLEAR_VARS) + LOCAL_MODULE := dump_imagesys + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) - #libbmlutils for /system for dumlock - include $(CLEAR_VARS) - LOCAL_MODULE := libbmlutils.so - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) + #libbmlutils for /system for dumlock + include $(CLEAR_VARS) + LOCAL_MODULE := libbmlutils.so + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) - #libflashutils for /system for dumlock - include $(CLEAR_VARS) - LOCAL_MODULE := libflashutils.so - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) + #libflashutils for /system for dumlock + include $(CLEAR_VARS) + LOCAL_MODULE := libflashutils.so + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) - #libmmcutils for /system for dumlock - include $(CLEAR_VARS) - LOCAL_MODULE := libmmcutils.so - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) + #libmmcutils for /system for dumlock + include $(CLEAR_VARS) + LOCAL_MODULE := libmmcutils.so + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) - #libmtdutils for /system for dumlock - include $(CLEAR_VARS) - LOCAL_MODULE := libmtdutils.so - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) + #libmtdutils for /system for dumlock + include $(CLEAR_VARS) + LOCAL_MODULE := libmtdutils.so + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) - #HTCDumlock.apk - include $(CLEAR_VARS) - LOCAL_MODULE := HTCDumlock.apk - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) - LOCAL_SRC_FILES := $(LOCAL_MODULE) - include $(BUILD_PREBUILT) + #HTCDumlock.apk + include $(CLEAR_VARS) + LOCAL_MODULE := HTCDumlock.apk + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWHTCD_PATH) + LOCAL_SRC_FILES := $(LOCAL_MODULE) + include $(BUILD_PREBUILT) endif ifeq ($(TW_USE_TOOLBOX), true) @@ -682,7 +446,7 @@ ifeq ($(TW_USE_TOOLBOX), true) LOCAL_MODULE_STEM := mkshrc LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := ETC - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/etc + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/etc LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) endif @@ -692,7 +456,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := me.twrp.twrpapp.apk LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) @@ -701,22 +465,20 @@ include $(CLEAR_VARS) LOCAL_MODULE := privapp-permissions-twrpapp.xml LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) ifeq ($(TW_INCLUDE_CRYPTO), true) ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),) - ifneq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) - # Prebuilt vdc_pie for pre-Pie SDK Platforms - include $(CLEAR_VARS) - LOCAL_MODULE := vdc_pie - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES - LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin - LOCAL_SRC_FILES := vdc_pie-$(TARGET_ARCH) - include $(BUILD_PREBUILT) - endif + # Prebuilt vdc_pie for pre-Pie SDK Platforms + include $(CLEAR_VARS) + LOCAL_MODULE := vdc_pie + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin + LOCAL_SRC_FILES := vdc_pie-$(TARGET_ARCH) + include $(BUILD_PREBUILT) endif endif diff --git a/prebuilt/relink.sh b/prebuilt/relink.sh index 783e0522..063f445e 100755 --- a/prebuilt/relink.sh +++ b/prebuilt/relink.sh @@ -5,20 +5,15 @@ process_file() dst=$1/$(basename $2) src=$2 - if [ ! -e $src ]; then - return - fi + [[ -e $src ]] || return 0 if [ $dst == $src ]; then cp -f -p $src $src.tmp src=$2.tmp - else - cp -f -p --remove-destination $src $dst fi - sed "s|/system/bin/linker64\x0|/sbin/linker64\x0\x0\x0\x0\x0\x0\x0|g" $src | sed "s|/system/bin/linker\x0|/sbin/linker\x0\x0\x0\x0\x0\x0\x0|g" | sed "s|/system/bin/sh\x0|/sbin/sh\x0\x0\x0\x0\x0\x0\x0|g" > $dst - #rm -f $src - [ -e $2.tmp ] && rm $2.tmp || echo + cp $src $dst + if [[ -e $2.tmp ]]; then rm -f $2.tmp; fi } diff --git a/simg2img/Android.mk b/simg2img/Android.mk old mode 100644 new mode 100755 index b0bb4f14..6b4c9a2e --- a/simg2img/Android.mk +++ b/simg2img/Android.mk @@ -5,7 +5,7 @@ LOCAL_SRC_FILES := simg2img.cpp \ sparse_crc32.cpp LOCAL_MODULE := simg2img_twrp LOCAL_MODULE_STEM := simg2img -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin LOCAL_MODULE_TAGS := optional LOCAL_SHARED_LIBRARIES := \ libsparse \ diff --git a/twinstall.cpp b/twinstall.cpp index 7b1ca0c7..fd338288 100755 --- a/twinstall.cpp +++ b/twinstall.cpp @@ -451,7 +451,7 @@ int TWinstall_zip(const char* path, int* wipe_cache) { bool vendor_mount_state = PartitionManager.Is_Mounted_By_Path("/vendor"); PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true); PartitionManager.Mount_By_Path("/vendor", true); - TWFunc::Exec_Cmd("cp -f /sbin/sh /tmp/sh"); + TWFunc::Exec_Cmd("cp -f /system/bin/sh /tmp/sh"); mount("/tmp/sh", "/system/bin/sh", "auto", MS_BIND, NULL); ret_val = Run_Update_Binary(path, &Zip, wipe_cache, AB_OTA_ZIP_TYPE); umount("/system/bin/sh"); diff --git a/twinstallorig.cpp b/twinstallorig.cpp deleted file mode 100644 index 60d76a5e..00000000 --- a/twinstallorig.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/* - Copyright 2012 to 2016 bigbiff/Dees_Troy TeamWin - This file is part of TWRP/TeamWin Recovery Project. - - TWRP is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - TWRP is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with TWRP. If not, see . -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "twcommon.h" -#include "mtdutils/mounts.h" -#include "mtdutils/mtdutils.h" -#include "minzip/SysUtil.h" -#include "minzip/Zip.h" -#ifdef USE_OLD_VERIFIER -#include "verifier24/verifier.h" -#else -#include "verifier.h" -#endif -#include "variables.h" -#include "data.hpp" -#include "partitions.hpp" -#include "twrpDigestDriver.hpp" -#include "twrpDigest/twrpDigest.hpp" -#include "twrpDigest/twrpMD5.hpp" -#include "twrp-functions.hpp" -#include "gui/gui.hpp" -#include "gui/pages.hpp" -#include "legacy_property_service.h" -#include "twinstall.h" -#include "installcommand.h" -extern "C" { - #include "gui/gui.h" -} - -#define AB_OTA "payload_properties.txt" - -static const char* properties_path = "/dev/__properties__"; -static const char* properties_path_renamed = "/dev/__properties_kk__"; -static bool legacy_props_env_initd = false; -static bool legacy_props_path_modified = false; - -enum zip_type { - UNKNOWN_ZIP_TYPE = 0, - UPDATE_BINARY_ZIP_TYPE, - AB_OTA_ZIP_TYPE, - TWRP_THEME_ZIP_TYPE -}; - -// to support pre-KitKat update-binaries that expect properties in the legacy format -static int switch_to_legacy_properties() -{ - if (!legacy_props_env_initd) { - if (legacy_properties_init() != 0) - return -1; - - char tmp[32]; - int propfd, propsz; - legacy_get_property_workspace(&propfd, &propsz); - sprintf(tmp, "%d,%d", dup(propfd), propsz); - setenv("ANDROID_PROPERTY_WORKSPACE", tmp, 1); - legacy_props_env_initd = true; - } - - if (TWFunc::Path_Exists(properties_path)) { - // hide real properties so that the updater uses the envvar to find the legacy format properties - if (rename(properties_path, properties_path_renamed) != 0) { - LOGERR("Renaming %s failed: %s\n", properties_path, strerror(errno)); - return -1; - } else { - legacy_props_path_modified = true; - } - } - - return 0; -} - -static int switch_to_new_properties() -{ - if (TWFunc::Path_Exists(properties_path_renamed)) { - if (rename(properties_path_renamed, properties_path) != 0) { - LOGERR("Renaming %s failed: %s\n", properties_path_renamed, strerror(errno)); - return -1; - } else { - legacy_props_path_modified = false; - } - } - - return 0; -} - -static int Install_Theme(const char* path, ZipArchive *Zip) { -#ifdef TW_OEM_BUILD // We don't do custom themes in OEM builds - mzCloseZipArchive(Zip); - return INSTALL_CORRUPT; -#else - const ZipEntry* xml_location = mzFindZipEntry(Zip, "ui.xml"); - - mzCloseZipArchive(Zip); - if (xml_location == NULL) { - return INSTALL_CORRUPT; - } - if (!PartitionManager.Mount_Settings_Storage(true)) - return INSTALL_ERROR; - string theme_path = DataManager::GetSettingsStoragePath(); - theme_path += "/TWRP/theme"; - if (!TWFunc::Path_Exists(theme_path)) { - if (!TWFunc::Recursive_Mkdir(theme_path)) { - return INSTALL_ERROR; - } - } - theme_path += "/ui.zip"; - if (TWFunc::copy_file(path, theme_path, 0644) != 0) { - return INSTALL_ERROR; - } - LOGINFO("Installing custom theme '%s' to '%s'\n", path, theme_path.c_str()); - PageManager::RequestReload(); - return INSTALL_SUCCESS; -#endif -} - -static int Prepare_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache) { - const ZipEntry* binary_location = mzFindZipEntry(Zip, ASSUMED_UPDATE_BINARY_NAME); - int binary_fd, ret_val; - - if (binary_location == NULL) { - return INSTALL_CORRUPT; - } - - // Delete any existing updater - if (TWFunc::Path_Exists(TMP_UPDATER_BINARY_PATH) && unlink(TMP_UPDATER_BINARY_PATH) != 0) { - LOGINFO("Unable to unlink '%s': %s\n", TMP_UPDATER_BINARY_PATH, strerror(errno)); - } - - binary_fd = creat(TMP_UPDATER_BINARY_PATH, 0755); - if (binary_fd < 0) { - LOGERR("Could not create file for updater extract in '%s': %s\n", TMP_UPDATER_BINARY_PATH, strerror(errno)); - mzCloseZipArchive(Zip); - return INSTALL_ERROR; - } - - ret_val = mzExtractZipEntryToFile(Zip, binary_location, binary_fd); - close(binary_fd); - - if (!ret_val) { - mzCloseZipArchive(Zip); - LOGERR("Could not extract '%s'\n", ASSUMED_UPDATE_BINARY_NAME); - return INSTALL_ERROR; - } - - // If exists, extract file_contexts from the zip file - const ZipEntry* selinx_contexts = mzFindZipEntry(Zip, "file_contexts"); - if (selinx_contexts == NULL) { - mzCloseZipArchive(Zip); - LOGINFO("Zip does not contain SELinux file_contexts file in its root.\n"); - } else { - string output_filename = "/file_contexts"; - LOGINFO("Zip contains SELinux file_contexts file in its root. Extracting to %s\n", output_filename.c_str()); - // Delete any file_contexts - if (TWFunc::Path_Exists(output_filename) && unlink(output_filename.c_str()) != 0) { - LOGINFO("Unable to unlink '%s': %s\n", output_filename.c_str(), strerror(errno)); - } - - int file_contexts_fd = creat(output_filename.c_str(), 0644); - if (file_contexts_fd < 0) { - LOGERR("Could not extract to '%s': %s\n", output_filename.c_str(), strerror(errno)); - mzCloseZipArchive(Zip); - return INSTALL_ERROR; - } - - ret_val = mzExtractZipEntryToFile(Zip, selinx_contexts, file_contexts_fd); - close(file_contexts_fd); - - if (!ret_val) { - mzCloseZipArchive(Zip); - LOGERR("Could not extract '%s'\n", output_filename.c_str()); - return INSTALL_ERROR; - } - } - mzCloseZipArchive(Zip); - return INSTALL_SUCCESS; -} - -static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache, zip_type ztype) { - int ret_val, pipe_fd[2], status, zip_verify; - char buffer[1024]; - FILE* child_data; - -#ifndef TW_NO_LEGACY_PROPS - /* Set legacy properties */ - if (switch_to_legacy_properties() != 0) { - LOGERR("Legacy property environment did not initialize successfully. Properties may not be detected.\n"); - } else { - LOGINFO("Legacy property environment initialized.\n"); - } -#endif - - pipe(pipe_fd); - - std::vector args; - if (ztype == UPDATE_BINARY_ZIP_TYPE) { - ret_val = update_binary_command(path, Zip, 0, pipe_fd[1], &args); - } else if (ztype == AB_OTA_ZIP_TYPE) { - ret_val = abupdate_binary_command(path, Zip, 0, pipe_fd[1], &args); - } else { - LOGERR("Unknown zip type %i\n", ztype); - ret_val = INSTALL_CORRUPT; - } - if (ret_val) { - close(pipe_fd[0]); - close(pipe_fd[1]); - return ret_val; - } - - // Convert the vector to a NULL-terminated char* array suitable for execv. - const char* chr_args[args.size() + 1]; - chr_args[args.size()] = NULL; - for (size_t i = 0; i < args.size(); i++) - chr_args[i] = args[i].c_str(); - - pid_t pid = fork(); - if (pid == 0) { - close(pipe_fd[0]); - execve(chr_args[0], const_cast(chr_args), environ); - printf("E:Can't execute '%s': %s\n", chr_args[0], strerror(errno)); - _exit(-1); - } - close(pipe_fd[1]); - - *wipe_cache = 0; - - DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify); - child_data = fdopen(pipe_fd[0], "r"); - while (fgets(buffer, sizeof(buffer), child_data) != NULL) { - char* command = strtok(buffer, " \n"); - if (command == NULL) { - continue; - } else if (strcmp(command, "progress") == 0) { - char* fraction_char = strtok(NULL, " \n"); - char* seconds_char = strtok(NULL, " \n"); - - float fraction_float = strtof(fraction_char, NULL); - int seconds_float = strtol(seconds_char, NULL, 10); - - if (zip_verify) - DataManager::ShowProgress(fraction_float * (1 - VERIFICATION_PROGRESS_FRACTION), seconds_float); - else - DataManager::ShowProgress(fraction_float, seconds_float); - } else if (strcmp(command, "set_progress") == 0) { - char* fraction_char = strtok(NULL, " \n"); - float fraction_float = strtof(fraction_char, NULL); - DataManager::SetProgress(fraction_float); - } else if (strcmp(command, "ui_print") == 0) { - char* display_value = strtok(NULL, "\n"); - if (display_value) { - gui_print("%s", display_value); - } else { - gui_print("\n"); - } - } else if (strcmp(command, "wipe_cache") == 0) { - *wipe_cache = 1; - } else if (strcmp(command, "clear_display") == 0) { - // Do nothing, not supported by TWRP - } else if (strcmp(command, "log") == 0) { - printf("%s\n", strtok(NULL, "\n")); - } else { - LOGERR("unknown command [%s]\n", command); - } - } - fclose(child_data); - - int waitrc = TWFunc::Wait_For_Child(pid, &status, "Updater"); - -#ifndef TW_NO_LEGACY_PROPS - /* Unset legacy properties */ - if (legacy_props_path_modified) { - if (switch_to_new_properties() != 0) { - LOGERR("Legacy property environment did not disable successfully. Legacy properties may still be in use.\n"); - } else { - LOGINFO("Legacy property environment disabled.\n"); - } - } -#endif - - if (waitrc != 0) - return INSTALL_ERROR; - - return INSTALL_SUCCESS; -} - -extern "C" int TWinstall_zip(const char* path, int* wipe_cache) { - int ret_val, zip_verify = 1; - ZipArchive Zip; - - if (strcmp(path, "error") == 0) { - LOGERR("Failed to get adb sideload file: '%s'\n", path); - return INSTALL_CORRUPT; - } - - gui_msg(Msg("installing_zip=Installing zip file '{1}'")(path)); - if (strlen(path) < 9 || strncmp(path, "/sideload", 9) != 0) { - string digest_str; - string Full_Filename = path; - string digest_file = path; - digest_file += ".md5"; - - gui_msg("check_for_digest=Checking for Digest file..."); - if (!TWFunc::Path_Exists(digest_file)) { - gui_msg("no_digest=Skipping Digest check: no Digest file found"); - } - else { - if (TWFunc::read_file(digest_file, digest_str) != 0) { - LOGERR("Skipping MD5 check: MD5 file unreadable\n"); - } - else { - twrpDigest *digest = new twrpMD5(); - if (!twrpDigestDriver::stream_file_to_digest(Full_Filename, digest)) { - delete digest; - return INSTALL_CORRUPT; - } - string digest_check = digest->return_digest_string(); - if (digest_str == digest_check) { - gui_msg(Msg("digest_matched=Digest matched for '{1}'.")(path)); - } - else { - LOGERR("Aborting zip install: Digest verification failed\n"); - delete digest; - return INSTALL_CORRUPT; - } - delete digest; - } - } - } - -#ifndef TW_OEM_BUILD - DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify); -#endif - DataManager::SetProgress(0); - - MemMapping map; - if (sysMapFile(path, &map) != 0) { - gui_msg(Msg(msg::kError, "fail_sysmap=Failed to map file '{1}'")(path)); - return -1; - } - - if (zip_verify) { - gui_msg("verify_zip_sig=Verifying zip signature..."); - std::vector loadedKeys; - if (!load_keys("/res/keys", loadedKeys)) { - LOGINFO("Failed to load keys"); - gui_err("verify_zip_fail=Zip signature verification failed!"); - return -1; - } - ret_val = verify_file(map.addr, map.length, loadedKeys, NULL); - if (ret_val != VERIFY_SUCCESS) { - LOGINFO("Zip signature verification failed: %i\n", ret_val); - gui_err("verify_zip_fail=Zip signature verification failed!"); - sysReleaseMap(&map); - return -1; - } else { - gui_msg("verify_zip_done=Zip signature verified successfully."); - } - } - ret_val = mzOpenZipArchive(map.addr, map.length, &Zip); - if (ret_val != 0) { - gui_err("zip_corrupt=Zip file is corrupt!"); - sysReleaseMap(&map); - return INSTALL_CORRUPT; - } - - time_t start, stop; - time(&start); - const ZipEntry* file_location = mzFindZipEntry(&Zip, ASSUMED_UPDATE_BINARY_NAME); - if (file_location != NULL) { - LOGINFO("Update binary zip\n"); - ret_val = Prepare_Update_Binary(path, &Zip, wipe_cache); - if (ret_val == INSTALL_SUCCESS) - ret_val = Run_Update_Binary(path, &Zip, wipe_cache, UPDATE_BINARY_ZIP_TYPE); - } else { - file_location = mzFindZipEntry(&Zip, AB_OTA); - if (file_location != NULL) { - LOGINFO("AB zip\n"); - ret_val = Run_Update_Binary(path, &Zip, wipe_cache, AB_OTA_ZIP_TYPE); - } else { - file_location = mzFindZipEntry(&Zip, "ui.xml"); - if (file_location != NULL) { - LOGINFO("TWRP theme zip\n"); - ret_val = Install_Theme(path, &Zip); - } else { - mzCloseZipArchive(&Zip); - ret_val = INSTALL_CORRUPT; - } - } - } - time(&stop); - int total_time = (int) difftime(stop, start); - if (ret_val == INSTALL_CORRUPT) { - gui_err("invalid_zip_format=Invalid zip file format!"); - } else { - LOGINFO("Install took %i second(s).\n", total_time); - } - sysReleaseMap(&map); - return ret_val; -} diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 9f13fe26..aeb2f7e7 100755 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -66,12 +66,15 @@ extern "C" { struct selabel_handle *selinux_handle; /* Execute a command */ -int TWFunc::Exec_Cmd(const string& cmd, string &result) { +int TWFunc::Exec_Cmd(const string& cmd, string &result, bool combine_stderr) { FILE* exec; char buffer[130]; int ret = 0; - exec = __popen(cmd.c_str(), "r"); - if (!exec) return -1; + std::string popen_cmd = cmd; + if (combine_stderr) + popen_cmd = cmd + " 2>&1"; + exec = __popen(popen_cmd.c_str(), "r"); + while (!feof(exec)) { if (fgets(buffer, 128, exec) != NULL) { result += buffer; @@ -90,7 +93,7 @@ int TWFunc::Exec_Cmd(const string& cmd, bool Show_Errors) { LOGERR("Exec_Cmd(): vfork failed: %d!\n", errno); return -1; case 0: // child - execl("/sbin/sh", "sh", "-c", cmd.c_str(), NULL); + execl("/system/bin/sh", "sh", "-c", cmd.c_str(), NULL); _exit(127); break; default: @@ -530,7 +533,7 @@ void TWFunc::Copy_Log(string Source, string Destination) { if (type == COMPRESSED) { std::string destFileBuffer; std::string getCompressedContents = "pigz -c -d " + Destination; - if (Exec_Cmd(getCompressedContents, destFileBuffer) < 0) { + if (Exec_Cmd(getCompressedContents, destFileBuffer, false) < 0) { LOGINFO("Unable to get destination logfile contents.\n"); return; } @@ -659,7 +662,7 @@ int TWFunc::tw_reboot(RebootCommand command) case rb_system: Update_Intent_File("s"); sync(); - check_and_run_script("/sbin/rebootsystem.sh", "reboot system"); + check_and_run_script("/system/bin/rebootsystem.sh", "reboot system"); #ifdef ANDROID_RB_PROPERTY return property_set(ANDROID_RB_PROPERTY, "reboot,"); #elif defined(ANDROID_RB_RESTART) @@ -668,21 +671,21 @@ int TWFunc::tw_reboot(RebootCommand command) return reboot(RB_AUTOBOOT); #endif case rb_recovery: - check_and_run_script("/sbin/rebootrecovery.sh", "reboot recovery"); + check_and_run_script("/system/bin/rebootrecovery.sh", "reboot recovery"); #ifdef ANDROID_RB_PROPERTY return property_set(ANDROID_RB_PROPERTY, "reboot,recovery"); #else return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "recovery"); #endif case rb_bootloader: - check_and_run_script("/sbin/rebootbootloader.sh", "reboot bootloader"); + check_and_run_script("/system/bin/rebootbootloader.sh", "reboot bootloader"); #ifdef ANDROID_RB_PROPERTY return property_set(ANDROID_RB_PROPERTY, "reboot,bootloader"); #else return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "bootloader"); #endif case rb_poweroff: - check_and_run_script("/sbin/poweroff.sh", "power off"); + check_and_run_script("/system/bin/poweroff.sh", "power off"); #ifdef ANDROID_RB_PROPERTY return property_set(ANDROID_RB_PROPERTY, "shutdown,"); #elif defined(ANDROID_RB_POWEROFF) @@ -691,14 +694,14 @@ int TWFunc::tw_reboot(RebootCommand command) return reboot(RB_POWER_OFF); #endif case rb_download: - check_and_run_script("/sbin/rebootdownload.sh", "reboot download"); + check_and_run_script("/system/bin/rebootdownload.sh", "reboot download"); #ifdef ANDROID_RB_PROPERTY return property_set(ANDROID_RB_PROPERTY, "reboot,download"); #else return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "download"); #endif case rb_edl: - check_and_run_script("/sbin/rebootedl.sh", "reboot edl"); + check_and_run_script("/system/bin/rebootedl.sh", "reboot edl"); #ifdef ANDROID_RB_PROPERTY return property_set(ANDROID_RB_PROPERTY, "reboot,edl"); #else @@ -1228,10 +1231,10 @@ unsigned long long TWFunc::IOCTL_Get_Block_Size(const char* block_device) { void TWFunc::copy_kernel_log(string curr_storage) { std::string dmesgDst = curr_storage + "/dmesg.log"; - std::string dmesgCmd = "/sbin/dmesg"; + std::string dmesgCmd = "/system/bin/dmesg"; std::string result; - Exec_Cmd(dmesgCmd, result); + Exec_Cmd(dmesgCmd, result, false); write_to_file(dmesgDst, result); gui_msg(Msg("copy_kernel_log=Copied kernel log to {1}")(dmesgDst)); tw_set_default_metadata(dmesgDst.c_str()); @@ -1248,7 +1251,7 @@ bool TWFunc::isNumber(string strtocheck) { } int TWFunc::stream_adb_backup(string &Restore_Name) { - string cmd = "/sbin/bu --twrp stream " + Restore_Name; + string cmd = "/system/bin/bu --twrp stream " + Restore_Name; LOGINFO("stream_adb_backup: %s\n", cmd.c_str()); int ret = TWFunc::Exec_Cmd(cmd); if (ret != 0) @@ -1299,8 +1302,8 @@ void TWFunc::check_selinux_support() { if (TWFunc::Path_Exists(se_context_check)) { ret = lgetfilecon(se_context_check.c_str(), &contexts); if (ret < 0) { - LOGINFO("Could not check %s SELinux contexts, using /sbin/teamwin instead which may be inaccurate.\n", se_context_check.c_str()); - lgetfilecon("/sbin/teamwin", &contexts); + LOGINFO("Could not check %s SELinux contexts, using /system/bin/teamwin instead which may be inaccurate.\n", se_context_check.c_str()); + lgetfilecon("/system/bin/teamwin", &contexts); } } if (ret < 0) { diff --git a/twrp-functions.hpp b/twrp-functions.hpp index 80cb80e5..26867349 100755 --- a/twrp-functions.hpp +++ b/twrp-functions.hpp @@ -59,15 +59,15 @@ public: static string Get_Path(const string& Path); // Trims everything after the last / in the string static string Get_Filename(const string& Path); // Trims the path off of a filename - static int Exec_Cmd(const string& cmd, string &result); //execute a command and return the result as a string by reference - static int Exec_Cmd(const string& cmd, bool Show_Errors = true); //execute a command, displays an error to the GUI if Show_Errors is true, Show_Errors is true by default + static int Exec_Cmd(const string& cmd, string &result, bool combine_stderr); //execute a command and return the result as a string by reference, set combined_stderror to add stderr + static int Exec_Cmd(const string& cmd, bool Show_Errors = true); //execute a command, displays an error to the GUI if Show_Errors is true, Show_Errors is true by default static int Wait_For_Child(pid_t pid, int *status, string Child_Name, bool Show_Errors = true); // Waits for pid to exit and checks exit status, displays an error to the GUI if Show_Errors is true which is the default static int Wait_For_Child_Timeout(pid_t pid, int *status, const string& Child_Name, int timeout); // Waits for a pid to exit until the timeout is hit. If timeout is hit, kill the chilld. static bool Path_Exists(string Path); // Returns true if the path exists static Archive_Type Get_File_Type(string fn); // Determines file type, 0 for unknown, 1 for gzip, 2 for OAES encrypted static int Try_Decrypting_File(string fn, string password); // -1 for some error, 0 for failed to decrypt, 1 for decrypted, 3 for decrypted and found gzip format static unsigned long Get_File_Size(const string& Path); // Returns the size of a file - static std::string Remove_Beginning_Slash(const std::string& path); // Remove the beginning slash of a path + static std::string Remove_Beginning_Slash(const std::string& path); // Remove the beginning slash of a path static std::string Remove_Trailing_Slashes(const std::string& path, bool leaveLast = false); // Normalizes the path, e.g /data//media/ -> /data/media static void Strip_Quotes(char* &str); // Remove leading & trailing double-quotes from a string static vector split_string(const string &in, char del, bool skip_empty); diff --git a/twrp.cpp b/twrp.cpp index 24cd9ad3..a187486b 100755 --- a/twrp.cpp +++ b/twrp.cpp @@ -187,7 +187,7 @@ int main(int argc, char **argv) { rmdir("/s"); - TWFunc::check_and_run_script("/sbin/sarsetup.sh", "boot"); + TWFunc::check_and_run_script("/system/bin/sarsetup.sh", "boot"); } // End SAR detection @@ -302,8 +302,8 @@ int main(int argc, char **argv) { } // Check for and run startup script if script exists - TWFunc::check_and_run_script("/sbin/runatboot.sh", "boot"); - TWFunc::check_and_run_script("/sbin/postrecoveryboot.sh", "boot"); + TWFunc::check_and_run_script("/system/bin/runatboot.sh", "boot"); + TWFunc::check_and_run_script("/system/bin/postrecoveryboot.sh", "boot"); #ifdef TW_INCLUDE_INJECTTWRP // Back up TWRP Ramdisk if needed: diff --git a/twrpApex.cpp b/twrpApex.cpp index 33ec4dc7..e41dc239 100755 --- a/twrpApex.cpp +++ b/twrpApex.cpp @@ -46,7 +46,8 @@ std::string twrpApex::unzipImage(std::string file) { } std::string baseFile = basename(file.c_str()); - std::string path = "/sbin/" + baseFile; + std::string path(APEX_BASE); + path = path + baseFile; int fd = open(path.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666); ret = ExtractEntryToFile(handle, &entry, fd); if (ret != 0) { diff --git a/twrpApex.hpp b/twrpApex.hpp index fb916753..b00b9ae1 100755 --- a/twrpApex.hpp +++ b/twrpApex.hpp @@ -22,6 +22,7 @@ #define APEX_DIR "/system_root/system/apex" #define APEX_PAYLOAD "apex_payload.img" #define LOOP_BLOCK_DEVICE_DIR "/dev/block/" +#define APEX_BASE "/apex/" class twrpApex { public: diff --git a/twrpRepacker.cpp b/twrpRepacker.cpp new file mode 100755 index 00000000..56638902 --- /dev/null +++ b/twrpRepacker.cpp @@ -0,0 +1,249 @@ +/* + Copyright 2013 to 2020 TeamWin + This file is part of TWRP/TeamWin Recovery Project. + + TWRP is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + TWRP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TWRP. If not, see . +*/ + +#include + +#include "data.hpp" +#include "partitions.hpp" +#include "twrp-functions.hpp" +#include "twrpRepacker.hpp" +#include "twcommon.h" +#include "variables.h" +#include "gui/gui.hpp" + +bool twrpRepacker::Prepare_Empty_Folder(const std::string& Folder) { + if (TWFunc::Path_Exists(Folder)) + TWFunc::removeDir(Folder, false); + return TWFunc::Recursive_Mkdir(Folder); +} + +bool twrpRepacker::Backup_Image_For_Repack(TWPartition* Part, const std::string& Temp_Folder_Destination, + const bool Create_Backup, const std::string& Backup_Name) { + if (!Part) { + LOGERR("Partition was null!\n"); + return false; + } + if (!Prepare_Empty_Folder(Temp_Folder_Destination)) + return false; + std::string target_image = Temp_Folder_Destination + "boot.img"; + PartitionSettings part_settings; + part_settings.Part = Part; + if (Create_Backup) { + if (PartitionManager.Check_Backup_Name(Backup_Name, true, false) != 0) + return false; + DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, part_settings.Backup_Folder); + part_settings.Backup_Folder = part_settings.Backup_Folder + "/" + TWFunc::Get_Current_Date() + " " + Backup_Name + "/"; + if (!TWFunc::Recursive_Mkdir(part_settings.Backup_Folder)) + return false; + } else + part_settings.Backup_Folder = Temp_Folder_Destination; + part_settings.adbbackup = false; + part_settings.generate_digest = false; + part_settings.generate_md5 = false; + part_settings.PM_Method = PM_BACKUP; + part_settings.progress = NULL; + pid_t not_a_pid = 0; + if (!Part->Backup(&part_settings, ¬_a_pid)) + return false; + std::string backed_up_image = part_settings.Backup_Folder; + backed_up_image += Part->Get_Backup_FileName(); + target_image = Temp_Folder_Destination + "boot.img"; + if (Create_Backup) { + std::string source = part_settings.Backup_Folder + Part->Get_Backup_FileName(); + if (TWFunc::copy_file(source, target_image, 0644) != 0) { + LOGERR("Failed to copy backup file '%s' to temp folder target '%s'\n", source.c_str(), target_image.c_str()); + return false; + } + } else { + if (rename(backed_up_image.c_str(), target_image.c_str()) != 0) { + LOGERR("Failed to rename '%s' to '%s'\n", backed_up_image.c_str(), target_image.c_str()); + return false; + } + } + original_ramdisk_format = Unpack_Image(target_image, Temp_Folder_Destination, false, false); + return !original_ramdisk_format.empty(); +} + +std::string twrpRepacker::Unpack_Image(const std::string& Source_Path, const std::string& Temp_Folder_Destination, + const bool Copy_Source, const bool Create_Destination) { + std::string txt_to_find = "RAMDISK_FMT"; + if (Create_Destination) { + if (!Prepare_Empty_Folder(Temp_Folder_Destination)) + return std::string(); + } + if (Copy_Source) { + std::string destination = Temp_Folder_Destination + "/boot.img"; + if (TWFunc::copy_file(Source_Path, destination, 0644)) + return std::string(); + } + std::string command = "cd " + Temp_Folder_Destination + " && /system/bin/magiskboot unpack -h "; + command = command + "'" + Source_Path +"'"; + + std::string magisk_unpack_output; + int ret; + if ((ret = TWFunc::Exec_Cmd(command, magisk_unpack_output, true)) != 0) { + LOGINFO("Error unpacking %s, ret: %d!\n", Source_Path.c_str(), ret); + gui_msg(Msg(msg::kError, "unpack_error=Error unpacking image.")); + return std::string(); + } + size_t pos = magisk_unpack_output.find(txt_to_find) + txt_to_find.size(); + std::string ramdisk_format = magisk_unpack_output.substr(pos, magisk_unpack_output.size() - 1); + ramdisk_format.erase(std::remove(ramdisk_format.begin(), ramdisk_format.end(), '['), ramdisk_format.end()); + ramdisk_format.erase(std::remove(ramdisk_format.begin(), ramdisk_format.end(), ']'), ramdisk_format.end()); + ramdisk_format.erase(std::remove(ramdisk_format.begin(), ramdisk_format.end(), ' '), ramdisk_format.end()); + ramdisk_format.erase(std::remove(ramdisk_format.begin(), ramdisk_format.end(), '\n'), ramdisk_format.end()); + return ramdisk_format; +} + +bool twrpRepacker::Repack_Image_And_Flash(const std::string& Target_Image, const struct Repack_Options_struct& Repack_Options) { + bool recompress = false; + + if (!TWFunc::Path_Exists("/system/bin/magiskboot")) { + LOGERR("Image repacking tool not present in this TWRP build!"); + return false; + } + DataManager::SetProgress(0); + TWPartition* part = PartitionManager.Find_Partition_By_Path("/boot"); + if (part) + gui_msg(Msg("unpacking_image=Unpacking {1}...")(part->Get_Display_Name())); + else { + gui_msg(Msg(msg::kError, "unable_to_locate=Unable to locate {1}.")("/boot")); + return false; + } + if (!Backup_Image_For_Repack(part, REPACK_ORIG_DIR, Repack_Options.Backup_First, gui_lookup("repack", "Repack"))) + return false; + DataManager::SetProgress(.25); + gui_msg(Msg("unpacking_image=Unpacking {1}...")(Target_Image)); + image_ramdisk_format = Unpack_Image(Target_Image, REPACK_NEW_DIR, true); + if (image_ramdisk_format.empty()) + return false; + DataManager::SetProgress(.5); + gui_msg(Msg("repacking_image=Repacking {1}...")(part->Get_Display_Name())); + std::string path = REPACK_NEW_DIR; + if (Repack_Options.Type == REPLACE_KERNEL) { + // When we replace the kernel, what we really do is copy the boot partition ramdisk into the new image's folder + if (TWFunc::copy_file(REPACK_ORIG_DIR "ramdisk.cpio", REPACK_NEW_DIR "ramdisk.cpio", 0644)) { + LOGERR("Failed to copy ramdisk\n"); + return false; + } + } else if (Repack_Options.Type == REPLACE_RAMDISK) { + // Repack the ramdisk + if (TWFunc::copy_file(REPACK_NEW_DIR "ramdisk.cpio", REPACK_ORIG_DIR "ramdisk.cpio", 0644)) { + LOGERR("Failed to copy ramdisk\n"); + return false; + } + path = REPACK_ORIG_DIR; + } else { + LOGERR("Invalid repacking options specified\n"); + return false; + } + if (Repack_Options.Disable_Verity) + LOGERR("Disabling verity is not implemented yet\n"); + if (Repack_Options.Disable_Force_Encrypt) + LOGERR("Disabling force encrypt is not implemented yet\n"); + std::string command = "cd " + path + " && /system/bin/magiskboot repack "; + if (original_ramdisk_format != image_ramdisk_format) { + command = command + "-n "; + recompress = true; + } + + command += path + "boot.img"; + + std::string orig_compressed_image(REPACK_ORIG_DIR); + orig_compressed_image += "ramdisk.cpio"; + std::string copy_compressed_image(REPACK_ORIG_DIR); + copy_compressed_image += "ramdisk-1.cpio"; + + if (recompress) { + std::string compress_cmd = "/system/bin/magiskboot compress=" + image_ramdisk_format + " " + orig_compressed_image + " " + copy_compressed_image; + if (TWFunc::Exec_Cmd(compress_cmd) != 0) { + gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); + return false; + } + std::rename(copy_compressed_image.c_str(), orig_compressed_image.c_str()); + } + + if (TWFunc::Exec_Cmd(command) != 0) { + gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); + return false; + } + + DataManager::SetProgress(.75); + std::string file = "new-boot.img"; + DataManager::SetValue("tw_flash_partition", "/boot;"); + if (!PartitionManager.Flash_Image(path, file)) { + LOGINFO("Error flashing new image\n"); + return false; + } + DataManager::SetProgress(1); + TWFunc::removeDir(REPACK_ORIG_DIR, false); + if (part->Is_SlotSelect() && Repack_Options.Type == REPLACE_RAMDISK) { + LOGINFO("Switching slots to flash ramdisk to both partitions\n"); + string Current_Slot = PartitionManager.Get_Active_Slot_Display(); + if (Current_Slot == "A") + PartitionManager.Set_Active_Slot("B"); + else + PartitionManager.Set_Active_Slot("A"); + DataManager::SetProgress(.25); + if (!Backup_Image_For_Repack(part, REPACK_ORIG_DIR, Repack_Options.Backup_First, gui_lookup("repack", "Repack"))) + return false; + if (TWFunc::copy_file(REPACK_NEW_DIR "ramdisk.cpio", REPACK_ORIG_DIR "ramdisk.cpio", 0644)) { + LOGERR("Failed to copy ramdisk\n"); + return false; + } + path = REPACK_ORIG_DIR; + std::string command = "cd " + path + " && /system/bin/magiskboot repack "; + + if (original_ramdisk_format != image_ramdisk_format) { + command = command + "-n "; + recompress = true; + } + command += path + "boot.img"; + + if (recompress) { + std::string compress_cmd = "/system/bin/magiskboot compress=" + image_ramdisk_format + " " + orig_compressed_image + " " + copy_compressed_image; + if (TWFunc::Exec_Cmd(compress_cmd) != 0) { + gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); + return false; + } + std::rename(copy_compressed_image.c_str(), orig_compressed_image.c_str()); + } + + if (TWFunc::Exec_Cmd(command) != 0) { + gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); + return false; + } + + if (TWFunc::Exec_Cmd(command) != 0) { + gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); + return false; + } + DataManager::SetProgress(.75); + std::string file = "new-boot.img"; + DataManager::SetValue("tw_flash_partition", "/boot;"); + if (!PartitionManager.Flash_Image(path, file)) { + LOGINFO("Error flashing new image\n"); + return false; + } + DataManager::SetProgress(1); + TWFunc::removeDir(REPACK_ORIG_DIR, false); + PartitionManager.Set_Active_Slot(Current_Slot); + } + TWFunc::removeDir(REPACK_NEW_DIR, false); + return true; +} diff --git a/twrpRepacker.hpp b/twrpRepacker.hpp new file mode 100755 index 00000000..346229bb --- /dev/null +++ b/twrpRepacker.hpp @@ -0,0 +1,48 @@ +/* + Copyright 2014 to 2020 TeamWin + This file is part of TWRP/TeamWin Recovery Project. + + TWRP is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + TWRP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TWRP. If not, see . +*/ + +#include +#include "partitions.hpp" + +#ifndef TWRP_REPACKER +#define TWRP_REPACKER + +enum Repack_Type { + REPLACE_NONE = 0, + REPLACE_RAMDISK = 1, + REPLACE_KERNEL = 2, +}; + +struct Repack_Options_struct { + Repack_Type Type; + bool Backup_First; + bool Disable_Verity; + bool Disable_Force_Encrypt; +}; + +class twrpRepacker { + public: + bool Backup_Image_For_Repack(TWPartition* Part, const std::string& Temp_Folder_Destination, const bool Create_Backup, const std::string& Backup_Name); // Prepares an image for repacking by unpacking it to the temp folder destination + std::string Unpack_Image(const std::string& Source_Path, const std::string& Temp_Folder_Destination, const bool Copy_Source, const bool Create_Destination = true); // Prepares an image for repacking by unpacking it to the temp folder destination and return the ramdisk format + bool Repack_Image_And_Flash(const std::string& Target_Image, const struct Repack_Options_struct& Repack_Options); // Repacks the boot image with a new kernel or a new ramdisk + private: + bool Prepare_Empty_Folder(const std::string& Folder); // Creates an empty folder at Folder. If the folder already exists, the folder is deleted, then created + std::string original_ramdisk_format; // Ramdisk format of boot partition + std::string image_ramdisk_format; // Ramdisk format of boot image to repack from +}; +#endif // TWRP_REPACKER \ No newline at end of file diff --git a/twrpTar.cpp b/twrpTar.cpp index c4a71560..6c9e758d 100755 --- a/twrpTar.cpp +++ b/twrpTar.cpp @@ -1487,7 +1487,7 @@ unsigned long long twrpTar::uncompressedSize(string filename) { Command = "pigz -l '" + filename + "'"; /* if we set Command = "pigz -l " + tarfn + " | sed '1d' | cut -f5 -d' '"; we get the uncompressed size at once. */ - TWFunc::Exec_Cmd(Command, result); + TWFunc::Exec_Cmd(Command, result, false); if (!result.empty()) { /* Expected output: compressed original reduced name @@ -1512,7 +1512,7 @@ unsigned long long twrpTar::uncompressedSize(string filename) { Command = "openaes dec --key \"" + password + "\" --in '" + filename + "' | pigz -l"; /* if we set Command = "pigz -l " + tarfn + " | sed '1d' | cut -f5 -d' '"; we get the uncompressed size at once. */ - TWFunc::Exec_Cmd(Command, result); + TWFunc::Exec_Cmd(Command, result, false); if (!result.empty()) { LOGINFO("result was: '%s'\n", result.c_str()); /* Expected output: diff --git a/twrpTarMain/twrpTarMain.cpp b/twrpTarMain/twrpTarMain.cpp old mode 100644 new mode 100755 index df40426e..2607a850 --- a/twrpTarMain/twrpTarMain.cpp +++ b/twrpTarMain/twrpTarMain.cpp @@ -71,9 +71,9 @@ void usage() { printf(" -d target directory\n"); printf(" -t output file\n"); printf(" -m skip media subfolder (has data media)\n"); - printf(" -z compress backup (/sbin/pigz must be present)\n"); + printf(" -z compress backup (/system/bin/pigz must be present)\n"); #ifndef TW_EXCLUDE_ENCRYPTED_BACKUPS - printf(" -e encrypt/decrypt backup followed by password (/sbin/openaes must be present)\n"); + printf(" -e encrypt/decrypt backup followed by password (/system/bin/openaes must be present)\n"); printf(" -u encrypt using userdata encryption (must be used with -e)\n"); #endif printf("\n\n"); diff --git a/verifier24/README b/verifier24/README deleted file mode 100644 index 44d9422e..00000000 --- a/verifier24/README +++ /dev/null @@ -1,2 +0,0 @@ -This is older code from Android 5.1 Marshmallow (SDK ver 24) and older -that still used mincrypt instead of libcrypto. diff --git a/verifier24/asn1_decoder.cpp b/verifier24/asn1_decoder.cpp deleted file mode 100644 index e7aef781..00000000 --- a/verifier24/asn1_decoder.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "asn1_decoder.h" - - -typedef struct asn1_context { - size_t length; - uint8_t* p; - int app_type; -} asn1_context_t; - - -static const int kMaskConstructed = 0xE0; -static const int kMaskTag = 0x7F; -static const int kMaskAppType = 0x1F; - -static const int kTagOctetString = 0x04; -static const int kTagOid = 0x06; -static const int kTagSequence = 0x30; -static const int kTagSet = 0x31; -static const int kTagConstructed = 0xA0; - -asn1_context_t* asn1_context_new(uint8_t* buffer, size_t length) { - asn1_context_t* ctx = (asn1_context_t*) calloc(1, sizeof(asn1_context_t)); - if (ctx == NULL) { - return NULL; - } - ctx->p = buffer; - ctx->length = length; - return ctx; -} - -void asn1_context_free(asn1_context_t* ctx) { - free(ctx); -} - -static inline int peek_byte(asn1_context_t* ctx) { - if (ctx->length <= 0) { - return -1; - } - return *ctx->p; -} - -static inline int get_byte(asn1_context_t* ctx) { - if (ctx->length <= 0) { - return -1; - } - int byte = *ctx->p; - ctx->p++; - ctx->length--; - return byte; -} - -static inline bool skip_bytes(asn1_context_t* ctx, size_t num_skip) { - if (ctx->length < num_skip) { - return false; - } - ctx->p += num_skip; - ctx->length -= num_skip; - return true; -} - -static bool decode_length(asn1_context_t* ctx, size_t* out_len) { - int num_octets = get_byte(ctx); - if (num_octets == -1) { - return false; - } - if ((num_octets & 0x80) == 0x00) { - *out_len = num_octets; - return 1; - } - num_octets &= kMaskTag; - if ((size_t)num_octets >= sizeof(size_t)) { - return false; - } - size_t length = 0; - for (int i = 0; i < num_octets; ++i) { - int byte = get_byte(ctx); - if (byte == -1) { - return false; - } - length <<= 8; - length += byte; - } - *out_len = length; - return true; -} - -/** - * Returns the constructed type and advances the pointer. E.g. A0 -> 0 - */ -asn1_context_t* asn1_constructed_get(asn1_context_t* ctx) { - int type = get_byte(ctx); - if (type == -1 || (type & kMaskConstructed) != kTagConstructed) { - return NULL; - } - size_t length; - if (!decode_length(ctx, &length) || length > ctx->length) { - return NULL; - } - asn1_context_t* app_ctx = asn1_context_new(ctx->p, length); - app_ctx->app_type = type & kMaskAppType; - return app_ctx; -} - -bool asn1_constructed_skip_all(asn1_context_t* ctx) { - int byte = peek_byte(ctx); - while (byte != -1 && (byte & kMaskConstructed) == kTagConstructed) { - skip_bytes(ctx, 1); - size_t length; - if (!decode_length(ctx, &length) || !skip_bytes(ctx, length)) { - return false; - } - byte = peek_byte(ctx); - } - return byte != -1; -} - -int asn1_constructed_type(asn1_context_t* ctx) { - return ctx->app_type; -} - -asn1_context_t* asn1_sequence_get(asn1_context_t* ctx) { - if ((get_byte(ctx) & kMaskTag) != kTagSequence) { - return NULL; - } - size_t length; - if (!decode_length(ctx, &length) || length > ctx->length) { - return NULL; - } - return asn1_context_new(ctx->p, length); -} - -asn1_context_t* asn1_set_get(asn1_context_t* ctx) { - if ((get_byte(ctx) & kMaskTag) != kTagSet) { - return NULL; - } - size_t length; - if (!decode_length(ctx, &length) || length > ctx->length) { - return NULL; - } - return asn1_context_new(ctx->p, length); -} - -bool asn1_sequence_next(asn1_context_t* ctx) { - size_t length; - if (get_byte(ctx) == -1 || !decode_length(ctx, &length) || !skip_bytes(ctx, length)) { - return false; - } - return true; -} - -bool asn1_oid_get(asn1_context_t* ctx, uint8_t** oid, size_t* length) { - if (get_byte(ctx) != kTagOid) { - return false; - } - if (!decode_length(ctx, length) || *length == 0 || *length > ctx->length) { - return false; - } - *oid = ctx->p; - return true; -} - -bool asn1_octet_string_get(asn1_context_t* ctx, uint8_t** octet_string, size_t* length) { - if (get_byte(ctx) != kTagOctetString) { - return false; - } - if (!decode_length(ctx, length) || *length == 0 || *length > ctx->length) { - return false; - } - *octet_string = ctx->p; - return true; -} diff --git a/verifier24/asn1_decoder.h b/verifier24/asn1_decoder.h deleted file mode 100644 index b17141c4..00000000 --- a/verifier24/asn1_decoder.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef ASN1_DECODER_H_ -#define ASN1_DECODER_H_ - -#include - -typedef struct asn1_context asn1_context_t; - -asn1_context_t* asn1_context_new(uint8_t* buffer, size_t length); -void asn1_context_free(asn1_context_t* ctx); -asn1_context_t* asn1_constructed_get(asn1_context_t* ctx); -bool asn1_constructed_skip_all(asn1_context_t* ctx); -int asn1_constructed_type(asn1_context_t* ctx); -asn1_context_t* asn1_sequence_get(asn1_context_t* ctx); -asn1_context_t* asn1_set_get(asn1_context_t* ctx); -bool asn1_sequence_next(asn1_context_t* seq); -bool asn1_oid_get(asn1_context_t* ctx, uint8_t** oid, size_t* length); -bool asn1_octet_string_get(asn1_context_t* ctx, uint8_t** octet_string, size_t* length); - -#endif /* ASN1_DECODER_H_ */ diff --git a/verifier24/verifier.cpp b/verifier24/verifier.cpp deleted file mode 100644 index ae8647a2..00000000 --- a/verifier24/verifier.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "asn1_decoder.h" -#include "../common.h" -//#include "ui.h" -#include "verifier.h" - -#include "mincrypt/dsa_sig.h" -#include "mincrypt/p256.h" -#include "mincrypt/p256_ecdsa.h" -#include "mincrypt/rsa.h" -#include "mincrypt/sha.h" -#include "mincrypt/sha256.h" - -#include -#include -#include -#include - -//extern RecoveryUI* ui; - -#define PUBLIC_KEYS_FILE "/res/keys" - -/* - * Simple version of PKCS#7 SignedData extraction. This extracts the - * signature OCTET STRING to be used for signature verification. - * - * For full details, see http://www.ietf.org/rfc/rfc3852.txt - * - * The PKCS#7 structure looks like: - * - * SEQUENCE (ContentInfo) - * OID (ContentType) - * [0] (content) - * SEQUENCE (SignedData) - * INTEGER (version CMSVersion) - * SET (DigestAlgorithmIdentifiers) - * SEQUENCE (EncapsulatedContentInfo) - * [0] (CertificateSet OPTIONAL) - * [1] (RevocationInfoChoices OPTIONAL) - * SET (SignerInfos) - * SEQUENCE (SignerInfo) - * INTEGER (CMSVersion) - * SEQUENCE (SignerIdentifier) - * SEQUENCE (DigestAlgorithmIdentifier) - * SEQUENCE (SignatureAlgorithmIdentifier) - * OCTET STRING (SignatureValue) - */ -static bool read_pkcs7(uint8_t* pkcs7_der, size_t pkcs7_der_len, uint8_t** sig_der, - size_t* sig_der_length) { - asn1_context_t* ctx = asn1_context_new(pkcs7_der, pkcs7_der_len); - if (ctx == NULL) { - return false; - } - - asn1_context_t* pkcs7_seq = asn1_sequence_get(ctx); - if (pkcs7_seq != NULL && asn1_sequence_next(pkcs7_seq)) { - asn1_context_t *signed_data_app = asn1_constructed_get(pkcs7_seq); - if (signed_data_app != NULL) { - asn1_context_t* signed_data_seq = asn1_sequence_get(signed_data_app); - if (signed_data_seq != NULL - && asn1_sequence_next(signed_data_seq) - && asn1_sequence_next(signed_data_seq) - && asn1_sequence_next(signed_data_seq) - && asn1_constructed_skip_all(signed_data_seq)) { - asn1_context_t *sig_set = asn1_set_get(signed_data_seq); - if (sig_set != NULL) { - asn1_context_t* sig_seq = asn1_sequence_get(sig_set); - if (sig_seq != NULL - && asn1_sequence_next(sig_seq) - && asn1_sequence_next(sig_seq) - && asn1_sequence_next(sig_seq) - && asn1_sequence_next(sig_seq)) { - uint8_t* sig_der_ptr; - if (asn1_octet_string_get(sig_seq, &sig_der_ptr, sig_der_length)) { - *sig_der = (uint8_t*) malloc(*sig_der_length); - if (*sig_der != NULL) { - memcpy(*sig_der, sig_der_ptr, *sig_der_length); - } - } - asn1_context_free(sig_seq); - } - asn1_context_free(sig_set); - } - asn1_context_free(signed_data_seq); - } - asn1_context_free(signed_data_app); - } - asn1_context_free(pkcs7_seq); - } - asn1_context_free(ctx); - - return *sig_der != NULL; -} - -// Look for an RSA signature embedded in the .ZIP file comment given -// the path to the zip. Verify it matches one of the given public -// keys. -// -// Return VERIFY_SUCCESS, VERIFY_FAILURE (if any error is encountered -// or no key matches the signature). -int verify_file(unsigned char* addr, size_t length) { - //ui->SetProgress(0.0); - - int numKeys; - Certificate* pKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys); - if (pKeys == NULL) { - LOGE("Failed to load keys\n"); - return INSTALL_CORRUPT; - } - LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE); - - // An archive with a whole-file signature will end in six bytes: - // - // (2-byte signature start) $ff $ff (2-byte comment size) - // - // (As far as the ZIP format is concerned, these are part of the - // archive comment.) We start by reading this footer, this tells - // us how far back from the end we have to start reading to find - // the whole comment. - -#define FOOTER_SIZE 6 - - if (length < FOOTER_SIZE) { - LOGE("not big enough to contain footer\n"); - return VERIFY_FAILURE; - } - - unsigned char* footer = addr + length - FOOTER_SIZE; - - if (footer[2] != 0xff || footer[3] != 0xff) { - LOGE("footer is wrong\n"); - return VERIFY_FAILURE; - } - - size_t comment_size = footer[4] + (footer[5] << 8); - size_t signature_start = footer[0] + (footer[1] << 8); - LOGI("comment is %zu bytes; signature %zu bytes from end\n", - comment_size, signature_start); - - if (signature_start <= FOOTER_SIZE) { - LOGE("Signature start is in the footer"); - return VERIFY_FAILURE; - } - -#define EOCD_HEADER_SIZE 22 - - // The end-of-central-directory record is 22 bytes plus any - // comment length. - size_t eocd_size = comment_size + EOCD_HEADER_SIZE; - - if (length < eocd_size) { - LOGE("not big enough to contain EOCD\n"); - return VERIFY_FAILURE; - } - - // Determine how much of the file is covered by the signature. - // This is everything except the signature data and length, which - // includes all of the EOCD except for the comment length field (2 - // bytes) and the comment data. - size_t signed_len = length - eocd_size + EOCD_HEADER_SIZE - 2; - - unsigned char* eocd = addr + length - eocd_size; - - // If this is really is the EOCD record, it will begin with the - // magic number $50 $4b $05 $06. - if (eocd[0] != 0x50 || eocd[1] != 0x4b || - eocd[2] != 0x05 || eocd[3] != 0x06) { - LOGE("signature length doesn't match EOCD marker\n"); - return VERIFY_FAILURE; - } - - size_t i; - for (i = 4; i < eocd_size-3; ++i) { - if (eocd[i ] == 0x50 && eocd[i+1] == 0x4b && - eocd[i+2] == 0x05 && eocd[i+3] == 0x06) { - // if the sequence $50 $4b $05 $06 appears anywhere after - // the real one, minzip will find the later (wrong) one, - // which could be exploitable. Fail verification if - // this sequence occurs anywhere after the real one. - LOGE("EOCD marker occurs after start of EOCD\n"); - return VERIFY_FAILURE; - } - } - -#define BUFFER_SIZE 4096 - - bool need_sha1 = false; - bool need_sha256 = false; - for (i = 0; i < numKeys; ++i) { - switch (pKeys[i].hash_len) { - case SHA_DIGEST_SIZE: need_sha1 = true; break; - case SHA256_DIGEST_SIZE: need_sha256 = true; break; - } - } - - SHA_CTX sha1_ctx; - SHA256_CTX sha256_ctx; - SHA_init(&sha1_ctx); - SHA256_init(&sha256_ctx); - - double frac = -1.0; - size_t so_far = 0; - while (so_far < signed_len) { - size_t size = signed_len - so_far; - if (size > BUFFER_SIZE) size = BUFFER_SIZE; - - if (need_sha1) SHA_update(&sha1_ctx, addr + so_far, size); - if (need_sha256) SHA256_update(&sha256_ctx, addr + so_far, size); - so_far += size; - - double f = so_far / (double)signed_len; - if (f > frac + 0.02 || size == so_far) { - //ui->SetProgress(f); - frac = f; - } - } - - const uint8_t* sha1 = SHA_final(&sha1_ctx); - const uint8_t* sha256 = SHA256_final(&sha256_ctx); - - uint8_t* sig_der = NULL; - size_t sig_der_length = 0; - - size_t signature_size = signature_start - FOOTER_SIZE; - if (!read_pkcs7(eocd + eocd_size - signature_start, signature_size, &sig_der, - &sig_der_length)) { - LOGE("Could not find signature DER block\n"); - return VERIFY_FAILURE; - } - - /* - * Check to make sure at least one of the keys matches the signature. Since - * any key can match, we need to try each before determining a verification - * failure has happened. - */ - for (i = 0; i < numKeys; ++i) { - const uint8_t* hash; - switch (pKeys[i].hash_len) { - case SHA_DIGEST_SIZE: hash = sha1; break; - case SHA256_DIGEST_SIZE: hash = sha256; break; - default: continue; - } - - // The 6 bytes is the "(signature_start) $ff $ff (comment_size)" that - // the signing tool appends after the signature itself. - if (pKeys[i].key_type == Certificate::RSA) { - if (sig_der_length < RSANUMBYTES) { - // "signature" block isn't big enough to contain an RSA block. - LOGI("signature is too short for RSA key %zu\n", i); - continue; - } - - if (!RSA_verify(pKeys[i].rsa, sig_der, RSANUMBYTES, - hash, pKeys[i].hash_len)) { - LOGI("failed to verify against RSA key %zu\n", i); - continue; - } - - LOGI("whole-file signature verified against RSA key %zu\n", i); - free(sig_der); - return VERIFY_SUCCESS; - } else if (pKeys[i].key_type == Certificate::EC - && pKeys[i].hash_len == SHA256_DIGEST_SIZE) { - p256_int r, s; - if (!dsa_sig_unpack(sig_der, sig_der_length, &r, &s)) { - LOGI("Not a DSA signature block for EC key %zu\n", i); - continue; - } - - p256_int p256_hash; - p256_from_bin(hash, &p256_hash); - if (!p256_ecdsa_verify(&(pKeys[i].ec->x), &(pKeys[i].ec->y), - &p256_hash, &r, &s)) { - LOGI("failed to verify against EC key %zu\n", i); - continue; - } - - LOGI("whole-file signature verified against EC key %zu\n", i); - free(sig_der); - return VERIFY_SUCCESS; - } else { - LOGI("Unknown key type %d\n", pKeys[i].key_type); - } - LOGI("i: %i, eocd_size: %i, RSANUMBYTES: %i\n", i, eocd_size, RSANUMBYTES); - } - free(sig_der); - LOGE("failed to verify whole-file signature\n"); - return VERIFY_FAILURE; -} - -// Reads a file containing one or more public keys as produced by -// DumpPublicKey: this is an RSAPublicKey struct as it would appear -// as a C source literal, eg: -// -// "{64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" -// -// For key versions newer than the original 2048-bit e=3 keys -// supported by Android, the string is preceded by a version -// identifier, eg: -// -// "v2 {64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}" -// -// (Note that the braces and commas in this example are actual -// characters the parser expects to find in the file; the ellipses -// indicate more numbers omitted from this example.) -// -// The file may contain multiple keys in this format, separated by -// commas. The last key must not be followed by a comma. -// -// A Certificate is a pair of an RSAPublicKey and a particular hash -// (we support SHA-1 and SHA-256; we store the hash length to signify -// which is being used). The hash used is implied by the version number. -// -// 1: 2048-bit RSA key with e=3 and SHA-1 hash -// 2: 2048-bit RSA key with e=65537 and SHA-1 hash -// 3: 2048-bit RSA key with e=3 and SHA-256 hash -// 4: 2048-bit RSA key with e=65537 and SHA-256 hash -// 5: 256-bit EC key using the NIST P-256 curve parameters and SHA-256 hash -// -// Returns NULL if the file failed to parse, or if it contain zero keys. -Certificate* -load_keys(const char* filename, int* numKeys) { - Certificate* out = NULL; - *numKeys = 0; - - FILE* f = fopen(filename, "r"); - if (f == NULL) { - LOGE("opening %s: %s\n", filename, strerror(errno)); - goto exit; - } - - { - int i; - bool done = false; - while (!done) { - ++*numKeys; - out = (Certificate*)realloc(out, *numKeys * sizeof(Certificate)); - Certificate* cert = out + (*numKeys - 1); - memset(cert, '\0', sizeof(Certificate)); - - char start_char; - if (fscanf(f, " %c", &start_char) != 1) goto exit; - if (start_char == '{') { - // a version 1 key has no version specifier. - cert->key_type = Certificate::RSA; - cert->rsa = (RSAPublicKey*)malloc(sizeof(RSAPublicKey)); - cert->rsa->exponent = 3; - cert->hash_len = SHA_DIGEST_SIZE; - } else if (start_char == 'v') { - int version; - if (fscanf(f, "%d {", &version) != 1) goto exit; - switch (version) { - case 2: - cert->key_type = Certificate::RSA; - cert->rsa = (RSAPublicKey*)malloc(sizeof(RSAPublicKey)); - cert->rsa->exponent = 65537; - cert->hash_len = SHA_DIGEST_SIZE; - break; - case 3: - cert->key_type = Certificate::RSA; - cert->rsa = (RSAPublicKey*)malloc(sizeof(RSAPublicKey)); - cert->rsa->exponent = 3; - cert->hash_len = SHA256_DIGEST_SIZE; - break; - case 4: - cert->key_type = Certificate::RSA; - cert->rsa = (RSAPublicKey*)malloc(sizeof(RSAPublicKey)); - cert->rsa->exponent = 65537; - cert->hash_len = SHA256_DIGEST_SIZE; - break; - case 5: - cert->key_type = Certificate::EC; - cert->ec = (ECPublicKey*)calloc(1, sizeof(ECPublicKey)); - cert->hash_len = SHA256_DIGEST_SIZE; - break; - default: - goto exit; - } - } - - if (cert->key_type == Certificate::RSA) { - RSAPublicKey* key = cert->rsa; - if (fscanf(f, " %i , 0x%x , { %u", - &(key->len), &(key->n0inv), &(key->n[0])) != 3) { - goto exit; - } - if (key->len != RSANUMWORDS) { - LOGE("key length (%d) does not match expected size\n", key->len); - goto exit; - } - for (i = 1; i < key->len; ++i) { - if (fscanf(f, " , %u", &(key->n[i])) != 1) goto exit; - } - if (fscanf(f, " } , { %u", &(key->rr[0])) != 1) goto exit; - for (i = 1; i < key->len; ++i) { - if (fscanf(f, " , %u", &(key->rr[i])) != 1) goto exit; - } - fscanf(f, " } } "); - - LOGI("read key e=%d hash=%d\n", key->exponent, cert->hash_len); - } else if (cert->key_type == Certificate::EC) { - ECPublicKey* key = cert->ec; - int key_len; - unsigned int byte; - uint8_t x_bytes[P256_NBYTES]; - uint8_t y_bytes[P256_NBYTES]; - if (fscanf(f, " %i , { %u", &key_len, &byte) != 2) goto exit; - if (key_len != P256_NBYTES) { - LOGE("Key length (%d) does not match expected size %d\n", key_len, P256_NBYTES); - goto exit; - } - x_bytes[P256_NBYTES - 1] = byte; - for (i = P256_NBYTES - 2; i >= 0; --i) { - if (fscanf(f, " , %u", &byte) != 1) goto exit; - x_bytes[i] = byte; - } - if (fscanf(f, " } , { %u", &byte) != 1) goto exit; - y_bytes[P256_NBYTES - 1] = byte; - for (i = P256_NBYTES - 2; i >= 0; --i) { - if (fscanf(f, " , %u", &byte) != 1) goto exit; - y_bytes[i] = byte; - } - fscanf(f, " } } "); - p256_from_bin(x_bytes, &key->x); - p256_from_bin(y_bytes, &key->y); - } else { - LOGE("Unknown key type %d\n", cert->key_type); - goto exit; - } - - // if the line ends in a comma, this file has more keys. - switch (fgetc(f)) { - case ',': - // more keys to come. - break; - - case EOF: - done = true; - break; - - default: - LOGE("unexpected character between keys\n"); - goto exit; - } - } - } - - fclose(f); - return out; - -exit: - if (f) fclose(f); - free(out); - *numKeys = 0; - return NULL; -} diff --git a/verifier24/verifier.h b/verifier24/verifier.h deleted file mode 100644 index fe01e366..00000000 --- a/verifier24/verifier.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _RECOVERY_VERIFIER_H -#define _RECOVERY_VERIFIER_H - -#include "mincrypt/p256.h" -#include "mincrypt/rsa.h" - -#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary" - -enum { INSTALL_SUCCESS, INSTALL_ERROR, INSTALL_CORRUPT }; - -static const float VERIFICATION_PROGRESS_FRAC = 0.25; - -typedef struct { - p256_int x; - p256_int y; -} ECPublicKey; - -typedef struct { - typedef enum { - RSA, - EC, - } KeyType; - - int hash_len; // SHA_DIGEST_SIZE (SHA-1) or SHA256_DIGEST_SIZE (SHA-256) - KeyType key_type; - RSAPublicKey* rsa; - ECPublicKey* ec; -} Certificate; - -/* addr and length define a an update package file that has been - * loaded (or mmap'ed, or whatever) into memory. Verify that the file - * is signed and the signature matches one of the given keys. Return - * one of the constants below. - */ -int verify_file(unsigned char* addr, size_t length); - -Certificate* load_keys(const char* filename, int* numKeys); - -#define VERIFY_SUCCESS 0 -#define VERIFY_FAILURE 1 - -#endif /* _RECOVERY_VERIFIER_H */