Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Unified Diff: device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.java

Issue 2315203002: [webnfc] Do not disable reader mode if NFC is turned off (Closed)
Patch Set: [webnfc] Do not disable NFC reader mode if nfc is turned off Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.java
diff --git a/device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.java b/device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.java
index fd6fbdc320430247ecce6abb661a1cc72b2f78a5..7552488ed268b7853dc9395f08d9351c0015bfed 100644
--- a/device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.java
+++ b/device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.java
@@ -346,7 +346,7 @@ public class NfcImpl implements Nfc {
private void enableReaderMode() {
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.
if (mPendingPushOperation == null) return;
@@ -366,8 +366,12 @@ public class NfcImpl implements Nfc {
private void disableReaderMode() {
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;
- if (mActivity != null && !mActivity.isDestroyed()) {
+ if (mActivity != null && mNfcAdapter != null && !mActivity.isDestroyed()) {
mNfcAdapter.disableReaderMode(mActivity);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698