Andreas Gampe | 01ad598 | 2016-03-09 16:27:29 -0800 | [diff] [blame] | 1 | #!/system/bin/sh |
| 2 | |
| 3 | # |
| 4 | # Copyright (C) 2016 The Android Open Source Project |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | |
| 19 | # This script will run as a postinstall step to drive otapreopt. |
| 20 | |
| 21 | # Maximum number of packages/steps. |
| 22 | MAXIMUM_PACKAGES=1000 |
| 23 | |
| 24 | PREPARE=$(cmd otadexopt prepare) |
| 25 | if [ "$PREPARE" != "Success" ] ; then |
| 26 | echo "Failed to prepare." |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | i=0 |
| 31 | while ((i<MAXIMUM_PACKAGES)) ; do |
| 32 | cmd otadexopt step |
| 33 | DONE=$(cmd otadexopt done) |
| 34 | if [ "$DONE" = "OTA complete." ] ; then |
| 35 | break |
| 36 | fi |
| 37 | sleep 1 |
| 38 | i=$((i+1)) |
| 39 | done |
| 40 | |
| 41 | DONE=$(cmd otadexopt done) |
| 42 | if [ "$DONE" = "OTA incomplete." ] ; then |
| 43 | echo "Incomplete." |
| 44 | else |
| 45 | echo "Complete or error." |
| 46 | fi |
| 47 | |
| 48 | cmd otadexopt cleanup |
| 49 | |
| 50 | exit 0 |