code: def current_app(self):
          
          # try: adb shell dumpsys activity top
          _activityRE = re.compile(r'ACTIVITY (?P<package>[^/]+)/(?P<activity>[^/\s]+) \w+ pid=(?P<pid>\d+)')
          m = _activityRE.search(self.shell('dumpsys', 'activity', 'top'))
          if m:
              return dict(package=m.group('package'), activity=m.group('activity'), pid=int(m.group('pid')))
  
          # try: adb shell dumpsys window windows
          _focusedRE = re.compile('mFocusedApp=.*ActivityRecord{\w+ \w+ (?P<package>.*)/(?P<activity>.*) .*')
          m = _focusedRE.search(self.shell('dumpsys', 'window', 'windows'))
          if m:
              return dict(package=m.group('package'), activity=m.group('activity'))
          raise RuntimeError("Couldn't get focused app")
docs: Return: dict(package, activity, pid?)
          Raises:
              RuntimeError