Revert "Move otadexopt-related logic to otapreopt_chroot binary"

Revert "Allow otapreopt_chroot to call otadexopt binder service"

Revert submission 1750144-otapreopt_chroot_speed_up

Reason for revert: Breaks postinstall step on some devices
Reverted Changes:
I56dec13c8:Add ota_dexopt_aidl_interface
Ib32cbbbf8:Allow otapreopt_chroot to call otadexopt binder se...
I02e80a8e6:Move otadexopt-related logic to otapreopt_chroot b...

Bug: 190817237
Change-Id: If090e0cbf8d086b41c0b22a42b5daf4561954156
diff --git a/cmds/installd/otapreopt_script.sh b/cmds/installd/otapreopt_script.sh
index 8bcbc9f..f950276 100644
--- a/cmds/installd/otapreopt_script.sh
+++ b/cmds/installd/otapreopt_script.sh
@@ -58,7 +58,23 @@
 PROGRESS=$(cmd otadexopt progress)
 print -u${STATUS_FD} "global_progress $PROGRESS"
 
-/system/bin/otapreopt_chroot $STATUS_FD $TARGET_SLOT_SUFFIX $DEXOPT_PARAMS >&- 2>&-
+i=0
+while ((i<MAXIMUM_PACKAGES)) ; do
+  DEXOPT_PARAMS=$(cmd otadexopt next)
+
+  /system/bin/otapreopt_chroot $STATUS_FD $TARGET_SLOT_SUFFIX $DEXOPT_PARAMS >&- 2>&-
+
+  PROGRESS=$(cmd otadexopt progress)
+  print -u${STATUS_FD} "global_progress $PROGRESS"
+
+  DONE=$(cmd otadexopt done)
+  if [ "$DONE" = "OTA incomplete." ] ; then
+    sleep 1
+    i=$((i+1))
+    continue
+  fi
+  break
+done
 
 DONE=$(cmd otadexopt done)
 if [ "$DONE" = "OTA incomplete." ] ; then