Add experimental scripts for disabling jit, and resetting device perf/test state

Bug: 355042464
Test: manually ran scripts

As a follow up, can provide gradle wrappers... though they're super
slow, and these are semi-internal anyway ¯\_(ツ)_/¯

Change-Id: Ia86b1a81e02569caaa2428b946e7cf62b04f0207
diff --git a/benchmark/gradle-plugin/src/main/resources/scripts/disableJit.sh b/benchmark/gradle-plugin/src/main/resources/scripts/disableJit.sh
new file mode 100755
index 0000000..858a968
--- /dev/null
+++ b/benchmark/gradle-plugin/src/main/resources/scripts/disableJit.sh
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2024 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# ADB push intro copied from lockClocks.sh
+if [ "`command -v getprop`" == "" ]; then
+    if [ -n "`command -v adb`" ]; then
+        echo ""
+        echo "Pushing $0 and running it on device..."
+        dest=/data/local/tmp/`basename $0`
+        adb push $0 ${dest}
+        adb shell ${dest} $@
+        adb shell rm ${dest}
+        exit
+    else
+        echo "Could not find adb. Options are:"
+        echo "  1. Ensure adb is on your \$PATH"
+        echo "  2. Use './gradlew lockClocks'"
+        echo "  3. Manually adb push this script to your device, and run it there"
+        exit -1
+    fi
+fi
+
+echo ""
+
+# require root
+if [[ `id` != "uid=0"* ]]; then
+    echo "Not running as root, cannot disable jit, aborting"
+    exit -1
+fi
+
+setprop dalvik.vm.extra-opts "-Xusejit:false"
+stop
+start
+
+DEVICE=`getprop ro.product.device`
+echo "JIT compilation has been disabled on $DEVICE!"
+echo "Performance will be terrible for almost everything! (except e.g. AOT benchmarks)"
+echo "To reenable it (strongly recommended after benchmarking!!!), reboot or run resetDevice.sh"
diff --git a/benchmark/gradle-plugin/src/main/resources/scripts/resetDevice.sh b/benchmark/gradle-plugin/src/main/resources/scripts/resetDevice.sh
new file mode 100755
index 0000000..060f075
--- /dev/null
+++ b/benchmark/gradle-plugin/src/main/resources/scripts/resetDevice.sh
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2024 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# ADB push intro copied from lockClocks.sh
+if [ "`command -v getprop`" == "" ]; then
+    if [ -n "`command -v adb`" ]; then
+        echo ""
+        echo "Pushing $0 and running it on device..."
+        dest=/data/local/tmp/`basename $0`
+        adb push $0 ${dest}
+        adb shell ${dest} $@
+        # adb shell rm ${dest} # will fail, not very important
+        exit
+    else
+        echo "Could not find adb. Options are:"
+        echo "  1. Ensure adb is on your \$PATH"
+        echo "  2. Use './gradlew lockClocks'"
+        echo "  3. Manually adb push this script to your device, and run it there"
+        exit -1
+    fi
+fi
+
+DEVICE=`getprop ro.product.device`
+echo ""
+echo "Rebooting $DEVICE, and resetting animation scales!"
+echo "This will re-lock clocks, reenable JIT, and reset animation scale to 1.0"
+
+settings put global window_animation_scale 1.0
+settings put global transition_animation_scale 1.0
+settings put global animator_duration_scale 1.0
+
+reboot # required to relock clocks, and handles reenabling jit since the property won't persist