summaryrefslogtreecommitdiff
path: root/usb
diff options
context:
space:
mode:
authorraychi <raychi@google.com>2019-05-06 16:31:32 +0800
committerMichael Bestas <mkbestas@lineageos.org>2022-09-20 01:10:07 +0300
commitc35cbbc8028f3ce736ce416050d69e9e94bda6ab (patch)
treebd3e725a744b1cd5f7bfc678b03c1ebd672fc263 /usb
parent8a685b178e2bf79750ada03c294854bfe44c8cb1 (diff)
Do not enable the funcion when it is not in list
rndis and rmnet cannot co-exist in QCOM spec and cause ramdump. Besides, enabling functions with the wrong PID may cause it cannot install proper PC driver on Windows. A better way is to not allow enabling the function which is not in support list. Bug: 130733202 Test: enable tethering with/without rmnet enabled Signed-off-by: raychi <raychi@google.com> (cherry picked from commit 79ef1d2d35f3e00ce8ab98ff4a3430af579a5419 and fix merge conflict) Change-Id: Ia50058f498c5b99ff58251fd7064963ccdbdd940
Diffstat (limited to 'usb')
-rw-r--r--usb/UsbGadget.cpp89
1 files changed, 58 insertions, 31 deletions
diff --git a/usb/UsbGadget.cpp b/usb/UsbGadget.cpp
index 14feeb7e..a2c51ea4 100644
--- a/usb/UsbGadget.cpp
+++ b/usb/UsbGadget.cpp
@@ -345,18 +345,24 @@ static V1_0::Status validateAndSetVidPid(uint64_t functions) {
if (vendorFunctions == "diag") {
ret = setVidPid("0x05C6", "0x901B");
} else {
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee1");
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee1");
+ }
}
break;
case GadgetFunction::ADB | GadgetFunction::MTP:
if (vendorFunctions == "diag") {
ret = setVidPid("0x05C6", "0x903A");
} else {
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee2");
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee2");
+ }
}
break;
case static_cast<uint64_t>(GadgetFunction::RNDIS):
@@ -365,9 +371,12 @@ static V1_0::Status validateAndSetVidPid(uint64_t functions) {
} else if (vendorFunctions == "serial_cdev,diag") {
ret = setVidPid("0x05C6", "0x90B5");
} else {
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee3");
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee3");
+ }
}
break;
case GadgetFunction::ADB | GadgetFunction::RNDIS:
@@ -376,21 +385,30 @@ static V1_0::Status validateAndSetVidPid(uint64_t functions) {
} else if (vendorFunctions == "serial_cdev,diag") {
ret = setVidPid("0x05C6", "0x90B6");
} else {
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee4");
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee4");
+ }
}
break;
case static_cast<uint64_t>(GadgetFunction::PTP):
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee5");
- break;
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee5");
+ }
+ break;
case GadgetFunction::ADB | GadgetFunction::PTP:
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee6");
- break;
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee6");
+ }
+ break;
case static_cast<uint64_t>(GadgetFunction::ADB):
if (vendorFunctions == "diag") {
ret = setVidPid("0x05C6", "0x901D");
@@ -399,21 +417,30 @@ static V1_0::Status validateAndSetVidPid(uint64_t functions) {
} else if (vendorFunctions == "diag,serial_cdev") {
ret = setVidPid("0x05C6", "0x901F");
} else {
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee7");
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee7");
+ }
}
break;
case static_cast<uint64_t>(GadgetFunction::MIDI):
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee8");
- break;
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee8");
+ }
+ break;
case GadgetFunction::ADB | GadgetFunction::MIDI:
- if (!(vendorFunctions == "user" || vendorFunctions == ""))
- ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
- ret = setVidPid("0x18d1", "0x4ee9");
- break;
+ if (!(vendorFunctions == "user" || vendorFunctions == "")) {
+ ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());
+ ret = Status::CONFIGURATION_NOT_SUPPORTED;
+ } else {
+ ret = setVidPid("0x18d1", "0x4ee9");
+ }
+ break;
case static_cast<uint64_t>(GadgetFunction::ACCESSORY):
if (!(vendorFunctions == "user" || vendorFunctions == ""))
ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());