From fb0d11db1b2fe42b78816f5db7deca3a3b97befe Mon Sep 17 00:00:00 2001 From: Till Skrodzki Date: Sun, 17 Dec 2023 12:09:53 +0100 Subject: [PATCH] WIP: Disable PD during pogo login --- mapadroid/ocr/screenPath.py | 13 ++++++++++++- mapadroid/worker/strategy/AbstractWorkerStrategy.py | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mapadroid/ocr/screenPath.py b/mapadroid/ocr/screenPath.py index 4f6363e7a..fa145be32 100644 --- a/mapadroid/ocr/screenPath.py +++ b/mapadroid/ocr/screenPath.py @@ -16,8 +16,8 @@ from mapadroid.mapping_manager.MappingManagerDevicemappingKey import \ MappingManagerDevicemappingKey from mapadroid.ocr.screen_type import ScreenType -from mapadroid.utils.CustomTypes import MessageTyping from mapadroid.utils.collections import Location, ScreenCoordinates +from mapadroid.utils.CustomTypes import MessageTyping from mapadroid.utils.madGlobals import MadGlobals, ScreenshotType from mapadroid.websocket.AbstractCommunicator import AbstractCommunicator from mapadroid.worker.WorkerState import WorkerState @@ -420,6 +420,8 @@ async def __handle_google_login(self, screentype) -> ScreenType: if await self.parse_ggl(await self._communicator.uiautomator(), usernames_to_check_for): logger.info("Sleeping 50 seconds after clicking the account to login with - please wait!") await asyncio.sleep(50) + await self._communicator.passthrough( + "su -c 'am startservice -n com.mad.pogodroid/.services.HookReceiverService'") else: screentype = ScreenType.ERROR return screentype @@ -504,6 +506,9 @@ async def __handle_ptc_login(self) -> ScreenType: await self._communicator.click(accept_x, accept_y) logger.info("Clicking Log In and sleeping 50 seconds - please wait!") await asyncio.sleep(50) + # Start pogodroid service again to make sure we are running PD properly here + await self._communicator.passthrough( + "su -c 'am startservice -n com.mad.pogodroid/.services.HookReceiverService'") return ScreenType.PTC else: logger.error("Log in [accept] button not found?") @@ -556,6 +561,12 @@ async def __handle_returning_player_or_wrong_credentials(self) -> None: await asyncio.sleep(2) async def __handle_birthday_screen(self) -> None: + # First disable pogodroid at this point to avoid the injection triggering any checks in other libraries + await self._communicator.passthrough( + "su -c 'am stopservice -n com.mad.pogodroid/.services.HookReceiverService'") + await self._communicator.restart_app("com.nianticlabs.pokemongo") + await asyncio.sleep(30) + # After having restarted pogo, we should again be on the birthday screen now and PD is turned off self._nextscreen = ScreenType.RETURNING click_x = int((self._width / 2) + (self._width / 4)) click_y = int((self._height / 1.69) + self._screenshot_y_offset) diff --git a/mapadroid/worker/strategy/AbstractWorkerStrategy.py b/mapadroid/worker/strategy/AbstractWorkerStrategy.py index 28b0b9a2d..94293945e 100644 --- a/mapadroid/worker/strategy/AbstractWorkerStrategy.py +++ b/mapadroid/worker/strategy/AbstractWorkerStrategy.py @@ -312,7 +312,7 @@ async def _ensure_pogo_topmost(self): else: return False - async def _handle_screen(self): + async def _handle_screen(self) -> ScreenType: screen_type: ScreenType = ScreenType.UNDEFINED while not self._worker_state.stop_worker_event.is_set(): if self._worker_state.login_error_count > 2: