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