Skip to content

Commit

Permalink
Show package userId and fix copy app info
Browse files Browse the repository at this point in the history
  • Loading branch information
zjn0505 committed Aug 29, 2022
1 parent 9efb946 commit d4ed3b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
CMD_CHECK_KEYBOARD = adbshell + "dumpsys input_method | grep mInputShown | awk '{{print $4}}'"

# Dump package
CMD_DUMP_PACKAGE = adbshell + "dumpsys package {} | grep 'versionCode\|versionName\|enabled=\|android.intent.action.MAIN' | tail -r"
CMD_DUMP_PACKAGE = adbshell + "dumpsys package {} | grep 'versionCode\|versionName\|enabled=\|android.intent.action.MAIN\|userId' | tail -r"

# Dump task stack
CMD_DUMP_STACK = adbshell + "dumpsys activity activities | grep 'Hist \|taskAffinity='"
20 changes: 16 additions & 4 deletions show_package_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def main(wf):
infos= None
versionName = ""
enabled = True
userId = None
versionCopyText = ""
# Package info
try:
result = run_script(shell_cmd)
Expand All @@ -24,25 +26,35 @@ def main(wf):
result = result[result.rfind("enabled="):]
infos = result.rstrip().split('\n')
log.debug(infos)

userIdInfo = [x.strip() for x in infos if x.strip().startswith("userId=")]
log.debug(userIdInfo)
if len(userIdInfo) == 1:
userId = userIdInfo[0][7:]

versionName = infos[1].strip()[12:]
versionCode = infos[2].strip()[12:]
if userId != None:
versionCode = versionCode + " userId={0}".format(userId)
it = wf.add_item(title=packName,
subtitle="{0}({1})".format(versionName, versionCode),
valid=False,
copytext=packName,
icon=ICON_INFO)
versionCopyText = it.subtitle
if infos:
appInfo = infos[0].strip()
enabled = (appInfo[appInfo.find("enabled=") + 8] != '2')
log.debug("enabled ? {0}".format(enabled))

# App info
title = "App info"
wf.add_item(title=title,
it = wf.add_item(title=title,
subtitle="Open app info page",
arg="app_info",
valid=True)
it.add_modifier("cmd", subtitle="Copy version name")
copytext=versionCopyText,
valid=True)
it.add_modifier("cmd", subtitle="cmd + C to copy app info")

if (infos and enabled):
# Force stop
Expand All @@ -51,7 +63,7 @@ def main(wf):
arg="force_stop",
valid=True)

if (infos and len(infos) > 3 and enabled):
if (infos and len(infos) > 4 and enabled):
# Start app
title = "Start application"
wf.add_item(title=title,
Expand Down

0 comments on commit d4ed3b8

Please sign in to comment.