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

Commit 867815f0 authored by Roshan Pius's avatar Roshan Pius Committed by Gerrit Code Review
Browse files

Merge "nfc(api): Separate out NfcExtras from nfc APIs (2/2)" into main

parents 5d339d0a aff3d1fd
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -76,9 +76,22 @@ public final class NfcAdapterExtras {
    private final NfcAdapter mAdapter;
    final String mPackageName;

    private static INfcAdapterExtras
        getNfcAdapterExtrasInterfaceFromNfcAdapter(NfcAdapter adapter) {
        try {
            Method method = NfcAdapter.class.getDeclaredMethod("getNfcAdapterExtrasInterface");
            method.setAccessible(true);
            return (INfcAdapterExtras) method.invoke(adapter);
        } catch (SecurityException | NoSuchMethodException | IllegalArgumentException
                 | IllegalAccessException | IllegalAccessError | InvocationTargetException e) {
            Log.e(TAG, "Unable to get context from NfcAdapter");
        }
        return null;
    }

    /** get service handles */
    private static void initService(NfcAdapter adapter) {
        final INfcAdapterExtras service = adapter.getNfcAdapterExtrasInterface();
        final INfcAdapterExtras service = getNfcAdapterExtrasInterfaceFromNfcAdapter(adapter);
        if (service != null) {
            // Leave stale rather than receive a null value.
            sService = service;