Merge "Assign the nonce from NfcService while contructing a Tag object" into tm-qpr-dev
This commit is contained in:
@@ -46,6 +46,5 @@ interface INfcTag
|
||||
int getMaxTransceiveLength(int technology);
|
||||
boolean getExtendedLengthApdusSupported();
|
||||
|
||||
void setTagUpToDate(long cookie);
|
||||
boolean isTagUpToDate(long cookie);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user