init.qcom.usb.sh: Pass blank MSM serial number for virtual Android
In Android GVM env, the path '/sys/devices/soc0/serial_number'
does not exist because SMEM is not virtualized. So the
msm_serial_hex gets updated to 0x00000000. This differs from MSM
serial number in EDL mode (it has access to SMEM). This leads to
external automation tools treating the same target as two
different devices in EDL and Android HLOS modes respectively.
Such confusion does not exist if the MSM serial number is blank.
Keep msm_serial_hex blank for Android GVM case.
Change-Id: I8e60909927234753b15d5287e12df2be75b0fe5d
diff --git a/etc/init.qcom.usb.sh b/etc/init.qcom.usb.sh
index 0c02328..a7e7faf 100644
--- a/etc/init.qcom.usb.sh
+++ b/etc/init.qcom.usb.sh
@@ -1,5 +1,5 @@
#!/vendor/bin/sh
-# Copyright (c) 2012-2018, 2020 The Linux Foundation. All rights reserved.
+# Copyright (c) 2012-2018, 2020-2021 The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -144,7 +144,11 @@
if [ -d /config/usb_gadget ]; then
# Chip-serial is used for unique MSM identification in Product string
msm_serial=`cat /sys/devices/soc0/serial_number`;
- msm_serial_hex=`printf %08X $msm_serial`
+ # If MSM serial number is not available, then keep it blank instead of 0x00000000
+ if [ "$msm_serial" != "" ]; then
+ msm_serial_hex=`printf %08X $msm_serial`
+ fi
+
machine_type=`cat /sys/devices/soc0/machine`
setprop vendor.usb.product_string "$machine_type-$soc_hwplatform _SN:$msm_serial_hex"