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 | |
Andreas Gampe | 64c4038 | 2016-06-10 15:08:53 -0700 | [diff] [blame^] | 21 | STATUS_FD="$2" |
| 22 | |
Andreas Gampe | 01ad598 | 2016-03-09 16:27:29 -0800 | [diff] [blame] | 23 | # Maximum number of packages/steps. |
| 24 | MAXIMUM_PACKAGES=1000 |
| 25 | |
| 26 | PREPARE=$(cmd otadexopt prepare) |
Andreas Gampe | 64c4038 | 2016-06-10 15:08:53 -0700 | [diff] [blame^] | 27 | # Note: Ignore preparation failures. Step and done will fail and exit this. |
| 28 | # This is necessary to support suspends - the OTA service will keep |
| 29 | # the state around for us. |
| 30 | |
| 31 | PROGRESS=$(cmd otadexopt progress) |
| 32 | print -u${STATUS_FD} "global_progress $PROGRESS" |
Andreas Gampe | 01ad598 | 2016-03-09 16:27:29 -0800 | [diff] [blame] | 33 | |
| 34 | i=0 |
| 35 | while ((i<MAXIMUM_PACKAGES)) ; do |
| 36 | cmd otadexopt step |
Andreas Gampe | 64c4038 | 2016-06-10 15:08:53 -0700 | [diff] [blame^] | 37 | |
| 38 | PROGRESS=$(cmd otadexopt progress) |
| 39 | print -u${STATUS_FD} "global_progress $PROGRESS" |
| 40 | |
Andreas Gampe | 01ad598 | 2016-03-09 16:27:29 -0800 | [diff] [blame] | 41 | DONE=$(cmd otadexopt done) |
Andreas Gampe | 64c4038 | 2016-06-10 15:08:53 -0700 | [diff] [blame^] | 42 | if [ "$DONE" = "OTA incomplete." ] ; then |
| 43 | sleep 1 |
| 44 | i=$((i+1)) |
| 45 | continue |
Andreas Gampe | 01ad598 | 2016-03-09 16:27:29 -0800 | [diff] [blame] | 46 | fi |
Andreas Gampe | 64c4038 | 2016-06-10 15:08:53 -0700 | [diff] [blame^] | 47 | break |
Andreas Gampe | 01ad598 | 2016-03-09 16:27:29 -0800 | [diff] [blame] | 48 | done |
| 49 | |
| 50 | DONE=$(cmd otadexopt done) |
| 51 | if [ "$DONE" = "OTA incomplete." ] ; then |
| 52 | echo "Incomplete." |
| 53 | else |
| 54 | echo "Complete or error." |
| 55 | fi |
| 56 | |
Andreas Gampe | 64c4038 | 2016-06-10 15:08:53 -0700 | [diff] [blame^] | 57 | print -u${STATUS_FD} "global_progress 1.0" |
Andreas Gampe | 01ad598 | 2016-03-09 16:27:29 -0800 | [diff] [blame] | 58 | cmd otadexopt cleanup |
| 59 | |
| 60 | exit 0 |