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

Commit 228a3848 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

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



Change-Id: Ie490c0094aafbbd0c43dc26250c2172ea05c1af3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7ebaecf0 bf481386
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;