summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Pfetsch <spfetsch@google.com>2020-09-16 04:28:06 -0700
committerSteve Pfetsch <spfetsch@google.com>2020-09-16 18:17:24 +0000
commitb61a1b58155bea2702cb056494246c5a23fde525 (patch)
treee7564409af545add3910dae98e62bdbddfce1c2d
parent96395e89e7b8e44adebe85a9254e2e532cf238b2 (diff)
downloadredbull-b61a1b58155bea2702cb056494246c5a23fde525.tar.gz
[DO NOT MERGE] redbull: Fix race in init.twoshay.sh
Verify that the serial number is available before performing hash. Bug: 168173860 Signed-off-by: Steve Pfetsch <spfetsch@google.com> Change-Id: I32a4edb264cfbaeefa65a084f4681b22294e90a6
-rwxr-xr-xinit.twoshay.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/init.twoshay.sh b/init.twoshay.sh
index 16a3edc2..c5af3aa8 100755
--- a/init.twoshay.sh
+++ b/init.twoshay.sh
@@ -2,6 +2,19 @@
# Implementation of A/B group selection - See b/161398758
seedfile=/sys/devices/platform/soc/soc:qcom,dsi-display-primary/panel_info/panel0/serial_number
+
+# Poll the file for up to 30 seconds
+retries=30
+while [[ ! "$(cat $seedfile)" ]]; do
+ retries=$(($retries - 1))
+ if [[ $retries == 0 ]]; then
+ setprop vendor.twoshay.study_group "failed"
+ exit
+ fi
+
+ sleep 1
+done
+
sum=$(sha1sum $seedfile)
result=$(expr $((16#${sum:1:1})) % 2)