1#!/bin/bash 2# 3# Copyright (C) 2020 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# 18# This script configures a device for boot image profile 19# 20 21if [[ -z "$ANDROID_BUILD_TOP" ]]; then 22 echo "You must run on this after running envsetup.sh and launch target" 23 exit 1 24fi 25 26if [[ "$#" -lt 1 ]]; then 27 echo "Usage $0 <output-for-boot-zip>" 28 echo "Example: $0 boot.zip" 29 exit 1 30fi 31 32OUT_BOOT_ZIP="$1" 33 34echo "Changing dirs to the build top" 35cd "$ANDROID_BUILD_TOP" 36 37# Make dist in order to easily get the boot and system server dex files 38# This will be stored in $ANDROID_PRODUCT_OUT/boot.zip 39echo "Make dist" 40m dist 41echo "Copy boot.zip to $OUT_BOOT_ZIP" 42cp "$ANDROID_PRODUCT_OUT"/boot.zip $OUT_BOOT_ZIP 43 44echo "Setting properties and clearing existing profiles" 45# If the device needs to be rebooted, it is better to set the properties 46# via a local.prop file: 47# 1) create a local.prop file with the content 48# dalvik.vm.profilebootclasspath=true 49# dalvik.vm.profilesystemserver=true 50# 2) adb push local.prop /data/ 51# adb shell chmod 0750 /data/local.prop 52# adb reboot 53 54adb root 55adb shell stop 56adb shell setprop dalvik.vm.profilebootclasspath true 57adb shell setprop dalvik.vm.profilesystemserver true 58adb shell find "/data/misc/profiles -name *.prof -exec truncate -s 0 {} \;" 59adb shell start