Skip to content

Commit

Permalink
WIP: Disable PD during pogo login
Browse files Browse the repository at this point in the history
  • Loading branch information
Grennith committed Dec 17, 2023
1 parent b2b9fa1 commit fb0d11d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion mapadroid/ocr/screenPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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?")
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mapadroid/worker/strategy/AbstractWorkerStrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit fb0d11d

Please sign in to comment.