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
() {
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
20 if (( $SDK_LEVEL >= 21 )); then
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.
31 adb shell
$SU_CMD rm $CMD_LINE_FILE >/dev
/null
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