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 3# found in the LICENSE file. 4 5"""Manages intents and associated information. 6 7This is generally intended to be used with functions that calls Android's 8Am command. 9""" 10 11class Intent(object): 12 13 def __init__(self, action='android.intent.action.VIEW', activity=None, 14 category=None, component=None, data=None, extras=None, 15 flags=None, package=None): 16 """Creates an Intent. 17 18 Args: 19 action: A string containing the action. 20 activity: A string that, with |package|, can be used to specify the 21 component. 22 category: A string or list containing any categories. 23 component: A string that specifies the component to send the intent to. 24 data: A string containing a data URI. 25 extras: A dict containing extra parameters to be passed along with the 26 intent. 27 flags: A string containing flags to pass. 28 package: A string that, with activity, can be used to specify the 29 component. 30 """ 31 self._action = action 32 self._activity = activity 33 if isinstance(category, list) or category is None: 34 self._category = category 35 else: 36 self._category = [category] 37 self._component = component 38 self._data = data 39 self._extras = extras 40 self._flags = flags 41 self._package = package 42 43 if self._component and '/' in component: 44 self._package, self._activity = component.split('/', 1) 45 elif self._package and self._activity: 46 self._component = '%s/%s' % (package, activity) 47 48 @property 49 def action(self): 50 return self._action 51 52 @property 53 def activity(self): 54 return self._activity 55 56 @property 57 def category(self): 58 return self._category 59 60 @property 61 def component(self): 62 return self._component 63 64 @property 65 def data(self): 66 return self._data 67 68 @property 69 def extras(self): 70 return self._extras 71 72 @property 73 def flags(self): 74 return self._flags 75 76 @property 77 def package(self): 78 return self._package 79 80