Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events : Change preferences for haptics vars #93

Open
wants to merge 5 commits into
base: android-11.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion gui/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions libblkid/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
71 changes: 71 additions & 0 deletions libblkid/src/superblocks/erofs.c
Original file line number Diff line number Diff line change
@@ -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 <stddef.h>
#include <string.h>

#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 }
}
};
3 changes: 2 additions & 1 deletion libblkid/src/superblocks/superblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ static const struct blkid_idinfo *idinfos[] =
&befs_idinfo,
&nilfs2_idinfo,
&exfat_idinfo,
&f2fs_idinfo
&f2fs_idinfo,
&erofs_idinfo
};

/*
Expand Down
1 change: 1 addition & 0 deletions libblkid/src/superblocks/superblocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions minuitwrp/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<android::hardware::vibrator::V1_2::IVibrator> 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<IVibrator> vib = IVibrator::fromBinder(ndk::SpAIBinder(AServiceManager_getService(kVibratorInstance.c_str())));
if (vib != nullptr) {
Expand All @@ -161,10 +160,11 @@ int vibrate(int timeout_ms)
write_to_file(VIBRATOR_TIMEOUT_FILE, tout);
}
#else
android::sp<android::hardware::vibrator::V1_2::IVibrator> 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;
}
Expand Down
1 change: 1 addition & 0 deletions partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions twrp-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion twrpinstall/ZipUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool ExtractPackageRecursive(ZipArchiveHandle zip, const std::string& zip_path,
}

std::unique_ptr<void, decltype(&EndIteration)> guard(cookie, EndIteration);
ZipEntry entry;
ZipEntry64 entry;
ZipString name;
int extractCount = 0;
while (Next(cookie, &entry, &name) == 0) {
Expand Down
14 changes: 7 additions & 7 deletions twrpinstall/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bool ReadMetadataFromPackage(ZipArchiveHandle zip, std::map<std::string, std::st

static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata";
std::string path(METADATA_PATH);
ZipEntry entry;
ZipEntry64 entry;
if (FindEntry(zip, path, &entry) != 0) {
LOG(ERROR) << "Failed to find " << METADATA_PATH;
return false;
Expand Down Expand Up @@ -235,7 +235,7 @@ int SetUpAbUpdateCommands(const std::string& package, ZipArchiveHandle zip, int
// in the zip file.
static constexpr const char* AB_OTA_PAYLOAD_PROPERTIES = "payload_properties.txt";
std::string property_name(AB_OTA_PAYLOAD_PROPERTIES);
ZipEntry properties_entry;
ZipEntry64 properties_entry;
if (FindEntry(zip, property_name, &properties_entry) != 0) {
LOG(ERROR) << "Failed to find " << AB_OTA_PAYLOAD_PROPERTIES;
return INSTALL_CORRUPT;
Expand All @@ -251,7 +251,7 @@ int SetUpAbUpdateCommands(const std::string& package, ZipArchiveHandle zip, int

static constexpr const char* AB_OTA_PAYLOAD = "payload.bin";
std::string payload_name(AB_OTA_PAYLOAD);
ZipEntry payload_entry;
ZipEntry64 payload_entry;
if (FindEntry(zip, payload_name, &payload_entry) != 0) {
LOG(ERROR) << "Failed to find " << AB_OTA_PAYLOAD;
return INSTALL_CORRUPT;
Expand All @@ -273,7 +273,7 @@ int SetUpNonAbUpdateCommands(const std::string& package, ZipArchiveHandle zip, i

// In non-A/B updates we extract the update binary from the package.
std::string binary_name(UPDATE_BINARY_NAME);
ZipEntry binary_entry;
ZipEntry64 binary_entry;
if (FindEntry(zip, binary_name, &binary_entry) != 0) {
LOG(ERROR) << "Failed to find update binary " << UPDATE_BINARY_NAME;
return INSTALL_CORRUPT;
Expand Down Expand Up @@ -390,7 +390,7 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b

is_ab = false;
std::string binary_name(UPDATE_BINARY_NAME);
ZipEntry binary_entry;
ZipEntry64 binary_entry;
if (FindEntry(zip, binary_name, &binary_entry) != 0) {
LOG(ERROR) << "Failed to find update binary " << UPDATE_BINARY_NAME;
is_ab = true;
Expand Down Expand Up @@ -521,7 +521,7 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b

// static constexpr const char* COMPATIBILITY_ZIP_ENTRY = "compatibility.zip";
// ZipString compatibility_entry_name(COMPATIBILITY_ZIP_ENTRY);
// ZipEntry compatibility_entry;
// ZipEntry64 compatibility_entry;
// if (FindEntry(package_zip, compatibility_entry_name, &compatibility_entry) != 0) {
// LOG(INFO) << "Package doesn't contain " << COMPATIBILITY_ZIP_ENTRY << " entry";
// return true;
Expand Down Expand Up @@ -555,7 +555,7 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b
// std::unique_ptr<void, decltype(&EndIteration)> guard(cookie, EndIteration);

// std::vector<std::string> 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');
Expand Down
10 changes: 5 additions & 5 deletions twrpinstall/installcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -313,7 +313,7 @@ bool verify_package_compatibility(ZipArchiveHandle zw) {
std::unique_ptr<void, decltype(&EndIteration)> guard(cookie, EndIteration);

std::vector<std::string> 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');
Expand Down
Loading