Skip to content

Commit e867c49

Browse files
committed
Improved package listing
1 parent 7416360 commit e867c49

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ChangeLog
22

3+
### 0.7.58
4+
- CHANGE: Improved package listing (-l option)
5+
36
### 0.7.57
47
- CHANGE: Added sanitize_path in setup option
58
- ADDED: Version configuration for tools

mpt/console.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,31 @@ def list_packages(show_all_pkgs):
191191
if package[0].find('/data/app/') >= 0 \
192192
and not (package[1].startswith('com.google') or package[1].startswith('com.android')):
193193

194-
code = functions.run_command(
195-
'adb shell dumpsys package {} | grep -i pkgFlags | grep ALLOW_BACKUP'.format(package[1]),
196-
returncode=True)
194+
dumpsys_package = functions.run_command(f'adb shell dumpsys package {package[1]}', return_output=True)
195+
#print(dumpsys_package)
196+
# Find lines containing both 'pkgFlags' and 'ALLOW_BACKUP'
197+
# adb shell dumpsys package {package-name} | grep -i pkgFlags | grep ALLOW_BACKUP'
198+
backup_enabled = [line for line in dumpsys_package
199+
if 'pkgFlags' in line and 'ALLOW_BACKUP' in line]
200+
# adb shell dumpsys package "package-name" | grep versionName
201+
version = [line for line in dumpsys_package if 'versionName' in line]
202+
version = version[0].strip().split('=')[1]
203+
204+
if backup_enabled:
205+
backup_status = "[BACKUP]: " + Fore.GREEN + "enabled" + Style.RESET_ALL
206+
else:
207+
backup_status = "[BACKUP]: " + Fore.YELLOW + "disabled" + Style.RESET_ALL
197208

198-
if code:
199-
backup_status = "[BACKUP]: " + Fore.YELLOW + "disabled" + Style.RESET_ALL
209+
if backup_enabled:
210+
backup_status = Fore.GREEN + "ENABLED" + Style.RESET_ALL
200211
else:
201-
backup_status = "[BACKUP]: " + Fore.GREEN + "enabled" + Style.RESET_ALL
212+
backup_status = Fore.YELLOW + "disabled" + Style.RESET_ALL
202213

203214
print(Fore.CYAN + package[1] + Style.RESET_ALL)
204-
print(Style.BRIGHT + "[APP]: " + package[0] + Style.RESET_ALL)
205-
print(Style.BRIGHT + "[DIR]: " + os.path.join("/data/data/", package[1]) + Style.RESET_ALL)
206-
print(backup_status)
215+
print("[APP]: " + Style.BRIGHT + package[0] + Style.RESET_ALL)
216+
print("[DIR]: " + Style.BRIGHT + os.path.join("/data/data/", package[1]) + Style.RESET_ALL)
217+
print("[VERSION]: " + Style.BRIGHT + version + Style.RESET_ALL)
218+
print("[BACKUP]: " + backup_status)
207219

208220

209221
def run_pidcat(package_name):

mpt/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import mpt.config
66
from mpt.config import Config
77

8-
__version__ = '0.7.57'
8+
__version__ = '0.7.58'
99
HOME_FOLDER = expanduser("~")
1010
DEFAULT_MOBILE_FOLDER = os.path.join(HOME_FOLDER, "tools/MOBILE/")
1111
MPT_BIN = os.path.join(DEFAULT_MOBILE_FOLDER, 'bin')

0 commit comments

Comments
 (0)