Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05e28fa8 authored by Zhuoyao Zhang's avatar Zhuoyao Zhang
Browse files

Do not start edit monitor under cog workspace

Edit monitor for cog workspace is not supported, stop the edit monitor
directly if it identifies the cog environment.

Test: atest daemon_manager_test
Bug: 365617369
Change-Id: I0113983b917490bcc0e5a92d6539626b4dbec6d8
parent aaf12a1c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@ class DaemonManager:
      logging.warning("Block sign found, exiting...")
      return

    if self.binary_path.startswith('/google/cog/'):
      logging.warning("Edit monitor for cog is not supported, exiting...")
      return

    self._stop_any_existing_instance()
    self._write_pid_to_pidfile()
    self._start_daemon_process()
+7 −0
Original line number Diff line number Diff line
@@ -131,6 +131,13 @@ class DaemonManagerTest(unittest.TestCase):
    # Verify no daemon process is started.
    self.assertIsNone(dm.daemon_process)

  def test_start_return_directly_if_in_cog_env(self):
    dm = daemon_manager.DaemonManager(
        '/google/cog/cloud/user/workspace/edit_monitor')
    dm.start()
    # Verify no daemon process is started.
    self.assertIsNone(dm.daemon_process)

  @mock.patch('os.kill')
  def test_start_failed_to_kill_existing_instance(self, mock_kill):
    mock_kill.side_effect = OSError('Unknown OSError')