1*38e8c45fSAndroid Build Coastguard Worker#!/system/bin/sh 2*38e8c45fSAndroid Build Coastguard Worker 3*38e8c45fSAndroid Build Coastguard Worker# 4*38e8c45fSAndroid Build Coastguard Worker# Copyright (C) 2016 The Android Open Source Project 5*38e8c45fSAndroid Build Coastguard Worker# 6*38e8c45fSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 7*38e8c45fSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 8*38e8c45fSAndroid Build Coastguard Worker# You may obtain a copy of the License at 9*38e8c45fSAndroid Build Coastguard Worker# 10*38e8c45fSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 11*38e8c45fSAndroid Build Coastguard Worker# 12*38e8c45fSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 13*38e8c45fSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 14*38e8c45fSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15*38e8c45fSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 16*38e8c45fSAndroid Build Coastguard Worker# limitations under the License. 17*38e8c45fSAndroid Build Coastguard Worker# 18*38e8c45fSAndroid Build Coastguard Worker 19*38e8c45fSAndroid Build Coastguard Worker# This script will move artifacts for the currently active slot. 20*38e8c45fSAndroid Build Coastguard Worker 21*38e8c45fSAndroid Build Coastguard WorkerSLOT_SUFFIX=$(getprop ro.boot.slot_suffix) 22*38e8c45fSAndroid Build Coastguard Workerif test -n "$SLOT_SUFFIX" ; then 23*38e8c45fSAndroid Build Coastguard Worker if test -d /data/ota/$SLOT_SUFFIX/dalvik-cache ; then 24*38e8c45fSAndroid Build Coastguard Worker log -p i -t otapreopt_slot "Moving A/B artifacts for slot ${SLOT_SUFFIX}." 25*38e8c45fSAndroid Build Coastguard Worker OLD_SIZE=$(du -h -s /data/dalvik-cache) 26*38e8c45fSAndroid Build Coastguard Worker rm -rf /data/dalvik-cache/* 27*38e8c45fSAndroid Build Coastguard Worker NEW_SIZE=$(du -h -s /data/ota/$SLOT_SUFFIX/dalvik-cache) 28*38e8c45fSAndroid Build Coastguard Worker mv /data/ota/$SLOT_SUFFIX/dalvik-cache/* /data/dalvik-cache/ 29*38e8c45fSAndroid Build Coastguard Worker rmdir /data/ota/$SLOT_SUFFIX/dalvik-cache 30*38e8c45fSAndroid Build Coastguard Worker rmdir /data/ota/$SLOT_SUFFIX 31*38e8c45fSAndroid Build Coastguard Worker log -p i -t otapreopt_slot "Moved ${NEW_SIZE} over ${OLD_SIZE}" 32*38e8c45fSAndroid Build Coastguard Worker else 33*38e8c45fSAndroid Build Coastguard Worker log -p i -t otapreopt_slot "No A/B artifacts found for slot ${SLOT_SUFFIX}." 34*38e8c45fSAndroid Build Coastguard Worker fi 35*38e8c45fSAndroid Build Coastguard Worker exit 0 36*38e8c45fSAndroid Build Coastguard Workerelse 37*38e8c45fSAndroid Build Coastguard Worker log -p w -t otapreopt_slot "Slot property empty." 38*38e8c45fSAndroid Build Coastguard Worker exit 1 39*38e8c45fSAndroid Build Coastguard Workerfi 40