From d0da21d40b3abcaf91803fd89503491a5f171d23 Mon Sep 17 00:00:00 2001 From: Till Skrodzki Date: Mon, 18 Dec 2023 21:03:58 +0100 Subject: [PATCH] Add intentional stop intent call for PD --- mapadroid/ocr/screenPath.py | 9 +++++++++ mapadroid/worker/strategy/AbstractMitmBaseStrategy.py | 3 +++ 2 files changed, 12 insertions(+) diff --git a/mapadroid/ocr/screenPath.py b/mapadroid/ocr/screenPath.py index fa145be32..3a922c0e2 100644 --- a/mapadroid/ocr/screenPath.py +++ b/mapadroid/ocr/screenPath.py @@ -420,6 +420,9 @@ 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 broadcast -a com.mad.pogodroid.SET_INTENTIONAL_STOP -c android.intent.category.DEFAULT -n com.mad.pogodroid/.IntentionalStopSetterReceiver --ez value false'") + await asyncio.sleep(5) await self._communicator.passthrough( "su -c 'am startservice -n com.mad.pogodroid/.services.HookReceiverService'") else: @@ -507,6 +510,9 @@ async def __handle_ptc_login(self) -> ScreenType: 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 broadcast -a com.mad.pogodroid.SET_INTENTIONAL_STOP -c android.intent.category.DEFAULT -n com.mad.pogodroid/.IntentionalStopSetterReceiver --ez value false'") + await asyncio.sleep(5) await self._communicator.passthrough( "su -c 'am startservice -n com.mad.pogodroid/.services.HookReceiverService'") return ScreenType.PTC @@ -562,6 +568,9 @@ async def __handle_returning_player_or_wrong_credentials(self) -> None: 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 broadcast -a com.mad.pogodroid.SET_INTENTIONAL_STOP -c android.intent.category.DEFAULT -n com.mad.pogodroid/.IntentionalStopSetterReceiver --ez value true'") + await asyncio.sleep(5) await self._communicator.passthrough( "su -c 'am stopservice -n com.mad.pogodroid/.services.HookReceiverService'") await self._communicator.restart_app("com.nianticlabs.pokemongo") diff --git a/mapadroid/worker/strategy/AbstractMitmBaseStrategy.py b/mapadroid/worker/strategy/AbstractMitmBaseStrategy.py index 779233ab1..8597f7b8d 100644 --- a/mapadroid/worker/strategy/AbstractMitmBaseStrategy.py +++ b/mapadroid/worker/strategy/AbstractMitmBaseStrategy.py @@ -474,6 +474,9 @@ async def _additional_health_check(self) -> None: # Ensure PogoDroid was started... if not await self.get_devicesettings_value(MappingManagerDevicemappingKey.EXTENDED_PERMISSION_TOGGLING, False): return + await self._communicator.passthrough( + "su -c 'am broadcast -a com.mad.pogodroid.SET_INTENTIONAL_STOP -c android.intent.category.DEFAULT -n com.mad.pogodroid/.IntentionalStopSetterReceiver --ez value false'") + await asyncio.sleep(5) await self._communicator.passthrough( "su -c 'am startservice -n com.mad.pogodroid/.services.HookReceiverService'")