1#
2# Copyright (C) 2024 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# ADB push intro copied from lockClocks.sh
18if [ "`command -v getprop`" == "" ]; then
19    if [ -n "`command -v adb`" ]; then
20        echo ""
21        echo "Pushing $0 and running it on device..."
22        dest=/data/local/tmp/`basename $0`
23        adb push $0 ${dest}
24        adb shell ${dest} $@
25        adb shell rm ${dest}
26        exit
27    else
28        echo "Could not find adb. Options are:"
29        echo "  1. Ensure adb is on your \$PATH"
30        echo "  2. Manually adb push this script to your device, and run it there"
31        exit -1
32    fi
33fi
34
35echo ""
36
37# require root
38if [[ `id` != "uid=0"* ]]; then
39    echo "Not running as root, cannot disable jit, aborting"
40    echo "Run 'adb root' and retry"
41    exit -1
42fi
43
44setprop dalvik.vm.extra-opts "-Xusejit:false"
45stop
46start
47
48## Poll for boot animation to start...
49echo "  Waiting for boot animation to start..."
50while [[ "`getprop init.svc.bootanim`" == "stopped" ]]; do
51  sleep 0.1; # frequent polling for boot anim to start, in case it's fast
52done
53
54## And then complete
55echo "  Waiting for boot animation to stop..."
56while [[ "`getprop init.svc.bootanim`" == "running" ]]; do
57  sleep 0.5;
58done
59
60DEVICE=`getprop ro.product.device`
61echo "\nJIT compilation has been disabled on $DEVICE!"
62echo "Performance will be terrible for almost everything! (except e.g. AOT benchmarks)"
63echo "To reenable it (strongly recommended after benchmarking!!!), reboot or run resetDevice.sh"
64