@@ -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
209221def run_pidcat (package_name ):
0 commit comments