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
Loading
Please register or sign in to comment