Commit da30dde2 authored by alexander.shalamov's avatar alexander.shalamov Committed by Commit bot

[webnfc] Do not disable NFC reader mode if nfc is turned off

Don't disable NFC reader mode when feature is turned off, since
the system NFC manager returns null NFCAdapter.

BUG=640890,640995

Review-Url: https://codereview.chromium.org/2315203002
Cr-Commit-Position: refs/heads/master@{#417003}
parent 5a28ce53
...@@ -346,7 +346,7 @@ public class NfcImpl implements Nfc { ...@@ -346,7 +346,7 @@ public class NfcImpl implements Nfc {
private void enableReaderMode() { private void enableReaderMode() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
if (mReaderCallbackHandler != null || mActivity == null) return; if (mReaderCallbackHandler != null || mActivity == null || mNfcAdapter == null) return;
// TODO(crbug.com/625589): Check if there are active watch operations. // TODO(crbug.com/625589): Check if there are active watch operations.
if (mPendingPushOperation == null) return; if (mPendingPushOperation == null) return;
...@@ -366,8 +366,12 @@ public class NfcImpl implements Nfc { ...@@ -366,8 +366,12 @@ public class NfcImpl implements Nfc {
private void disableReaderMode() { private void disableReaderMode() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
// There is no API that could query whether reader mode is enabled for adapter.
// If mReaderCallbackHandler is null, reader mode is not enabled.
if (mReaderCallbackHandler == null) return;
mReaderCallbackHandler = null; mReaderCallbackHandler = null;
if (mActivity != null && !mActivity.isDestroyed()) { if (mActivity != null && mNfcAdapter != null && !mActivity.isDestroyed()) {
mNfcAdapter.disableReaderMode(mActivity); mNfcAdapter.disableReaderMode(mActivity);
} }
} }
......
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