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

Commit 20e62c9f authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Support for getTimeout() (API).

Bug: 4492175
Change-Id: Ibc9a1b78d8c0992f47664d33760e0ce8dca67c64
parent be4ad4ac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,5 +44,6 @@ interface INfcTag
    Tag rediscover(int nativehandle);

    int setTimeout(int technology, int timeout);
    int getTimeout(int technology);
    void resetTimeouts();
}
+18 −0
Original line number Diff line number Diff line
@@ -100,6 +100,24 @@ public final class IsoDep extends BasicTagTechnology {
        }
    }

    /**
     * Gets the currently set timeout of {@link #transceive} in milliseconds.
     *
     * <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
     *
     * @return timeout value in milliseconds
     * @hide
     */
    // TODO Unhide for ICS
    public int getTimeout() {
        try {
            return mTag.getTagService().getTimeout(TagTechnology.ISO_DEP);
        } catch (RemoteException e) {
            Log.e(TAG, "NFC service dead", e);
            return 0;
        }
    }

    /**
     * Return the ISO-DEP historical bytes for {@link NfcA} tags.
     * <p>Does not cause any RF activity and does not block.
+18 −0
Original line number Diff line number Diff line
@@ -597,6 +597,24 @@ public final class MifareClassic extends BasicTagTechnology {
        }
    }

    /**
     * Gets the currently set timeout of {@link #transceive} in milliseconds.
     *
     * <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
     *
     * @return timeout value in milliseconds
     * @hide
     */
    // TODO Unhide for ICS
    public int getTimeout() {
        try {
            return mTag.getTagService().getTimeout(TagTechnology.MIFARE_CLASSIC);
        } catch (RemoteException e) {
            Log.e(TAG, "NFC service dead", e);
            return 0;
        }
    }

    private static void validateSector(int sector) {
        // Do not be too strict on upper bounds checking, since some cards
        // have more addressable memory than they report. For example,
+18 −0
Original line number Diff line number Diff line
@@ -238,6 +238,24 @@ public final class MifareUltralight extends BasicTagTechnology {
        }
    }

    /**
     * Gets the currently set timeout of {@link #transceive} in milliseconds.
     *
     * <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
     *
     * @return timeout value in milliseconds
     * @hide
     */
    // TODO Unhide for ICS
    public int getTimeout() {
        try {
            return mTag.getTagService().getTimeout(TagTechnology.MIFARE_ULTRALIGHT);
        } catch (RemoteException e) {
            Log.e(TAG, "NFC service dead", e);
            return 0;
        }
    }

    private static void validatePageIndex(int pageIndex) {
        // Do not be too strict on upper bounds checking, since some cards
        // may have more addressable memory than they report.
+18 −0
Original line number Diff line number Diff line
@@ -141,4 +141,22 @@ public final class NfcA extends BasicTagTechnology {
            Log.e(TAG, "NFC service dead", e);
        }
    }

    /**
     * Gets the currently set timeout of {@link #transceive} in milliseconds.
     *
     * <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
     *
     * @return timeout value in milliseconds
     * @hide
     */
    // TODO Unhide for ICS
    public int getTimeout() {
        try {
            return mTag.getTagService().getTimeout(TagTechnology.NFC_A);
        } catch (RemoteException e) {
            Log.e(TAG, "NFC service dead", e);
            return 0;
        }
    }
}
Loading