Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 # | |
| 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. | |
| 6 | |
| 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 | |
| 18 fi | |
| 19 SU_CMD="su -c" | |
| 20 if (( $SDK_LEVEL >= 21 )); then | |
| 21 SU_CMD="su 0" | |
| 22 fi | |
| 23 fi | |
| 24 | |
| 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-" | |
|
Dmitry Skiba
2015/06/02 20:24:25
Previously (in adb_chrome_public_command_line) thi
| |
| 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 | |
| 38 fi | |
| 39 } | |
| 40 | |
| OLD | NEW |