Ensure only valid events are reported.
When CHOOSER_ACTION events are reported via reportChooserSelection, make sure the package name is not null and is also a valid, installed package. Bug: 229633537 Bug: 253403242 Test: atest UsageStatsTest Change-Id: Ib28014f2d21b451d2f7f6e7136f500fc49d0779b
This commit is contained in:
@@ -2539,10 +2539,14 @@ public class UsageStatsService extends SystemService implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportChooserSelection(String packageName, int userId, String contentType,
|
||||
String[] annotations, String action) {
|
||||
public void reportChooserSelection(@NonNull String packageName, int userId,
|
||||
String contentType, String[] annotations, String action) {
|
||||
if (packageName == null) {
|
||||
Slog.w(TAG, "Event report user selecting a null package");
|
||||
throw new IllegalArgumentException("Package selection must not be null.");
|
||||
}
|
||||
// Verify if this package exists before reporting an event for it.
|
||||
if (mPackageManagerInternal.getPackageUid(packageName, 0, userId) < 0) {
|
||||
Slog.w(TAG, "Event report user selecting an invalid package");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user