pidcat icon indicating copy to clipboard operation
pidcat copied to clipboard

fix bash completion of package names for the filter arg

Open eighthave opened this issue 10 years ago • 10 comments

Not all devices can do ls /data/data, so instead use the running process list, which should be guaranteed to be public to all running processes.

eighthave avatar Dec 21 '15 14:12 eighthave

The only downside here is that it restricts to running packages. What about using pm list packages -f instead?

JakeWharton avatar Dec 21 '15 15:12 JakeWharton

I was thinking that restricting it to running packages was actually a feature since that'll make the completion list a lot shorter, and what are the chances of someone wanting to get the logcat of a process that isn't running? I suppose it might be that the process has been totally killed or died somehow in the process of debugging, and that would be annoying that it doesn't show up in the completion.

pm list packages -f gives a big list, including all of the system apps. I think to go that route, it would require grep /data to limit the completion list to filter out the system apps to keep the completion list's signal-to-noise high.

eighthave avatar Dec 22 '15 12:12 eighthave

Also, any ideas on whether pm list packages -f is always implemented and runnable without root? When was it added to Android? ps is as close to a guarantee as I can think of with Android.

eighthave avatar Dec 22 '15 12:12 eighthave

The package manager has been around since API 1, so presumably the command has as well. And yes it does not require root.

what are the chances of someone wanting to get the logcat of a process that isn't running?

90% of the time I'm starting pidcat before the app I want to observe.

JakeWharton avatar Dec 22 '15 15:12 JakeWharton

I updated it to use pm list packages -3 to only list the user installed packages, i.e. those in /data. It's been working well for me, but I haven't tried it on anything older than 4.4.2.

eighthave avatar Dec 23 '15 21:12 eighthave

In my opinion we should just use adb shell pm list packages without any options, as that will list all installed packages. Other than that, any plans to merge this?

AlvaroBrey avatar May 18 '17 15:05 AlvaroBrey

without -3 there was a lot of pointless noise in the completion, from all the system apps

eighthave avatar May 18 '17 15:05 eighthave

You are assuming other users don't want to filter for a system app, which we do.

AlvaroBrey avatar May 18 '17 15:05 AlvaroBrey

Why is it not merged? I made own implementation with awk for local use:

    local apks=$(adb $device_selected shell 'pm list packages -3' 2>/dev/null | awk '
BEGIN {ORS=" "}
$1 ~/package:/ { gsub(/^.*:/,""); gsub(/\r*$/,""); print $1 }')

gavenkoa avatar Nov 20 '17 11:11 gavenkoa

@JakeWharton any plans on merging this?

AlvaroBrey avatar Dec 13 '17 11:12 AlvaroBrey