From e2c0b5fe4b562b8fb101bb7a18f480d3e79c1201 Mon Sep 17 00:00:00 2001 From: Katsiaryna Naliuka Date: Tue, 18 Feb 2020 19:26:21 +0100 Subject: [PATCH] Handle the case of null intent type when obtaining target intent filter. Currently the method swallows the exception but that pollutes the logs. This change preserves the behavior while getting rid of distracting errors in the logs. Test: atest IntentTest; atest ChooserActivityTest Change-Id: I2b02dc4ae0343fa1fd58a112455e426d8a6d3f34 --- core/java/com/android/internal/app/ChooserActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index 65cad834d5be0..a2eff17d53929 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -1795,6 +1795,10 @@ public class ChooserActivity extends ResolverActivity implements if (!TextUtils.isEmpty(dataString)) { return new IntentFilter(intent.getAction(), dataString); } + if (intent.getType() == null) { + Log.e(TAG, "Failed to get target intent filter: intent data and type are null"); + return null; + } IntentFilter intentFilter = new IntentFilter(intent.getAction(), intent.getType()); List contentUris = new ArrayList<>(); if (Intent.ACTION_SEND.equals(intent.getAction())) { @@ -1815,7 +1819,7 @@ public class ChooserActivity extends ResolverActivity implements } return intentFilter; } catch (Exception e) { - Log.e(TAG, "failed to get target intent filter", e); + Log.e(TAG, "Failed to get target intent filter", e); return null; } }