From bb578203a66b677dce252447318fe05ab80b94b8 Mon Sep 17 00:00:00 2001 From: Howard Yen Date: Wed, 26 Feb 2020 21:36:59 +0800 Subject: [PATCH] init: prevent persist.sys.usb.config initalized as none,adb Prevent appending ",adb" to persist.sys.usb.config if "none" is explicitly defined in default prop. Bug: 150130503 Test: persist.sys.usb.config initalized correctly Change-Id: I3b5de6fd102e252019e843f39f0875f5aaea7486 Merged-In: I3b5de6fd102e252019e843f39f0875f5aaea7486 --- init/property_service.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index b140ee438..319a241c7 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -813,7 +813,9 @@ static bool load_properties_from_file(const char* filename, const char* filter, static void update_sys_usb_config() { bool is_debuggable = android::base::GetBoolProperty("ro.debuggable", false); std::string config = android::base::GetProperty("persist.sys.usb.config", ""); - if (config.empty()) { + // 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 && config.length() + 4 < PROP_VALUE_MAX) {