101ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe#!/system/bin/sh 201ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe 301ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# 401ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# Copyright (C) 2016 The Android Open Source Project 501ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# 601ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# Licensed under the Apache License, Version 2.0 (the "License"); 701ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# you may not use this file except in compliance with the License. 801ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# You may obtain a copy of the License at 901ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# 1001ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# http://www.apache.org/licenses/LICENSE-2.0 1101ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# 1201ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# Unless required by applicable law or agreed to in writing, software 1301ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# distributed under the License is distributed on an "AS IS" BASIS, 1401ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1501ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# See the License for the specific language governing permissions and 1601ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# limitations under the License. 1701ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# 1801ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe 1901ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# This script will run as a postinstall step to drive otapreopt. 2001ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe 2101ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe# Maximum number of packages/steps. 2201ad5984dd202311a7e301c8c771a5d4b7c76136Andreas GampeMAXIMUM_PACKAGES=1000 2301ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe 2401ad5984dd202311a7e301c8c771a5d4b7c76136Andreas GampePREPARE=$(cmd otadexopt prepare) 2501ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampeif [ "$PREPARE" != "Success" ] ; then 2601ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe echo "Failed to prepare." 2701ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe exit 1 2801ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampefi 2901ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe 3001ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampei=0 3101ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampewhile ((i<MAXIMUM_PACKAGES)) ; do 3201ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe cmd otadexopt step 3301ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe DONE=$(cmd otadexopt done) 3401ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe if [ "$DONE" = "OTA complete." ] ; then 3501ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe break 3601ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe fi 3701ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe sleep 1 3801ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe i=$((i+1)) 3901ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampedone 4001ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe 4101ad5984dd202311a7e301c8c771a5d4b7c76136Andreas GampeDONE=$(cmd otadexopt done) 4201ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampeif [ "$DONE" = "OTA incomplete." ] ; then 4301ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe echo "Incomplete." 4401ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampeelse 4501ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe echo "Complete or error." 4601ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampefi 4701ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe 4801ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampecmd otadexopt cleanup 4901ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampe 5001ad5984dd202311a7e301c8c771a5d4b7c76136Andreas Gampeexit 0 51