Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5193b24 authored by Nick Pelly's avatar Nick Pelly
Browse files

Fix NPE on devices that don't have NFC.

We should return null instead of NPE.

Bug: 5622939
Change-Id: I802f4a99ea9f5e73453d5ea30da4e1d9fa279b9c
parent 7dc81e06
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -360,6 +360,10 @@ public final class NfcAdapter {
        /* use getSystemService() instead of just instantiating to take
         * advantage of the context's cached NfcManager & NfcAdapter */
        NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
        if (manager == null) {
            // NFC not available
            return null;
        }
        return manager.getDefaultAdapter();
    }