Commit 1dd3158d authored by Francois Beaufort's avatar Francois Beaufort Committed by Commit Bot

[WebNFC] Don't play sound when a tag is discovered

Setting the FLAG_READER_NO_PLATFORM_SOUNDS flag allows us to prevent
Android from playing sounds when it discovers a tag. Vibration still
occurs though with same duration as Android (200ms).

Change-Id: If39b880a0b7a69da1a8917fd643ec0846119a47f
Bug: 1011325
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1840611Reviewed-by: default avatarRijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#704760}
parent 93855ff4
......@@ -18,6 +18,7 @@ import android.nfc.TagLostException;
import android.os.Build;
import android.os.Handler;
import android.os.Process;
import android.os.Vibrator;
import android.util.SparseArray;
import org.chromium.base.Callback;
......@@ -119,6 +120,11 @@ public class NfcImpl implements Nfc {
*/
private Runnable mPushTimeoutRunnable;
/**
* Vibrator. @see android.os.Vibrator
*/
private Vibrator mVibrator;
public NfcImpl(int hostId, NfcDelegate delegate) {
mHostId = hostId;
mDelegate = delegate;
......@@ -148,6 +154,9 @@ public class NfcImpl implements Nfc {
mNfcAdapter = mNfcManager.getDefaultAdapter();
}
}
mVibrator = (Vibrator) ContextUtils.getApplicationContext().getSystemService(
Context.VIBRATOR_SERVICE);
}
/**
......@@ -437,7 +446,8 @@ public class NfcImpl implements Nfc {
mReaderCallbackHandler = new ReaderCallbackHandler(this);
mNfcAdapter.enableReaderMode(mActivity, mReaderCallbackHandler,
NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NFC_B
| NfcAdapter.FLAG_READER_NFC_F | NfcAdapter.FLAG_READER_NFC_V,
| NfcAdapter.FLAG_READER_NFC_F | NfcAdapter.FLAG_READER_NFC_V
| NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS,
null);
}
......@@ -652,6 +662,7 @@ public class NfcImpl implements Nfc {
* Called by ReaderCallbackHandler when NFC tag is in proximity.
*/
public void onTagDiscovered(Tag tag) {
mVibrator.vibrate(200);
processPendingOperations(NfcTagHandler.create(tag));
}
......
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