Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a76596a3 authored by jhenrique09's avatar jhenrique09 Committed by Rohit Sekhar
Browse files

init: Set persist.sys.usb.config properly

Change-Id: I5921d0657004c698046c1fb608802c7fdc193023

Former-commit-id: ce2919b342ef019a30e8094739eefdd1ac824e7b
parent cc0d2dd2
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -768,13 +768,13 @@ static void LoadPropertiesFromSecondStageRes(std::map<std::string, std::string>*
// So we need to apply the same rule of build/make/tools/post_process_props.py
// on runtime.
static void update_sys_usb_config() {
    bool is_debuggable = android::base::GetBoolProperty("ro.debuggable", false);
    bool is_secure = android::base::GetBoolProperty("ro.adb.secure", true);
    std::string config = android::base::GetProperty("persist.sys.usb.config", "");
    // b/150130503, add (config == "none") condition here to prevent appending
    // ",adb" if "none" is explicitly defined in default prop.
    if (config.empty() || config == "none") {
        InitPropertySet("persist.sys.usb.config", is_debuggable ? "adb" : "none");
    } else if (is_debuggable && config.find("adb") == std::string::npos &&
        InitPropertySet("persist.sys.usb.config", !is_secure ? "adb" : "none");
    } else if (!is_secure && config.find("adb") == std::string::npos &&
               config.length() + 4 < PROP_VALUE_MAX) {
        config.append(",adb");
        InitPropertySet("persist.sys.usb.config", config);