diff --git a/alembic/versions/b533c33be802_add_device_and_devicepool_options_for_.py b/alembic/versions/b533c33be802_add_device_and_devicepool_options_for_.py new file mode 100644 index 000000000..7d321089b --- /dev/null +++ b/alembic/versions/b533c33be802_add_device_and_devicepool_options_for_.py @@ -0,0 +1,28 @@ +"""Add device and devicepool options for extended login + +Revision ID: b533c33be802 +Revises: 73063d78ff1c +Create Date: 2024-02-10 11:36:15.733010 + +""" +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision = 'b533c33be802' +down_revision = '73063d78ff1c' +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column('settings_device', sa.Column('extended_login', sa.BOOLEAN(), + server_default=sa.text("'0'"), nullable=False)) + op.add_column('settings_devicepool', sa.Column('extended_login', sa.BOOLEAN(), + server_default=sa.text("'0'"), nullable=False)) + + +def downgrade(): + op.drop_column('settings_device', 'extended_login') + op.drop_column('settings_devicepool', 'extended_login') diff --git a/mapadroid/db/model.py b/mapadroid/db/model.py index f2f188436..81cd86f0f 100644 --- a/mapadroid/db/model.py +++ b/mapadroid/db/model.py @@ -641,6 +641,7 @@ class SettingsDevicepool(Base): injection_thresh_reboot = Column(INTEGER(11)) screendetection = Column(BOOLEAN) enhanced_mode_quest_safe_items = Column(String(500, 'utf8mb4_unicode_ci')) + extended_login = Column(BOOLEAN, server_default=text("'0'")) instance = relationship('MadminInstance') @@ -716,6 +717,7 @@ class SettingsDevice(Base): interface_type = Column(ENUM('lan', 'wlan'), server_default=text("'lan'")) softbar_enabled = Column(BOOLEAN, server_default=text("'0'")) extended_permission_toggling = Column(BOOLEAN, server_default=text("'0'")) + extended_login = Column(BOOLEAN, server_default=text("'0'")) instance = relationship('MadminInstance') pool = relationship('SettingsDevicepool') diff --git a/mapadroid/db/resource_definitions/Device.py b/mapadroid/db/resource_definitions/Device.py index 43f31fb86..5c88eef99 100644 --- a/mapadroid/db/resource_definitions/Device.py +++ b/mapadroid/db/resource_definitions/Device.py @@ -326,6 +326,16 @@ class Device(Resource): "expected": str, "default": "1401, 1402, 1403, 1106, 901, 902, 903, 501, 502, 503, 504, 301" } - } + }, + "extended_login": { + "settings": { + "type": "option", + "values": [False, True], + "require": False, + "description": "Extended login routine triggering full stop of PD. Default: False. " + "Breaks forced version suppression.", + "expected": bool + } + }, } } diff --git a/mapadroid/db/resource_definitions/Devicepool.py b/mapadroid/db/resource_definitions/Devicepool.py index 44f5989a3..c09953a4c 100644 --- a/mapadroid/db/resource_definitions/Devicepool.py +++ b/mapadroid/db/resource_definitions/Devicepool.py @@ -207,6 +207,16 @@ class Devicepool(Resource): "expected": str, "default": "1401, 1402, 1403, 1106, 901, 902, 903, 501, 502, 503, 504, 301" } - } + }, + "extended_login": { + "settings": { + "type": "option", + "values": [False, True], + "require": False, + "description": "Extended login routine triggering full stop of PD. Default: False. " + "Breaks forced version suppression.", + "expected": bool + } + }, } } diff --git a/mapadroid/mapping_manager/MappingManager.py b/mapadroid/mapping_manager/MappingManager.py index 262c76e76..81bd83051 100644 --- a/mapadroid/mapping_manager/MappingManager.py +++ b/mapadroid/mapping_manager/MappingManager.py @@ -334,6 +334,8 @@ async def get_devicesetting_value_of_device(self, device_name: str, key: Mapping return devicemapping_entry.device_settings.rotate_on_lvl_30 elif key == MappingManagerDevicemappingKey.EXTENDED_PERMISSION_TOGGLING: return devicemapping_entry.device_settings.extended_permission_toggling + elif key == MappingManagerDevicemappingKey.EXTENDED_LOGIN: + return devicemapping_entry.pool_settings.extended_login if devicemapping_entry.pool_settings and devicemapping_entry.pool_settings.extended_login else devicemapping_entry.device_settings.extended_login else: # TODO: Get all the DB values... pass diff --git a/mapadroid/mapping_manager/MappingManagerDevicemappingKey.py b/mapadroid/mapping_manager/MappingManagerDevicemappingKey.py index c9bbf5474..621f3abbb 100644 --- a/mapadroid/mapping_manager/MappingManagerDevicemappingKey.py +++ b/mapadroid/mapping_manager/MappingManagerDevicemappingKey.py @@ -41,3 +41,4 @@ class MappingManagerDevicemappingKey(IntEnum): ENHANCED_MODE_QUEST_SAFE_ITEMS = 40 SOFTBAR_ENABLED = 42 EXTENDED_PERMISSION_TOGGLING = 43 + EXTENDED_LOGIN = 44 diff --git a/mapadroid/ocr/screenPath.py b/mapadroid/ocr/screenPath.py index 7a64290c1..ba122914d 100644 --- a/mapadroid/ocr/screenPath.py +++ b/mapadroid/ocr/screenPath.py @@ -418,18 +418,20 @@ async def __handle_google_login(self, screentype) -> ScreenType: return ScreenType.ERROR usernames_to_check_for: List[str] = usernames.split(",") 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(120) - 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(2) - await self._communicator.passthrough( - "su -c 'am start-foreground-service -n com.mad.pogodroid/.services.HookReceiverService'") - await asyncio.sleep(5) - await self._communicator.stop_app("com.nianticlabs.pokemongo") - await asyncio.sleep(10) - await self._communicator.start_app("com.nianticlabs.pokemongo") + logger.info("Sleeping 120 seconds after clicking the account to login with - please wait!") await asyncio.sleep(120) + if await self.get_devicesettings_value(MappingManagerDevicemappingKey.EXTENDED_LOGIN, False): + logger.info("Extended login enabled. Restarting pogo with PD fully enabled again") + 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(2) + await self._communicator.passthrough( + "su -c 'am start-foreground-service -n com.mad.pogodroid/.services.HookReceiverService'") + await asyncio.sleep(5) + await self._communicator.stop_app("com.nianticlabs.pokemongo") + await asyncio.sleep(10) + await self._communicator.start_app("com.nianticlabs.pokemongo") + await asyncio.sleep(120) else: screentype = ScreenType.ERROR return screentype @@ -590,15 +592,17 @@ 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 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.stop_app("com.nianticlabs.pokemongo") - await asyncio.sleep(10) - await self._communicator.start_app("com.nianticlabs.pokemongo") + if await self.get_devicesettings_value(MappingManagerDevicemappingKey.EXTENDED_LOGIN, False): + logger.info("Extended login, stopping PD entirely and restarting POGO.") + # 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.stop_app("com.nianticlabs.pokemongo") + await asyncio.sleep(10) + await self._communicator.start_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