Enforce package visibility to the api shouldHideFromSuggestions

App can query which applications are installed on the device via
api LauncherApps#shouldHideFromSuggestions. This cl enforces
package visibility filter to the api fix the security issue.

Bug: 191147534
Test: atest AppEnumerationTests
Change-Id: I40589f42b14c8a3e9372647d89a35203acaacd14
This commit is contained in:
Rhed Jao
2021-07-01 18:01:50 +08:00
parent 7b7ff66c39
commit 63cfbfcc09

View File

@@ -407,11 +407,16 @@ public class LauncherAppsService extends SystemService {
@Override
public boolean shouldHideFromSuggestions(String packageName, UserHandle user) {
if (!canAccessProfile(user.getIdentifier(), "cannot get shouldHideFromSuggestions")) {
final int userId = user.getIdentifier();
if (!canAccessProfile(userId, "cannot get shouldHideFromSuggestions")) {
return false;
}
final int flags = mPackageManagerInternal.getDistractingPackageRestrictions(packageName,
user.getIdentifier());
if (mPackageManagerInternal.filterAppAccess(
packageName, Binder.getCallingUid(), userId)) {
return false;
}
final int flags = mPackageManagerInternal.getDistractingPackageRestrictions(
packageName, userId);
return (flags & PackageManager.RESTRICTION_HIDE_FROM_SUGGESTIONS) != 0;
}