RMX3031: libinit: Fix adb in recovery mode

Signed-off-by: Nishant Kumar <www.rajsonu13@gmail.com>
This commit is contained in:
sebaubuntu
2023-03-07 16:11:37 +05:30
committed by Nishant Kumar
parent cb2e932b97
commit 753ea1bf83
5 changed files with 103 additions and 0 deletions

View File

@@ -165,6 +165,10 @@ TARGET_USERIMAGES_USE_F2FS := true
# HWUI
TARGET_USES_VULKAN := true
# Init
TARGET_INIT_VENDOR_LIB ?= //$(DEVICE_PATH):init_RMX3031
TARGET_RECOVERY_DEVICE_MODULES ?= init_RMX3031
# Ril
ENABLE_VENDOR_RIL_SERVICE := true

23
libinit/Android.bp Normal file
View File

@@ -0,0 +1,23 @@
//
// Copyright (C) 2021 The LineageOS Project
//
// SPDX-License-Identifier: Apache-2.0
//
cc_library_static {
name: "libinit_RMX3031",
srcs: [
"libinit_utils.cpp",
],
whole_static_libs: ["libbase"],
export_include_dirs: ["include"],
recovery_available: true,
}
cc_library_static {
name: "init_RMX3031",
srcs: ["init_RMX3031.cpp"],
whole_static_libs: ["libinit_RMX3031"],
include_dirs: ["system/core/init"],
recovery_available: true,
}

View File

@@ -0,0 +1,16 @@
/*
* Copyright (C) 2021 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef LIBINIT_UTILS_H
#define LIBINIT_UTILS_H
#include <string>
void property_override(std::string prop, std::string value, bool add = true);
void set_ro_build_prop(const std::string &prop, const std::string &value, bool product = false);
#endif // LIBINIT_UTILS_H

18
libinit/init_RMX3031.cpp Normal file
View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <android-base/logging.h>
#include <libinit_utils.h>
#include "vendor_init.h"
void vendor_load_properties() {
if (access("/system/bin/recovery", F_OK) == 0) {
property_override("ro.adb.secure", "0");
property_override("ro.debuggable", "1");
property_override("ro.adb.secure.recovery", "0");
property_override("persist.sys.usb.config", "adb");
}
}

42
libinit/libinit_utils.cpp Normal file
View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2021 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
#include <vector>
#include <libinit_utils.h>
void property_override(std::string prop, std::string value, bool add) {
auto pi = (prop_info *) __system_property_find(prop.c_str());
if (pi != nullptr) {
__system_property_update(pi, value.c_str(), value.length());
} else if (add) {
__system_property_add(prop.c_str(), prop.length(), value.c_str(), value.length());
}
}
std::vector<std::string> ro_props_default_source_order = {
"odm.",
"product.",
"system.",
"system_ext.",
"vendor.",
"",
};
void set_ro_build_prop(const std::string &prop, const std::string &value, bool product) {
std::string prop_name;
for (const auto &source : ro_props_default_source_order) {
if (product)
prop_name = "ro.product." + source + prop;
else
prop_name = "ro." + source + "build." + prop;
property_override(prop_name, value, true);
}
}