Skip to content

Commit

Permalink
Add extended_login option to intentionally stop PD during login.
Browse files Browse the repository at this point in the history
  • Loading branch information
Grennith committed Feb 18, 2024
1 parent 3b13db1 commit 11766b9
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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')
2 changes: 2 additions & 0 deletions mapadroid/db/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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')
Expand Down
12 changes: 11 additions & 1 deletion mapadroid/db/resource_definitions/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
}
}
12 changes: 11 additions & 1 deletion mapadroid/db/resource_definitions/Devicepool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
}
}
2 changes: 2 additions & 0 deletions mapadroid/mapping_manager/MappingManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ class MappingManagerDevicemappingKey(IntEnum):
ENHANCED_MODE_QUEST_SAFE_ITEMS = 40
SOFTBAR_ENABLED = 42
EXTENDED_PERMISSION_TOGGLING = 43
EXTENDED_LOGIN = 44
44 changes: 24 additions & 20 deletions mapadroid/ocr/screenPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 11766b9

Please sign in to comment.