blob: 394c24433655be8c5431f70728e7f346b65357f0 [file] [log] [blame]
Andreas Gampe01ad5982016-03-09 16:27:29 -08001#!/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 Gampe64c40382016-06-10 15:08:53 -070021STATUS_FD="$2"
22
Andreas Gampe01ad5982016-03-09 16:27:29 -080023# Maximum number of packages/steps.
24MAXIMUM_PACKAGES=1000
25
26PREPARE=$(cmd otadexopt prepare)
Andreas Gampe64c40382016-06-10 15:08:53 -070027# 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
31PROGRESS=$(cmd otadexopt progress)
32print -u${STATUS_FD} "global_progress $PROGRESS"
Andreas Gampe01ad5982016-03-09 16:27:29 -080033
34i=0
35while ((i<MAXIMUM_PACKAGES)) ; do
36 cmd otadexopt step
Andreas Gampe64c40382016-06-10 15:08:53 -070037
38 PROGRESS=$(cmd otadexopt progress)
39 print -u${STATUS_FD} "global_progress $PROGRESS"
40
Andreas Gampe01ad5982016-03-09 16:27:29 -080041 DONE=$(cmd otadexopt done)
Andreas Gampe64c40382016-06-10 15:08:53 -070042 if [ "$DONE" = "OTA incomplete." ] ; then
43 sleep 1
44 i=$((i+1))
45 continue
Andreas Gampe01ad5982016-03-09 16:27:29 -080046 fi
Andreas Gampe64c40382016-06-10 15:08:53 -070047 break
Andreas Gampe01ad5982016-03-09 16:27:29 -080048done
49
50DONE=$(cmd otadexopt done)
51if [ "$DONE" = "OTA incomplete." ] ; then
52 echo "Incomplete."
53else
54 echo "Complete or error."
55fi
56
Andreas Gampe64c40382016-06-10 15:08:53 -070057print -u${STATUS_FD} "global_progress 1.0"
Andreas Gampe01ad5982016-03-09 16:27:29 -080058cmd otadexopt cleanup
59
60exit 0