Merge "Ensure only valid events are reported." into udc-dev am: ab109af8fa am: 25fe9840ec

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23067922

Change-Id: If82a400acdb1a3bb0b746557ff0eae809321fa30
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-05-12 22:30:54 +00:00
committed by Automerger Merge Worker

View File

@@ -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;
}