aidl: usb: gadget: Make gadget name configurable through soong
Change-Id: Ic91598d8ddee0f9254354786b7598e9f7377008d
diff --git a/aidl/usb/gadget/Android.bp b/aidl/usb/gadget/Android.bp
index 76e5fa9..5b84ad6 100644
--- a/aidl/usb/gadget/Android.bp
+++ b/aidl/usb/gadget/Android.bp
@@ -14,8 +14,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+soong_config_module_type {
+ name: "gadget_name",
+ module_type: "cc_defaults",
+ config_namespace: "samsungUsbGadgetVars",
+ value_variables: ["gadget_name"],
+ properties: ["cppflags"],
+}
+
+gadget_name {
+ name: "gadget_name_defaults",
+ soong_config_variables: {
+ gadget_name: {
+ cppflags: ["-DGADGET_NAME=\"%s\""],
+ },
+ },
+}
+
cc_binary {
name: "android.hardware.usb.gadget-service.samsung",
+ defaults: ["gadget_name_defaults"],
relative_install_path: "hw",
init_rc: ["android.hardware.usb.gadget-service.samsung.rc"],
vintf_fragments: [
diff --git a/aidl/usb/gadget/UsbGadget.h b/aidl/usb/gadget/UsbGadget.h
index 8ddd03a..8d46f69 100644
--- a/aidl/usb/gadget/UsbGadget.h
+++ b/aidl/usb/gadget/UsbGadget.h
@@ -67,9 +67,9 @@
using ::std::shared_ptr;
using ::std::string;
-constexpr char kGadgetName[] = "10c00000.dwc3";
+constexpr char kGadgetName[] = GADGET_NAME;
#ifndef UDC_PATH
-#define UDC_PATH "/sys/class/udc/10c00000.dwc3/"
+#define UDC_PATH "/sys/class/udc/" GADGET_NAME "/"
#endif
static MonitorFfs monitorFfs(kGadgetName);