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

Side by Side Diff: build/android/pylib/device/intent.py

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Manages intents and associated information. 5 """Manages intents and associated information.
6 6
7 This is generally intended to be used with functions that calls Android's 7 This is generally intended to be used with functions that calls Android's
8 Am command. 8 Am command.
9 """ 9 """
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return self._extras 70 return self._extras
71 71
72 @property 72 @property
73 def flags(self): 73 def flags(self):
74 return self._flags 74 return self._flags
75 75
76 @property 76 @property
77 def package(self): 77 def package(self):
78 return self._package 78 return self._package
79 79
80 @property
81 def am_args(self):
82 """Returns the intent as a list of arguments for the activity manager.
83
84 For details refer to the specification at:
85 - http://developer.android.com/tools/help/adb.html#IntentSpec
86 """
87 args = []
88 if self.action:
89 args.extend(['-a', self.action])
90 if self.data:
91 args.extend(['-d', self.data])
92 if self.category:
93 args.extend(arg for cat in self.category for arg in ('-c', cat))
94 if self.component:
95 args.extend(['-n', self.component])
96 if self.flags:
97 args.extend(['-f', self.flags])
98 if self.extras:
99 for key, value in self.extras.iteritems():
100 if value is None:
101 args.extend(['--esn', key])
102 elif isinstance(value, str):
103 args.extend(['--es', key, value])
104 elif isinstance(value, bool):
105 args.extend(['--ez', key, str(value)])
106 elif isinstance(value, int):
107 args.extend(['--ei', key, str(value)])
108 elif isinstance(value, float):
109 args.extend(['--ef', key, str(value)])
110 else:
111 raise NotImplementedError(
112 'Intent does not know how to pass %s extras' % type(value))
113 return args
OLDNEW
« no previous file with comments | « build/android/pylib/device/device_utils_test.py ('k') | build/android/pylib/gtest/gtest_test_instance.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698