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

Commit 90d2c04d authored by chloedai's avatar chloedai Committed by Chloe Dai
Browse files

Assign the nonce from NfcService while contructing a Tag object

1. Remove nonce setting method from AIDL, only NfcService could generate
nonce
2. NfcService directily assign a nonce to Tag object while contructing

Bug: 199291025
Test: test with some reader apps, test pass
Change-Id: I0cf3d22a785b463589f1ba9bd3ca49825839b9ce
Merged-In: I0cf3d22a785b463589f1ba9bd3ca49825839b9ce
parent 78622ed1
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -46,6 +46,5 @@ interface INfcTag
    int getMaxTransceiveLength(int technology);
    boolean getExtendedLengthApdusSupported();

    void setTagUpToDate(long cookie);
    boolean isTagUpToDate(long cookie);
}
+9 −14
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;

import java.io.IOException;
import java.util.Arrays;
@@ -119,17 +118,17 @@ public final class Tag implements Parcelable {
    final String[] mTechStringList;
    final Bundle[] mTechExtras;
    final int mServiceHandle;  // for use by NFC service, 0 indicates a mock
    final long mCookie;        // for accessibility checking
    final INfcTag mTagService; // interface to NFC service, will be null if mock tag

    int mConnectedTechnology;
    long mCookie;

    /**
     * Hidden constructor to be used by NFC service and internal classes.
     * @hide
     */
    public Tag(byte[] id, int[] techList, Bundle[] techListExtras, int serviceHandle,
            INfcTag tagService) {
            long cookie, INfcTag tagService) {
        if (techList == null) {
            throw new IllegalArgumentException("rawTargets cannot be null");
        }
@@ -139,20 +138,13 @@ public final class Tag implements Parcelable {
        // Ensure mTechExtras is as long as mTechList
        mTechExtras = Arrays.copyOf(techListExtras, techList.length);
        mServiceHandle = serviceHandle;
        mCookie = cookie;
        mTagService = tagService;

        mConnectedTechnology = -1;
        mCookie = SystemClock.elapsedRealtime();

        if (tagService == null) {
            return;
        }

        try {
            tagService.setTagUpToDate(mCookie);
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    /**
@@ -165,9 +157,10 @@ public final class Tag implements Parcelable {
     * @return freshly constructed tag
     * @hide
     */
    public static Tag createMockTag(byte[] id, int[] techList, Bundle[] techListExtras) {
    public static Tag createMockTag(byte[] id, int[] techList, Bundle[] techListExtras,
            long cookie) {
        // set serviceHandle to 0 and tagService to null to indicate mock tag
        return new Tag(id, techList, techListExtras, 0, null);
        return new Tag(id, techList, techListExtras, 0, cookie, null);
    }

    private String[] generateTechStringList(int[] techList) {
@@ -445,6 +438,7 @@ public final class Tag implements Parcelable {
        dest.writeIntArray(mTechList);
        dest.writeTypedArray(mTechExtras, 0);
        dest.writeInt(mServiceHandle);
        dest.writeLong(mCookie);
        dest.writeInt(isMock);
        if (isMock == 0) {
            dest.writeStrongBinder(mTagService.asBinder());
@@ -463,6 +457,7 @@ public final class Tag implements Parcelable {
            in.readIntArray(techList);
            Bundle[] techExtras = in.createTypedArray(Bundle.CREATOR);
            int serviceHandle = in.readInt();
            long cookie = in.readLong();
            int isMock = in.readInt();
            if (isMock == 0) {
                tagService = INfcTag.Stub.asInterface(in.readStrongBinder());
@@ -471,7 +466,7 @@ public final class Tag implements Parcelable {
                tagService = null;
            }

            return new Tag(id, techList, techExtras, serviceHandle, tagService);
            return new Tag(id, techList, techExtras, serviceHandle, cookie, tagService);
        }

        @Override