Enforce package visibility filter on the PreferredActivities
A security fix to enforce package visibility filter on the api of PackageManager#getPreferredActivities. Bug: 188218313 Test: atest AppEnumerationTests Change-Id: I73e2385ee51e1921dc1abe4292a66a4d9a7f15ed
This commit is contained in:
@@ -22120,7 +22120,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
*/
|
||||
public int getPreferredActivitiesInternal(List<WatchedIntentFilter> outFilters,
|
||||
List<ComponentName> outActivities, String packageName) {
|
||||
if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
if (getInstantAppPackageName(callingUid) != null) {
|
||||
return 0;
|
||||
}
|
||||
int num = 0;
|
||||
@@ -22132,9 +22133,13 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
final Iterator<PreferredActivity> it = pir.filterIterator();
|
||||
while (it.hasNext()) {
|
||||
final PreferredActivity pa = it.next();
|
||||
final String prefPackageName = pa.mPref.mComponent.getPackageName();
|
||||
if (packageName == null
|
||||
|| (pa.mPref.mComponent.getPackageName().equals(packageName)
|
||||
&& pa.mPref.mAlways)) {
|
||||
|| (prefPackageName.equals(packageName) && pa.mPref.mAlways)) {
|
||||
if (shouldFilterApplicationLocked(
|
||||
mSettings.getPackageLPr(prefPackageName), callingUid, userId)) {
|
||||
continue;
|
||||
}
|
||||
if (outFilters != null) {
|
||||
outFilters.add(new WatchedIntentFilter(pa.getIntentFilter()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user