Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3056)

Unified Diff: build/android/adb_command_line_functions.sh

Issue 1165753002: Fix adb_chrome_public_command_line for Android M & refactor into a helper .sh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't show error when reading flags file and it doesn't exist Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/adb_chrome_shell_command_line ('k') | build/android/adb_content_shell_command_line » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/adb_command_line_functions.sh
diff --git a/build/android/adb_command_line_functions.sh b/build/android/adb_command_line_functions.sh
new file mode 100755
index 0000000000000000000000000000000000000000..0c62f6e8be97fecdce6618c6365db9df2f377dfc
--- /dev/null
+++ b/build/android/adb_command_line_functions.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Variables must be set before calling:
+# CMD_LINE_FILE - Path on device to flags file.
+# REQUIRES_SU - Set to 1 if path requires root.
+function set_command_line() {
+ SU_CMD=""
+ 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
+ # Older androids accept "su -c", while newer use "su uid".
+ 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)
+ SU_CMD="su -c"
+ if [[ -n $IS_OLD_STYLE ]]; then
+ 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
+ fi
+ fi
+
+ if [ $# -eq 0 ] ; then
+ # If nothing specified, print the command line (stripping off "chrome ")
+ adb shell "cat $CMD_LINE_FILE 2>/dev/null | cut -d ' ' -s -f2-"
+ elif [ $# -eq 1 ] && [ "$1" = '' ] ; then
+ # If given an empty string, delete the command line.
+ set -x
+ adb shell $SU_CMD rm $CMD_LINE_FILE >/dev/null
+ else
+ # Else set it.
+ set -x
+ adb shell "echo 'chrome $*' | $SU_CMD dd of=$CMD_LINE_FILE"
+ # Prevent other apps from modifying flags (this can create security issues).
+ adb shell $SU_CMD chmod 0664 $CMD_LINE_FILE
+ fi
+}
+
« no previous file with comments | « build/android/adb_chrome_shell_command_line ('k') | build/android/adb_content_shell_command_line » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698