Merge tag 'LA.UM.9.12.r1-15200-SMxx50.QSSI13.0' into int/13/fp4
"LA.UM.9.12.r1-15200-SMxx50.QSSI13.0"
* tag 'LA.UM.9.12.r1-15200-SMxx50.QSSI13.0':
USB: Solving path traversal issue in USB HAL AppendNodeMapper
UsbGadgetHal: Add null check in getCurrentUsbFunctions()
USB: HAL: handling readFile failure on device path
init.qcom.usb.sh: Set default composition for msmnile
init.qcom.usb.sh: Set default composition to 0x901D for msmnile
Change-Id: Ibfda2c97b78f1d091d3edfcc142b931e19f87e8e
diff --git a/etc/init.qcom.usb.sh b/etc/init.qcom.usb.sh
index 7e33c83..5e8a099 100644
--- a/etc/init.qcom.usb.sh
+++ b/etc/init.qcom.usb.sh
@@ -101,7 +101,17 @@
"sdm845" | "sdm710")
setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
;;
- "msmnile" | "sm6150" | "trinket" | "lito" | "atoll" | "bengal" | "lahaina" | "holi")
+ "msmnile")
+ case "$soc_id" in
+ "362" | "367")
+ setprop persist.vendor.usb.config diag,adb
+ ;;
+ *)
+ setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,qdss,adb
+ ;;
+ esac
+ ;;
+ "sm6150" | "trinket" | "lito" | "atoll" | "bengal" | "lahaina" | "holi")
setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,qdss,adb
;;
"monaco")
diff --git a/hal/Usb.cpp b/hal/Usb.cpp
index e522979..01fc78e 100644
--- a/hal/Usb.cpp
+++ b/hal/Usb.cpp
@@ -103,17 +103,23 @@
std::string appendRoleNodeHelper(const std::string &portName,
PortRoleType type) {
- std::string node("/sys/class/typec/" + portName);
- switch (type) {
- case PortRoleType::DATA_ROLE:
- return node + "/data_role";
- case PortRoleType::POWER_ROLE:
- return node + "/power_role";
- case PortRoleType::MODE:
- return node + "/port_type";
- default:
- return "";
+ if ((portName == "..") || (portName.find('/') != std::string::npos)) {
+ ALOGE("Fatal: invalid portName");
+ return "";
+ }
+
+ std::string node("/sys/class/typec/" + portName);
+
+ switch (type) {
+ case PortRoleType::DATA_ROLE:
+ return node + "/data_role";
+ case PortRoleType::POWER_ROLE:
+ return node + "/power_role";
+ case PortRoleType::MODE:
+ return node + "/port_type";
+ default:
+ return "";
}
}
@@ -1024,9 +1030,16 @@
static bool checkUsbInterfaceAutoSuspend(const std::string& devicePath,
const std::string &intf) {
std::string bInterfaceClass;
- int interfaceClass, ret = -1;
+ int interfaceClass, ret = -1, retry = 3;
- readFile(devicePath + "/" + intf + "/bInterfaceClass", &bInterfaceClass);
+ do {
+ readFile(devicePath + "/" + intf + "/bInterfaceClass",
+ &bInterfaceClass);
+ } while ((--retry > 0) && (bInterfaceClass.length() == 0));
+
+ if (bInterfaceClass.length() == 0) {
+ return false;
+ }
interfaceClass = std::stoi(bInterfaceClass, 0, 16);
// allow autosuspend for certain class devices
diff --git a/hal/UsbGadget.cpp b/hal/UsbGadget.cpp
index 3757671..78e73d5 100644
--- a/hal/UsbGadget.cpp
+++ b/hal/UsbGadget.cpp
@@ -233,6 +233,8 @@
Return<void> UsbGadget::getCurrentUsbFunctions(
const sp<V1_0::IUsbGadgetCallback> &callback) {
+ if (!callback) return Void();
+
Return<void> ret = callback->getCurrentUsbFunctionsCb(
mCurrentUsbFunctions, mCurrentUsbFunctionsApplied
? Status::FUNCTIONS_APPLIED