diff --git a/data.cpp b/data.cpp index 4a3d9e538..4ced91e68 100755 --- a/data.cpp +++ b/data.cpp @@ -894,9 +894,6 @@ void DataManager::SetDefaultValues() #else mPersist.SetValue(TW_NO_SHA2, "1"); #endif - mPersist.SetValue(TRB_EN, "0"); - mPersist.SetValue(STD, "0"); - #ifdef TW_NO_SCREEN_TIMEOUT mConst.SetValue("tw_screen_timeout_secs", "0"); mConst.SetValue("tw_no_screen_timeout", "1"); diff --git a/gui/action.cpp b/gui/action.cpp index 88e268262..b81472767 100755 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -1333,7 +1333,6 @@ int GUIAction::flash(std::string arg) } gui_highlight("pb_saving_log=Preserving Logs...\n"); copylog(zip_filename); - DataManager::SetValue(TRB_EN, 0); //Reset At end operation_end(ret_val); // This needs to be after the operation_end call so we change pages before we change variables that we display on the screen DataManager::SetValue(TW_ZIP_QUEUE_COUNT, zip_queue_index); diff --git a/libblkid/Android.mk b/libblkid/Android.mk index 38a192f99..c6f62d2e8 100644 --- a/libblkid/Android.mk +++ b/libblkid/Android.mk @@ -146,6 +146,7 @@ LOCAL_SRC_FILES = src/cache.c \ src/superblocks/drbdproxy_datalog.c \ src/superblocks/exfat.c \ src/superblocks/ext.c \ + src/superblocks/erofs.c \ src/superblocks/f2fs.c \ src/superblocks/gfs.c \ src/superblocks/hfs.c \ diff --git a/libblkid/src/superblocks/erofs.c b/libblkid/src/superblocks/erofs.c new file mode 100644 index 000000000..0bf15913b --- /dev/null +++ b/libblkid/src/superblocks/erofs.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2020 Gao Xiang + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License + */ +#include +#include + +#include "superblocks.h" + +#define EROFS_SUPER_OFFSET 1024 +#define EROFS_SB_KBOFF (EROFS_SUPER_OFFSET >> 10) + +#define EROFS_SUPER_MAGIC_V1 "\xe2\xe1\xf5\xe0" +#define EROFS_MAGIC_OFF 0 + +/* All in little-endian */ +struct erofs_super_block { + uint32_t magic; + uint32_t checksum; + uint32_t feature_compat; + uint8_t blkszbits; + uint8_t reserved; + + uint16_t root_nid; + uint64_t inos; + + uint64_t build_time; + uint32_t build_time_nsec; + uint32_t blocks; + uint32_t meta_blkaddr; + uint32_t xattr_blkaddr; + uint8_t uuid[16]; + uint8_t volume_name[16]; + uint32_t feature_incompat; + uint8_t reserved2[44]; +}; + +static int probe_erofs(blkid_probe pr, const struct blkid_idmag *mag) +{ + struct erofs_super_block *sb; + + sb = blkid_probe_get_sb(pr, mag, struct erofs_super_block); + if (!sb) + return errno ? -errno : BLKID_PROBE_NONE; + + if (sb->volume_name[0]) + blkid_probe_set_label(pr, (unsigned char *)sb->volume_name, + sizeof(sb->volume_name)); + + blkid_probe_set_uuid(pr, sb->uuid); + + return BLKID_PROBE_OK; +} + +const struct blkid_idinfo erofs_idinfo = +{ + .name = "erofs", + .usage = BLKID_USAGE_FILESYSTEM, + .probefunc = probe_erofs, + .magics = + { + { + .magic = EROFS_SUPER_MAGIC_V1, + .len = 4, + .kboff = EROFS_SB_KBOFF, + .sboff = EROFS_MAGIC_OFF, + }, { NULL } + } +}; diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index 80bd6e596..9d0d2cb18 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -155,7 +155,8 @@ static const struct blkid_idinfo *idinfos[] = &befs_idinfo, &nilfs2_idinfo, &exfat_idinfo, - &f2fs_idinfo + &f2fs_idinfo, + &erofs_idinfo }; /* diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h index 3bbfb9c19..808ae6a6a 100644 --- a/libblkid/src/superblocks/superblocks.h +++ b/libblkid/src/superblocks/superblocks.h @@ -74,6 +74,7 @@ extern const struct blkid_idinfo nilfs2_idinfo; extern const struct blkid_idinfo exfat_idinfo; extern const struct blkid_idinfo f2fs_idinfo; extern const struct blkid_idinfo bcache_idinfo; +extern const struct blkid_idinfo erofs_idinfo; /* * superblock functions diff --git a/minuitwrp/events.cpp b/minuitwrp/events.cpp index 8779a46d8..4ed03cec4 100644 --- a/minuitwrp/events.cpp +++ b/minuitwrp/events.cpp @@ -142,12 +142,11 @@ int vibrate(int timeout_ms) char tout[6]; sprintf(tout, "%i", timeout_ms); -#ifndef USE_QTI_HAPTICS - if (std::ifstream(LEDS_HAPTICS_ACTIVATE_FILE).good()) { - write_to_file(LEDS_HAPTICS_DURATION_FILE, tout); - write_to_file(LEDS_HAPTICS_ACTIVATE_FILE, "1"); - } else - write_to_file(VIBRATOR_TIMEOUT_FILE, std::to_string(timeout_ms)); +#ifdef USE_QTI_HAPTICS + android::sp vib = android::hardware::vibrator::V1_2::IVibrator::getService(); + if (vib != nullptr) { + vib->on((uint32_t)timeout_ms); + } #elif defined(USE_QTI_AIDL_HAPTICS) std::shared_ptr vib = IVibrator::fromBinder(ndk::SpAIBinder(AServiceManager_getService(kVibratorInstance.c_str()))); if (vib != nullptr) { @@ -161,10 +160,11 @@ int vibrate(int timeout_ms) write_to_file(VIBRATOR_TIMEOUT_FILE, tout); } #else - android::sp vib = android::hardware::vibrator::V1_2::IVibrator::getService(); - if (vib != nullptr) { - vib->on((uint32_t)timeout_ms); - } + if (std::ifstream(LEDS_HAPTICS_ACTIVATE_FILE).good()) { + write_to_file(LEDS_HAPTICS_DURATION_FILE, tout); + write_to_file(LEDS_HAPTICS_ACTIVATE_FILE, "1"); + } else + write_to_file(VIBRATOR_TIMEOUT_FILE, std::to_string(timeout_ms)); #endif return 0; } diff --git a/partition.cpp b/partition.cpp index 969c69460..b884c218e 100755 --- a/partition.cpp +++ b/partition.cpp @@ -1154,6 +1154,7 @@ bool TWPartition::Is_File_System(string File_System) { File_System == "yaffs2" || File_System == "exfat" || File_System == "f2fs" || + File_System == "erofs" || File_System == "squashfs" || File_System == "auto") return true; diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 8e11c775b..80167f341 100755 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -68,7 +68,6 @@ static const string split_img = tmp + "split_img/"; static string default_prop = ramdisk + "default.prop"; static string fstab1 = PartitionManager.Get_Android_Root_Path() + "/vendor/etc"; static string fstab2 = "/vendor/etc"; -static int trb_en = 0; static string dtb = "", ram = ""; struct selabel_handle *selinux_handle; @@ -1559,7 +1558,7 @@ static bool Patch_AVBDM_Verity() { if (stat == 0) { - if(trb_en == 1 || PartitionManager.Mount_By_Path("/vendor", false)) + if(PartitionManager.Mount_By_Path("/vendor", false)) { d1 = opendir(fstab2.c_str()); stat = 2; @@ -1724,7 +1723,7 @@ bool TWFunc::Patch_Forced_Encryption() } if (stat == 0 || ram.find("ramdisk") != string::npos) { - if(trb_en == 1 || PartitionManager.Mount_By_Path("/vendor", false)) + if(PartitionManager.Mount_By_Path("/vendor", false)) { //PartitionManager.Mount_By_Path("/vendor", false); d1 = opendir(fstab2.c_str()); @@ -1803,7 +1802,6 @@ void TWFunc::Deactivation_Process(void) return; } gui_msg(Msg(msg::kProcess, "pb_run_process=Starting '{1}' process")("PitchBlack")); - DataManager::GetValue(TRB_EN, trb_en); if (TWFunc::check_encrypt_status() != 0 && DataManager::GetIntValue(PB_ENABLE_ADVANCE_ENCRY) == 0) { gui_msg(Msg(msg::kHighlight, "pb_ecryption_leave=Device Encrypted Leaving Forceencrypt")); setenv("KEEPFORCEENCRYPT", "true", true); diff --git a/twrpinstall/ZipUtil.cpp b/twrpinstall/ZipUtil.cpp index f8134bc49..f073a229b 100755 --- a/twrpinstall/ZipUtil.cpp +++ b/twrpinstall/ZipUtil.cpp @@ -63,7 +63,7 @@ bool ExtractPackageRecursive(ZipArchiveHandle zip, const std::string& zip_path, } std::unique_ptr guard(cookie, EndIteration); - ZipEntry entry; + ZipEntry64 entry; ZipString name; int extractCount = 0; while (Next(cookie, &entry, &name) == 0) { diff --git a/twrpinstall/install.cpp b/twrpinstall/install.cpp index 5295405fc..d270d26d4 100755 --- a/twrpinstall/install.cpp +++ b/twrpinstall/install.cpp @@ -72,7 +72,7 @@ bool ReadMetadataFromPackage(ZipArchiveHandle zip, std::map guard(cookie, EndIteration); // std::vector compatibility_info; -// ZipEntry info_entry; +// ZipEntry64 info_entry; // ZipString info_name; // while (Next(cookie, &info_entry, &info_name) == 0) { // std::string content(info_entry.uncompressed_length, '\0'); diff --git a/twrpinstall/installcommand.cpp b/twrpinstall/installcommand.cpp index 2d2bc61e2..07db5c156 100755 --- a/twrpinstall/installcommand.cpp +++ b/twrpinstall/installcommand.cpp @@ -55,7 +55,7 @@ static int parse_build_number(std::string str) { bool read_metadata_from_package(ZipArchiveHandle zip, std::string* meta_data) { std::string binary_name(METADATA_PATH); - ZipEntry binary_entry; + ZipEntry64 binary_entry; if (FindEntry(zip, binary_name, &binary_entry) == 0) { long size = binary_entry.uncompressed_length; if (size <= 0) @@ -202,7 +202,7 @@ abupdate_binary_command(const char* path, int retry_count __unused, // the RAW payload offset in the zip file. // if (!Zip->EntryExists(AB_OTA_PAYLOAD_PROPERTIES)) { std::string binary_name(AB_OTA_PAYLOAD_PROPERTIES); - ZipEntry binary_entry; + ZipEntry64 binary_entry; if (FindEntry(Zip, binary_name, &binary_entry) != 0) { printf("Can't find %s\n", AB_OTA_PAYLOAD_PROPERTIES); return INSTALL_CORRUPT; @@ -218,7 +218,7 @@ abupdate_binary_command(const char* path, int retry_count __unused, } std::string ab_ota_payload(AB_OTA_PAYLOAD); - ZipEntry ab_ota_payload_entry; + ZipEntry64 ab_ota_payload_entry; if (FindEntry(Zip, ab_ota_payload, &ab_ota_payload_entry) != 0) { printf("Can't find %s\n", AB_OTA_PAYLOAD); return INSTALL_CORRUPT; @@ -279,7 +279,7 @@ bool verify_package_compatibility(ZipArchiveHandle zw) { static constexpr const char* COMPATIBILITY_ZIP_ENTRY = "compatibility.zip"; std::string compatibility_entry_name(COMPATIBILITY_ZIP_ENTRY); - ZipEntry compatibility_entry; + ZipEntry64 compatibility_entry; if (FindEntry(zw, compatibility_entry_name, &compatibility_entry) != 0) { printf("Package doesn't contain %s entry\n", COMPATIBILITY_ZIP_ENTRY); return true; @@ -313,7 +313,7 @@ bool verify_package_compatibility(ZipArchiveHandle zw) { std::unique_ptr guard(cookie, EndIteration); std::vector compatibility_info; - ZipEntry info_entry; + ZipEntry64 info_entry; std::string info_name; while (Next(cookie, &info_entry, &info_name) == 0) { std::string content(info_entry.uncompressed_length, '\0'); diff --git a/twrpinstall/twinstall.cpp b/twrpinstall/twinstall.cpp index eabf25c1c..3c8dd2bd2 100755 --- a/twrpinstall/twinstall.cpp +++ b/twrpinstall/twinstall.cpp @@ -89,7 +89,7 @@ static int Install_Theme(const char* path, ZipArchiveHandle Zip) { return INSTALL_CORRUPT; #else std::string binary_name("ui.xml"); - ZipEntry binary_entry; + ZipEntry64 binary_entry; if (FindEntry(Zip, binary_name, &binary_entry) != 0) { CloseArchive(Zip); return INSTALL_CORRUPT; @@ -153,7 +153,6 @@ static int Prepare_Update_Binary(ZipArchiveHandle Zip) { string fingerprint_property = "ro.build.fingerprint"; string pre_device = pre_something + "device"; string pre_build = pre_something + "build"; - int chk_sdk = 26 ; char arches[PATH_MAX]; property_get("ro.product.cpu.abilist", arches, "error"); @@ -163,7 +162,7 @@ static int Prepare_Update_Binary(ZipArchiveHandle Zip) { std::vector::iterator arch; std::string base_name = UPDATE_BINARY_NAME; base_name += "-"; - ZipEntry binary_entry; + ZipEntry64 binary_entry; std::string update_binary_string(UPDATE_BINARY_NAME); if (FindEntry(Zip, update_binary_string, &binary_entry) != 0) { for (arch = split.begin(); arch != split.end(); arch++) { @@ -198,61 +197,21 @@ static int Prepare_Update_Binary(ZipArchiveHandle Zip) { gui_msg("pb_install_detecting=Detecting Current Package"); - std::string system_br("system.new.dat"); - std::string system_("system.new.dat.br"); - std::string vendor_br("vendor.new.dat.br"); - std::string vendor_("vendor.new.dat"); - std::string bootimg("boot.img"); - ZipEntry miui_sg_entry; - int update_data[] = {FindEntry(Zip, miui_sg_path, &miui_sg_entry), - FindEntry(Zip, system_, nullptr), - FindEntry(Zip, system_br, nullptr), - FindEntry(Zip, vendor_, nullptr), - FindEntry(Zip, vendor_br, nullptr), - FindEntry(Zip, bootimg, nullptr) - }; + ZipEntry64 miui_sg_entry; + int update_data = FindEntry(Zip, miui_sg_path, &miui_sg_entry); string outp = TWFunc::Get_output("grep miui.ui.version " + std::string(TMP_UPDATER_BINARY_PATH)); - if (!update_data[3] || !update_data[4]) - { - chk_sdk = 27; - DataManager::SetValue(TRB_EN, 1); - } - else - chk_sdk = 26; - if ((outp.size() > 0 || !update_data[0]) && chk_sdk < 27) { - if (!update_data[1] || !update_data[2]) { - DataManager::SetValue(PB_MIUI_ZIP_TMP, 1); - } + if (outp.size() > 0 || !update_data) { + DataManager::SetValue(PB_MIUI_ZIP_TMP, 1); DataManager::SetValue(PB_CALL_DEACTIVATION, 1); - DataManager::SetValue(NON_STD, 1); - if (!update_data[0]) { - gui_msg("pb_install_miui_detected=- Detected Standard MIUI Update Package"); - } - else - gui_msg("pb_install_miui_10_detected=- Detected MIUI 10 Non-Treble Update Package"); + gui_msg("pb_install_miui_detected=- Detected MIUI Update Package"); } else { - if (outp.size() > 0 && chk_sdk >= 27) { - DataManager::SetValue(PB_MIUI_ZIP_TMP, 1); - DataManager::SetValue(PB_CALL_DEACTIVATION, 1); - trb_en = true; - gui_msg("pb_install_miui_oreo_detected=- Detected Treble MIUI Update Package"); - } - else if (!update_data[1] || !update_data[2]) { - DataManager::SetValue(PB_CALL_DEACTIVATION, 1); - DataManager::SetValue(STD, "1"); - gui_msg("pb_install_standard_detected=- Detected standard Package"); - } - else { - if (!update_data[3]) { - DataManager::SetValue(PB_CALL_DEACTIVATION, 1); - } - gui_msg("pb_install_patch_detected=- Detected Either a Patch or Fix Package"); - } + DataManager::SetValue(PB_CALL_DEACTIVATION, 1); + gui_msg("pb_install_standard_detected=- Detected standard Package"); } if (DataManager::GetIntValue(PB_INCREMENTAL_PACKAGE) != 0) { gui_msg("pb_incremental_ota_status_enabled=Support MIUI Incremental package status: Enabled"); - if (!update_data[0]) { + if (!update_data) { android::base::unique_fd take_out_metadata( open("/tmp/build.prop", O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, 0644)); if (ExtractEntryToFile(Zip, &miui_sg_entry, take_out_metadata)) { @@ -338,7 +297,7 @@ static int Prepare_Update_Binary(ZipArchiveHandle Zip) { } // If exists, extract file_contexts from the zip file std::string file_contexts("file_contexts"); - ZipEntry file_contexts_entry; + ZipEntry64 file_contexts_entry; if (FindEntry(Zip, file_contexts, &file_contexts_entry) != 0) { LOGINFO("Zip does not contain SELinux file_contexts file in its root.\n"); } else { @@ -529,7 +488,7 @@ int TWinstall_zip(const char* path, int* wipe_cache, bool check_for_digest) { time(&start); std::string update_binary_name(UPDATE_BINARY_NAME); - ZipEntry update_binary_entry; + ZipEntry64 update_binary_entry; if (FindEntry(Zip, update_binary_name, &update_binary_entry) == 0) { LOGINFO("Update binary zip\n"); // Additionally verify the compatibility of the package. @@ -548,7 +507,7 @@ int TWinstall_zip(const char* path, int* wipe_cache, bool check_for_digest) { } } else { std::string ab_binary_name(AB_OTA); - ZipEntry ab_binary_entry; + ZipEntry64 ab_binary_entry; if (FindEntry(Zip, ab_binary_name, &ab_binary_entry) == 0) { LOGINFO("AB zip\n"); // We need this so backuptool can do its magic @@ -578,7 +537,7 @@ int TWinstall_zip(const char* path, int* wipe_cache, bool check_for_digest) { } } else { std::string binary_name("ui.xml"); - ZipEntry binary_entry; + ZipEntry64 binary_entry; if (FindEntry(Zip, binary_name, &binary_entry) != 0) { LOGINFO("PBRP theme zip\n"); ret_val = Install_Theme(path, Zip); diff --git a/twrpinstall/verifier.cpp b/twrpinstall/verifier.cpp index 1fa8279a2..02ec987de 100755 --- a/twrpinstall/verifier.cpp +++ b/twrpinstall/verifier.cpp @@ -328,7 +328,7 @@ static std::vector IterateZipEntriesAndSearchForKeys(const ZipArchi std::vector result; std::string_view name; - ZipEntry entry; + ZipEntry64 entry; while ((iter_status = Next(cookie, &entry, &name)) == 0) { std::vector pem_content(entry.uncompressed_length); if (int32_t extract_status = diff --git a/variables.h b/variables.h index f235007a5..7784c0ee8 100755 --- a/variables.h +++ b/variables.h @@ -181,9 +181,6 @@ #define PB_DISABLE_REBOOT_OTA "pb_disable_reboot_ota" #define PB_MOUNT_SYSTEM_AS_ROOT "pb_mount_system_as_root" #define PB_FLASHLIGHT_THEME_SUPPORT "pb_flashlight_theme_support" -#define TRB_EN "0" -#define STD "0" -#define NON_STD "0" #define PB_TREBLE_COMP "pb_error_treble" #define PB_PROP_VALUE "pb_prop_value" #define PB_PROP_DEVICE "ro.product.device"