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
This commit is contained in:
Vijayavardhan Vennapusa 2017-05-17 10:39:41 +05:30
parent 15db7a3e5e
commit d075702d0f
1 changed files with 4 additions and 4 deletions

View File

@ -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`