parameters: (xmlroot)
return_statement: return launchable_activities
docstring: A given application can have several activities, and each activity
      can have several intent filters. We want to only list, in the final
      output, the activities which have a intent-filter that contains the
      following elements:
  
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
docstring_summary: A given application can have several activities, and each activity
      can have several intent filters. We want to only list, in the final
      output, the activities which have a intent-filter that contains the
      following elements:
docstring_tokens: A given application can have several activities and each activity can have several intent filters . We want to only list in the final output the activities which have a intent - filter that contains the following elements :
function: def extract_launchable(xmlroot):
      '''
      A given application can have several activities, and each activity
      can have several intent filters. We want to only list, in the final
      output, the activities which have a intent-filter that contains the
      following elements:
  
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      '''
      launchable_activities = []
      application = xmlroot.findall("application")[0]
  
      main_action = "android.intent.action.MAIN"
      launcher_category = "android.intent.category.LAUNCHER"
      name_attrib = "{}name".format(ANDROID_XMLNS)
  
      for activity in application.iter("activity"):
          if name_attrib not in activity.attrib:
              continue
  
          for intent_filter in activity.iter("intent-filter"):
              found_action = False
              found_category = False
              for child in intent_filter:
                  if child.tag == "action":
                      if not found_action and name_attrib in child.attrib:
                          if child.attrib[name_attrib] == main_action:
                              found_action = True
                  if child.tag == "category":
                      if not found_category and name_attrib in child.attrib:
                          if child.attrib[name_attrib] == launcher_category:
                              found_category = True
              if found_action and found_category:
                  launchable_activities.append(activity.attrib[name_attrib])
      return launchable_activities
function_tokens: def extract_launchable ( xmlroot ) : launchable_activities = [ ] application = xmlroot . findall ( "application" ) [ 0 ] main_action = "android.intent.action.MAIN" launcher_category = "android.intent.category.LAUNCHER" name_attrib = "{}name" . format ( ANDROID_XMLNS ) for activity in application . iter ( "activity" ) : if name_attrib not in activity . attrib : continue for intent_filter in activity . iter ( "intent-filter" ) : found_action = False found_category = False for child in intent_filter : if child . tag == "action" : if not found_action and name_attrib in child . attrib : if child . attrib [ name_attrib ] == main_action : found_action = True if child . tag == "category" : if not found_category and name_attrib in child . attrib : if child . attrib [ name_attrib ] == launcher_category : found_category = True if found_action and found_category : launchable_activities . append ( activity . attrib [ name_attrib ] ) return launchable_activities