From d075702d0fd3e22d854aefdee3828644ff606c9c Mon Sep 17 00:00:00 2001 From: Vijayavardhan Vennapusa Date: Wed, 17 May 2017 10:39:41 +0530 Subject: [PATCH] init.qcom.usb.sh: Check serialnumber value before writing dummy value Currently .rc updates serialnumber from ro.serialno on boot and before enabling .sh to execute. Once .sh starts executing, it tries to read ro.serialno and if it shows empty string, it tries to write dummy value for adb interface to work properly. But it happens that .sh couldn't access ro.serialno due to sepolicy permission and in that .sh endup overriding serialnumber with dummy value. This causes all devices get same dummy value instead of having different serialnumber for each hardware. Fix the issue by checking serialnumber in .sh if it is already updated by .rc rule or not and write dummy value to serialnumber sysfs entry only if it is empty. Change-Id: Ie07dfa6f05d9847800143b4c318c55367e865935 --- rootdir/etc/init.qcom.usb.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rootdir/etc/init.qcom.usb.sh b/rootdir/etc/init.qcom.usb.sh index 95af4f5c..bcb9f2f0 100644 --- a/rootdir/etc/init.qcom.usb.sh +++ b/rootdir/etc/init.qcom.usb.sh @@ -217,11 +217,11 @@ if [ -d /config/usb_gadget ]; then echo "$product_string" > /config/usb_gadget/g1/strings/0x409/product # ADB requires valid iSerialNumber; if ro.serialno is missing, use dummy - serialno=`getprop ro.serialno` - if [ "$serialno" == "" ]; then - serialno=1234567 + serialnumber=`cat /config/usb_gadget/g1/strings/0x409/serialnumber` 2> /dev/null + if [ "$serialnumber" == "" ]; then + serialno=1234567 + echo $serialno > /config/usb_gadget/g1/strings/0x409/serialnumber fi - echo $serialno > /config/usb_gadget/g1/strings/0x409/serialnumber persist_comp=`getprop persist.sys.usb.config` comp=`getprop sys.usb.config`