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 move artifacts for the currently active slot. 20 21SLOT_SUFFIX=$(getprop ro.boot.slot_suffix) 22if test -n "$SLOT_SUFFIX" ; then 23 if test -d /data/ota/$SLOT_SUFFIX/dalvik-cache ; then 24 log -p i -t otapreopt_slot "Moving A/B artifacts for slot ${SLOT_SUFFIX}." 25 OLD_SIZE=$(du -h -s /data/dalvik-cache) 26 rm -rf /data/dalvik-cache/* 27 NEW_SIZE=$(du -h -s /data/ota/$SLOT_SUFFIX/dalvik-cache) 28 mv /data/ota/$SLOT_SUFFIX/dalvik-cache/* /data/dalvik-cache/ 29 rmdir /data/ota/$SLOT_SUFFIX/dalvik-cache 30 rmdir /data/ota/$SLOT_SUFFIX 31 log -p i -t otapreopt_slot "Moved ${NEW_SIZE} over ${OLD_SIZE}" 32 else 33 log -p i -t otapreopt_slot "No A/B artifacts found for slot ${SLOT_SUFFIX}." 34 fi 35 exit 0 36else 37 log -p w -t otapreopt_slot "Slot property empty." 38 exit 1 39fi 40