diff --git a/usb/UsbGadget.cpp b/usb/UsbGadget.cpp index 66ac85e5..e5c37a6a 100644 --- a/usb/UsbGadget.cpp +++ b/usb/UsbGadget.cpp @@ -311,18 +311,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(GadgetFunction::RNDIS): @@ -331,9 +337,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: @@ -342,21 +351,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(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(GadgetFunction::ADB): if (vendorFunctions == "diag") { ret = setVidPid("0x05C6", "0x901D"); @@ -365,21 +383,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(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(GadgetFunction::ACCESSORY): if (!(vendorFunctions == "user" || vendorFunctions == "")) ALOGE("Invalid vendorFunctions set: %s", vendorFunctions.c_str());