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

Commit 98b44f35 authored by Roshan Pius's avatar Roshan Pius Committed by Automerger Merge Worker
Browse files

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

Merge "nfc(api): Separate out NfcExtras from nfc APIs (2/2)" into main am: 867815f0 am: bf481386 am: 228a3848

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2799358



Change-Id: If4794e81d8658325a0b3c6fe65f8227bf564be7a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6110e07f 228a3848
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;