Search in sources :

Example 1 with INfcFCardEmulation

use of android.nfc.INfcFCardEmulation in project android_frameworks_base by ResurrectionRemix.

the class NfcFCardEmulation method getInstance.

/**
     * Helper to get an instance of this class.
     *
     * @param adapter A reference to an NfcAdapter object.
     * @return
     */
public static synchronized NfcFCardEmulation getInstance(NfcAdapter adapter) {
    if (adapter == null)
        throw new NullPointerException("NfcAdapter is null");
    Context context = adapter.getContext();
    if (context == null) {
        Log.e(TAG, "NfcAdapter context is null.");
        throw new UnsupportedOperationException();
    }
    if (!sIsInitialized) {
        IPackageManager pm = ActivityThread.getPackageManager();
        if (pm == null) {
            Log.e(TAG, "Cannot get PackageManager");
            throw new UnsupportedOperationException();
        }
        try {
            if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF, 0)) {
                Log.e(TAG, "This device does not support NFC-F card emulation");
                throw new UnsupportedOperationException();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "PackageManager query failed.");
            throw new UnsupportedOperationException();
        }
        sIsInitialized = true;
    }
    NfcFCardEmulation manager = sCardEmus.get(context);
    if (manager == null) {
        // Get card emu service
        INfcFCardEmulation service = adapter.getNfcFCardEmulationService();
        if (service == null) {
            Log.e(TAG, "This device does not implement the INfcFCardEmulation interface.");
            throw new UnsupportedOperationException();
        }
        manager = new NfcFCardEmulation(context, service);
        sCardEmus.put(context, manager);
    }
    return manager;
}
Also used : Context(android.content.Context) IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException) INfcFCardEmulation(android.nfc.INfcFCardEmulation) INfcFCardEmulation(android.nfc.INfcFCardEmulation)

Example 2 with INfcFCardEmulation

use of android.nfc.INfcFCardEmulation in project android_frameworks_base by AOSPA.

the class NfcFCardEmulation method getInstance.

/**
     * Helper to get an instance of this class.
     *
     * @param adapter A reference to an NfcAdapter object.
     * @return
     */
public static synchronized NfcFCardEmulation getInstance(NfcAdapter adapter) {
    if (adapter == null)
        throw new NullPointerException("NfcAdapter is null");
    Context context = adapter.getContext();
    if (context == null) {
        Log.e(TAG, "NfcAdapter context is null.");
        throw new UnsupportedOperationException();
    }
    if (!sIsInitialized) {
        IPackageManager pm = ActivityThread.getPackageManager();
        if (pm == null) {
            Log.e(TAG, "Cannot get PackageManager");
            throw new UnsupportedOperationException();
        }
        try {
            if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF, 0)) {
                Log.e(TAG, "This device does not support NFC-F card emulation");
                throw new UnsupportedOperationException();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "PackageManager query failed.");
            throw new UnsupportedOperationException();
        }
        sIsInitialized = true;
    }
    NfcFCardEmulation manager = sCardEmus.get(context);
    if (manager == null) {
        // Get card emu service
        INfcFCardEmulation service = adapter.getNfcFCardEmulationService();
        if (service == null) {
            Log.e(TAG, "This device does not implement the INfcFCardEmulation interface.");
            throw new UnsupportedOperationException();
        }
        manager = new NfcFCardEmulation(context, service);
        sCardEmus.put(context, manager);
    }
    return manager;
}
Also used : Context(android.content.Context) IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException) INfcFCardEmulation(android.nfc.INfcFCardEmulation) INfcFCardEmulation(android.nfc.INfcFCardEmulation)

Example 3 with INfcFCardEmulation

use of android.nfc.INfcFCardEmulation in project platform_frameworks_base by android.

the class NfcFCardEmulation method getInstance.

/**
     * Helper to get an instance of this class.
     *
     * @param adapter A reference to an NfcAdapter object.
     * @return
     */
