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
This commit is contained in:
Katsiaryna Naliuka
2020-02-18 19:26:21 +01:00
parent 753216ebc7
commit e2c0b5fe4b

View File

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