Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit e2d078ef authored by Robert Horvath's avatar Robert Horvath
Browse files

LogcatManagerService: Find packageName through parent PIDs

Log access requests may come from forked processes, eg. by a logcat
process started by an app. In such cases, `getPackageNameByPid` failed
to return a package name, as the process (eg. logcat) does not have a
package name associated with it. As a fallback we used the first package
name returned by `PackageManager#getPackagesForUid`, but this method
returns package names in an indeterministic order, so the same app doing
multiple log accesses could trigger multiple log access dialogs if the
order differed.

To find a better package name match, this change walks up the process
tree to find a package name that forked the requesting process and
matches the requesting UID.
As a fallback, the list returned by `PackageManager#getPackagesForUid`
is sorted before picking the first element.

Bug: 229279048
Test: Manual, sending feedback through assistant
Test: atest FrameworksServicesTests:LogcatManagerServiceTest
Change-Id: I7ac044ac012be8c3911f3c4ce35c06215d078fe6
parent 6f628631
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment