[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / build / android / adb_command_line_functions.sh
blob7ea98b09be67f9a163ed459fda5b12b53241cc48
1 #!/bin/bash
3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Variables must be set before calling:
8 # CMD_LINE_FILE - Path on device to flags file.
9 # REQUIRES_SU - Set to 1 if path requires root.
10 function set_command_line() {
11 SU_CMD=""
12 if [[ "$REQUIRES_SU" = 1 ]]; then
13 # Older androids accept "su -c", while newer use "su uid".
14 SDK_LEVEL=$(adb shell getprop ro.build.version.sdk | tr -d '\r')
15 # E.g. if no device connected.
16 if [[ -z "$SDK_LEVEL" ]]; then
17 exit 1
19 SU_CMD="su -c"
20 if (( $SDK_LEVEL >= 21 )); then
21 SU_CMD="su 0"
25 if [ $# -eq 0 ] ; then
26 # If nothing specified, print the command line (stripping off "chrome ")
27 adb shell "cat $CMD_LINE_FILE 2>/dev/null" | cut -d ' ' -s -f2-
28 elif [ $# -eq 1 ] && [ "$1" = '' ] ; then
29 # If given an empty string, delete the command line.
30 set -x
31 adb shell $SU_CMD rm $CMD_LINE_FILE >/dev/null
32 else
33 # Else set it.
34 set -x
35 adb shell "echo 'chrome $*' | $SU_CMD dd of=$CMD_LINE_FILE"
36 # Prevent other apps from modifying flags (this can create security issues).
37 adb shell $SU_CMD chmod 0664 $CMD_LINE_FILE