prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Android: `paths.app` doesn't work in event handlers
  **Describe the bug**
  
  On Android, `paths.app` returns `/` when called outside of the `startup` method, e.g. in an event handler. This is because the `__main__` module has finished importing, and it no longer exists in `sys.modules` under that name.
  
  This doesn't happen on Windows, because it runs the entire main loop within the top level of the `__main__` module. The other desktop platforms are probably the same.
  
  But on Android, the main loop is already running and we have to integrate into it, so importing the `__main__` module does not block. From inspection of the code, it looks like iOS is similar, so it might have the same problem.
  
  The fallback to `/` makes no sense on Android anyway, so it should be removed.
  
  Reported by @kakos-k9 on Discord.
  
  **Test app**
  ```python
  import toga
  from toga.style import Pack
  from toga.style.pack import COLUMN, ROW
  
  class Hello(toga.App):
  
      def startup(self):
          button = toga.Button("Print", on_press=self.on_press)
          self.on_press(button)
  
          self.main_window = toga.MainWindow()
          self.main_window.content = toga.Box(
              style=Pack(direction=COLUMN),
              children=[button]
          )
          self.main_window.show()
  
      def on_press(self, button):
          import traceback
          for name in ["app", "data", "toga"]:
              print(f"{name}={getattr(self.paths, name)}")
  
  
  def main():
      return Hello()
  ```
  
  **Environment:**
   - Operating System: Android
   - Python version: 3.8
   - Software versions:
     - Toga: 9a292f8e26
  
  
  </issue>
  <code>
  [start of src/android/toga_android/paths.py]
  1 import sys
  2 from pathlib import Path
  3 
  4 import toga
  5 from toga import App
  6 
  7 
  8 class Paths:
  9     # Allow instantiating Path object via the factory
  10     Path = Path
  11 
  12     @property
  13     def __context(self):
  14         return App.app._impl.native.getApplicationContext()
  15 
  16     @property
  17     def app(self):
  18         try:
  19             return Path(sys.modules["__main__"].__file__).parent
  20         except KeyError:
  21             # If we're running in test conditions,
  22             # there is no __main__ module.
  23             return Path.cwd()
  24         except AttributeError:
  25             # If we're running at an interactive prompt,
  26             # the __main__ module isn't file-based.
  27             return Path.cwd()
  28 
  29     @property
  30     def data(self):
  31         return Path(self.__context.getFilesDir().getPath())
  32 
  33     @property
  34     def cache(self):
  35         return Path(self.__context.getCacheDir().getPath())
  36 
  37     @property
  38     def logs(self):
  39         return self.data
  40 
  41     @property
  42     def toga(self):
  43         """Return a path to a Toga resources
  44         """
  45         return Path(toga.__file__).parent
  46 
  47 
  48 paths = Paths()
  49
  [end of src/android/toga_android/paths.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/android/toga_android/paths.py b/src/android/toga_android/paths.py
  --- a/src/android/toga_android/paths.py
  +++ b/src/android/toga_android/paths.py
  @@ -13,18 +13,13 @@
       def __context(self):
           return App.app._impl.native.getApplicationContext()
   
  +    def __init__(self):
  +        # On Android, __main__ only exists during app startup, so cache its location now.
  +        self._app = Path(sys.modules["__main__"].__file__).parent
  +
       @property
       def app(self):
  -        try:
  -            return Path(sys.modules["__main__"].__file__).parent
  -        except KeyError:
  -            # If we're running in test conditions,
  -            # there is no __main__ module.
  -            return Path.cwd()
  -        except AttributeError:
  -            # If we're running at an interactive prompt,
  -            # the __main__ module isn't file-based.
  -            return Path.cwd()
  +        return self._app
   
       @property
       def data(self):
  
verification_info: {"golden_diff": "diff --git a/src/android/toga_android/paths.py b/src/android/toga_android/paths.py\n--- a/src/android/toga_android/paths.py\n+++ b/src/android/toga_android/paths.py\n@@ -13,18 +13,13 @@\n     def __context(self):\n         return App.app._impl.native.getApplicationContext()\n \n+    def __init__(self):\n+        # On Android, __main__ only exists during app startup, so cache its location now.\n+        self._app = Path(sys.modules[\"__main__\"].__file__).parent\n+\n     @property\n     def app(self):\n-        try:\n-            return Path(sys.modules[\"__main__\"].__file__).parent\n-        except KeyError:\n-            # If we're running in test conditions,\n-            # there is no __main__ module.\n-            return Path.cwd()\n-        except AttributeError:\n-            # If we're running at an interactive prompt,\n-            # the __main__ module isn't file-based.\n-            return Path.cwd()\n+        return self._app\n \n     @property\n     def data(self):\n", "issue": "Android: `paths.app` doesn't work in event handlers\n**Describe the bug**\r\n\r\nOn Android, `paths.app` returns `/` when called outside of the `startup` method, e.g. in an event handler. This is because the `__main__` module has finished importing, and it no longer exists in `sys.modules` under that name.\r\n\r\nThis doesn't happen on Windows, because it runs the entire main loop within the top level of the `__main__` module. The other desktop platforms are probably the same.\r\n\r\nBut on Android, the main loop is already running and we have to integrate into it, so importing the `__main__` module does not block. From inspection of the code, it looks like iOS is similar, so it might have the same problem.\r\n\r\nThe fallback to `/` makes no sense on Android anyway, so it should be removed.\r\n\r\nReported by @kakos-k9 on Discord.\r\n\r\n**Test app**\r\n```python\r\nimport toga\r\nfrom toga.style import Pack\r\nfrom toga.style.pack import COLUMN, ROW\r\n\r\nclass Hello(toga.App):\r\n\r\n    def startup(self):\r\n        button = toga.Button(\"Print\", on_press=self.on_press)\r\n        self.on_press(button)\r\n\r\n        self.main_window = toga.MainWindow()\r\n        self.main_window.content = toga.Box(\r\n            style=Pack(direction=COLUMN),\r\n            children=[button]\r\n        )\r\n        self.main_window.show()\r\n\r\n    def on_press(self, button):\r\n        import traceback\r\n        for name in [\"app\", \"data\", \"toga\"]:\r\n            print(f\"{name}={getattr(self.paths, name)}\")\r\n\r\n\r\ndef main():\r\n    return Hello()\r\n```\r\n\r\n**Environment:**\r\n - Operating System: Android\r\n - Python version: 3.8\r\n - Software versions:\r\n   - Toga: 9a292f8e26\r\n\n", "before_files": [{"content": "import sys\nfrom pathlib import Path\n\nimport toga\nfrom toga import App\n\n\nclass Paths:\n    # Allow instantiating Path object via the factory\n    Path = Path\n\n    @property\n    def __context(self):\n        return App.app._impl.native.getApplicationContext()\n\n    @property\n    def app(self):\n        try:\n            return Path(sys.modules[\"__main__\"].__file__).parent\n        except KeyError:\n            # If we're running in test conditions,\n            # there is no __main__ module.\n            return Path.cwd()\n        except AttributeError:\n            # If we're running at an interactive prompt,\n            # the __main__ module isn't file-based.\n            return Path.cwd()\n\n    @property\n    def data(self):\n        return Path(self.__context.getFilesDir().getPath())\n\n    @property\n    def cache(self):\n        return Path(self.__context.getCacheDir().getPath())\n\n    @property\n    def logs(self):\n        return self.data\n\n    @property\n    def toga(self):\n        \"\"\"Return a path to a Toga resources\n        \"\"\"\n        return Path(toga.__file__).parent\n\n\npaths = Paths()\n", "path": "src/android/toga_android/paths.py"}]}