public static synchronized NfcFCardEmulation getInstance(NfcAdapter adapter) {
    if (adapter == null)
        throw new NullPointerException("NfcAdapter is null");
    Context context = adapter.getContext();
    if (context == null) {
        Log.e(TAG, "NfcAdapter context is null.");
        throw new UnsupportedOperationException();
    }
    if (!sIsInitialized) {
        IPackageManager pm = ActivityThread.getPackageManager();
        if (pm == null) {
            Log.e(TAG, "Cannot get PackageManager");
            throw new UnsupportedOperationException();
        }
        try {
            if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF, 0)) {
                Log.e(TAG, "This device does not support NFC-F card emulation");
                throw new UnsupportedOperationException();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "PackageManager query failed.");
            throw new UnsupportedOperationException();
        }
        sIsInitialized = true;
    }
    NfcFCardEmulation manager = sCardEmus.get(context);
    if (manager == null) {
        // Get card emu service
        INfcFCardEmulation service = adapter.getNfcFCardEmulationService();
        if (service == null) {
            Log.e(TAG, "This device does not implement the INfcFCardEmulation interface.");
            throw new UnsupportedOperationException();
        }
        manager = new NfcFCardEmulation(context, service);
        sCardEmus.put(context, manager);
    }
    return manager;
}
Also used : Context(android.content.Context) IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException) INfcFCardEmulation(android.nfc.INfcFCardEmulation) INfcFCardEmulation(android.nfc.INfcFCardEmulation)

Example 4 with INfcFCardEmulation

use of android.nfc.INfcFCardEmulation in project android_frameworks_base by DirtyUnicorns.

the class NfcFCardEmulation method getInstance.

/**
     * Helper to get an instance of this class.
     *
     * @param adapter A reference to an NfcAdapter object.
     * @return
     */
public static synchronized NfcFCardEmulation getInstance(NfcAdapter adapter) {
    if (adapter == null)
        throw new NullPointerException("NfcAdapter is null");
    Context context = adapter.getContext();
    if (context == null) {
        Log.e(TAG, "NfcAdapter context is null.");
        throw new UnsupportedOperationException();
    }
    if (!sIsInitialized) {
        IPackageManager pm = ActivityThread.getPackageManager();
        if (pm == null) {
            Log.e(TAG, "Cannot get PackageManager");
            throw new UnsupportedOperationException();
        }
        try {
            if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF, 0)) {
                Log.e(TAG, "This device does not support NFC-F card emulation");
                throw new UnsupportedOperationException();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "PackageManager query failed.");
            throw new UnsupportedOperationException();
        }
        sIsInitialized = true;
    }
    NfcFCardEmulation manager = sCardEmus.get(context);
    if (manager == null) {
        // Get card emu service
        INfcFCardEmulation service = adapter.getNfcFCardEmulationService();
        if (service == null) {
            Log.e(TAG, "This device does not implement the INfcFCardEmulation interface.");
            throw new UnsupportedOperationException();
        }
        manager = new NfcFCardEmulation(context, service);
        sCardEmus.put(context, manager);
    }
    return manager;
}
Also used : Context(android.content.Context) IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException) INfcFCardEmulation(android.nfc.INfcFCardEmulation) INfcFCardEmulation(android.nfc.INfcFCardEmulation)

Example 5 with INfcFCardEmulation

use of android.nfc.INfcFCardEmulation in project android_frameworks_base by crdroidandroid.

the class NfcFCardEmulation method getInstance.

/**
     * Helper to get an instance of this class.
     *
     * @param adapter A reference to an NfcAdapter object.
     * @return
     */
public static synchronized NfcFCardEmulation getInstance(NfcAdapter adapter) {
    if (adapter == null)
        throw new NullPointerException("NfcAdapter is null");
    Context context = adapter.getContext();
    if (context == null) {
        Log.e(TAG, "NfcAdapter context is null.");
        throw new UnsupportedOperationException();
    }
    if (!sIsInitialized) {
        IPackageManager pm = ActivityThread.getPackageManager();
        if (pm == null) {
            Log.e(TAG, "Cannot get PackageManager");
            throw new UnsupportedOperationException();
        }
        try {
            if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF, 0)) {
                Log.e(TAG, "This device does not support NFC-F card emulation");
                throw new UnsupportedOperationException();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "PackageManager query failed.");
            throw new UnsupportedOperationException();
        }
        sIsInitialized = true;
    }
    NfcFCardEmulation manager = sCardEmus.get(context);
    if (manager == null) {
        // Get card emu service
        INfcFCardEmulation service = adapter.getNfcFCardEmulationService();
        if (service == null) {
            Log.e(TAG, "This device does not implement the INfcFCardEmulation interface.");
            throw new UnsupportedOperationException();
        }
        manager = new NfcFCardEmulation(context, service);
        sCardEmus.put(context, manager);
    }
    return manager;
}
Also used : Context(android.content.Context) IPackageManager(android.content.pm.IPackageManager) RemoteException(android.os.RemoteException) INfcFCardEmulation(android.nfc.INfcFCardEmulation) INfcFCardEmulation(android.nfc.INfcFCardEmulation)

Aggregations

Context (android.content.Context)5 IPackageManager (android.content.pm.IPackageManager)5 INfcFCardEmulation (android.nfc.INfcFCardEmulation)5 RemoteException (android.os.RemoteException)5