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 | |
|
jbudorick
2015/06/01 15:43:24
-eq
?
agrieve
2015/06/01 15:58:19
Since REQUIRES_SU can be unset, I think = is more
| |
| 13 # Older androids accept "su -c", while newer use "su uid". | |
| 14 IS_OLD_STYLE=$(adb shell su -c echo 1 2>/dev/null) | |
|
jbudorick
2015/06/01 15:43:24
I'm not crazy about this.
agrieve
2015/06/01 15:58:19
suggestion for what you would be crazy for?
jbudorick
2015/06/01 17:44:21
I would break on SDK level (ro.build.version.sdk)
| |
| 15 SU_CMD="su -c" | |
| 16 if [[ -n $IS_OLD_STYLE ]]; then | |
| 17 SU_CMD="su 0" | |
|
jbudorick
2015/06/01 15:43:24
Does this style work in older android versions?
agrieve
2015/06/01 15:58:19
From my quick test, seems to work back got JB, but
| |
| 18 fi | |
| 19 fi | |
| 20 | |
| 21 if [ $# -eq 0 ] ; then | |
| 22 # If nothing specified, print the command line (stripping off "chrome ") | |
| 23 adb shell "cat $CMD_LINE_FILE 2>/dev/null | cut -d ' ' -s -f2-" | |
| 24 elif [ $# -eq 1 ] && [ "$1" = '' ] ; then | |
| 25 # If given an empty string, delete the command line. | |
| 26 set -x | |
| 27 adb shell $SU_CMD rm $CMD_LINE_FILE >/dev/null | |
| 28 else | |
| 29 # Else set it. | |
| 30 set -x | |
| 31 adb shell "echo 'chrome $*' | $SU_CMD dd of=$CMD_LINE_FILE" | |
| 32 # Prevent other apps from modifying flags (this can create security issues). | |
| 33 adb shell $SU_CMD chmod 0664 $CMD_LINE_FILE | |
| 34 fi | |
| 35 } | |
| 36 | |
| OLD | NEW |