Skip to content
This repository was archived by the owner on Jan 5, 2022. It is now read-only.

Commit 2267b0f

Browse files
committed
Making sure apps reported by pm list packages are really apps
- due to some Xposed alterations, some libs throw warnings there, resulting in those being treated as apps - other than originally assumed by reporter, this output goes to STDOUT (not STDERR), so additional filtering was required
1 parent 83c5286 commit 2267b0f

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

adebar-cli

+15-9
Original file line numberDiff line numberDiff line change
@@ -284,21 +284,27 @@ initAppLists() {
284284

285285
doProgress "- userApps" 2
286286
for app in $(adb ${ADBOPTS} shell pm list packages -3 2>/dev/null); do
287-
app=${app//[$'\t\r\n']} # remove trailing CR (^M)
288-
userApps+=(${app##*:})
287+
if [[ "${app}" =~ ^package: ]]; then
288+
app=${app//[$'\t\r\n']} # remove trailing CR (^M)
289+
userApps+=(${app##*:})
290+
fi
289291
done
290292
doProgress "- systemApps" 2
291293
for app in $(adb ${ADBOPTS} shell pm list packages -s 2>/dev/null); do
292-
app=${app//[$'\t\r\n']}
293-
sysApps+=(${app##*:})
294+
if [[ "${app}" =~ ^package: ]]; then
295+
app=${app//[$'\t\r\n']}
296+
sysApps+=(${app##*:})
297+
fi
294298
done
295299
doProgress "- checking for uninstalled apps remembered by the system" 2
296300
for app in $(adb ${ADBOPTS} shell pm list packages -u 2>/dev/null); do
297-
app=${app//[$'\t\r\n']}
298-
in_array "${app##*:}" ${sysApps[@]} && continue
299-
in_array "${app##*:}" ${userApps[@]} && continue
300-
dApps+=($app)
301-
echo "Removed app: ${app##*:}"
301+
if [[ "${app}" =~ ^package: ]]; then
302+
app=${app//[$'\t\r\n']}
303+
in_array "${app##*:}" ${sysApps[@]} && continue
304+
in_array "${app##*:}" ${userApps[@]} && continue
305+
dApps+=($app)
306+
echo "Found removed app entry: ${app##*:}"
307+
fi
302308
done
303309
}
304310

lib/scriptgen.lib

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ getDisabled() {
2222
echo >> "${scriptname}"
2323

2424
for app in $(adb ${ADBOPTS} shell "pm list packages -d 2>/dev/null"); do
25-
app=${app//[$'\t\r\n']}
26-
echo "adb ${ADBOPTS} shell \"pm disable ${app##*:}\"" >> "${scriptname}"
25+
if [[ "${app}" =~ ^package: ]]; then
26+
app=${app//[$'\t\r\n']}
27+
echo "adb ${ADBOPTS} shell \"pm disable ${app##*:}\"" >> "${scriptname}"
28+
fi
2729
done
2830

2931
chmod u+x "${scriptname}"

0 commit comments

Comments
 (0)