Repository navigation
0.1.4
Fixes from the Operator v1 release review (MOB-395).
Changed (behaviour)
- HCE no longer serves while the phone is locked. The contributed
res/xml/mob_nfc_hce_apduservice.xmlnow declares
android:requireDeviceUnlock="true"(was"false"). - HCE emulation is foreground-only and is now stopped on background.
When the host activity pauses (backgrounded, screen off, a permission
prompt / dialog-style activity on top, an activity-recreating config change) the emulated payload is
dropped, the preferred-service claim released,MobNfcApduServicerefuses
every APDU (6A82), and the owner receives{:nfc, :emulation_stopped}.
Previously only the routing preference was released and the payload was
retained and re-armed on resume. Apps that want emulation back must call
MobNfc.emulate_ndef/3again, e.g. on{:mob_device, :did_become_active}. - An
emulate_ndef/3call that passes the up-front checks (size, payload, an
attached activity) but then fails ends any emulation already running, and a
successful one from another process replaces it; the previous owner gets
{:nfc, :emulation_stopped}in both cases. Reader mode is dropped only once
emulation is actually live, so a failed emulate no longer kills a reader
session.
Fixed
emulate_ndef/3no longer claims success on hardware that can't
emulate.{:nfc, :emulation_started}is sent only when the device has
FEATURE_NFC_HOST_CARD_EMULATION, the NFC adapter exists and is enabled,
the activity is resumed, andCardEmulation.setPreferredServicesucceeded.
Otherwise one error arrives instead:{:nfc, :error, :unavailable}
(no NFC / no HCE / app not in the foreground / routing refused),
{:nfc, :error, :disabled}(NFC switched off), matchingstart_reading/2,
or{:nfc, :error, :no_activity}(no host activity attached yet).- NDEF messages larger than the emulated file are rejected. The emulated
tag advertises a 1024-byte NDEF file including the 2-byte NLEN, so
emulate_ndef/3now rejects messages over 1022 bytes with
{:nfc, :error, :too_large}(checked in Elixir before the NIF, and again in
the Android bridge). NewMobNfc.Hce.max_message_size/0,
MobNfc.Hce.check_size/1, andMobNfc.Hce.stop/1(the pure reference for the
stopped-service behaviour);MobNfc.Hce.new/2raises on an oversized message.