Commit 6792f109 authored by Francois Beaufort's avatar Francois Beaufort Committed by Commit Bot

[WebNFC] Check if NFC Settings intent can be resolved

This CL fixes a crash on some samsung android devices where the link
between ACTION_NFC_SETTINGS and the NFC settings-menu is broken. NFC
settings intent is only returned from now on only if we're confident
activity can be opened, to prevent an android java exception
"android.content.ActivityNotFoundException".

See https://developer.android.com/guide/components/intents-common

Bug: 1035048, 1055216
Change-Id: Ibedd48cf9aded28def53753275747c4addaa220a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072158Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#745013}
parent a334e12b
...@@ -76,7 +76,12 @@ public class NfcSystemLevelSetting { ...@@ -76,7 +76,12 @@ public class NfcSystemLevelSetting {
} }
public static Intent getNfcSystemLevelSettingIntent() { public static Intent getNfcSystemLevelSettingIntent() {
return new Intent(Settings.ACTION_NFC_SETTINGS); Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS);
Context context = ContextUtils.getApplicationContext();
if (intent.resolveActivity(context.getPackageManager()) == null) {
return null;
}
return intent;
} }
/** Disable/enable Android NFC setting for testing use only. */ /** Disable/enable Android NFC setting for testing use only. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment