Merge "AIDL and java files for NfcAntenna Location Api."
This commit is contained in:
@@ -27354,6 +27354,15 @@ package android.net.vcn {
|
|||||||
|
|
||||||
package android.nfc {
|
package android.nfc {
|
||||||
|
|
||||||
|
public final class AvailableNfcAntenna implements android.os.Parcelable {
|
||||||
|
ctor public AvailableNfcAntenna(int, int);
|
||||||
|
method public int describeContents();
|
||||||
|
method public int getLocationX();
|
||||||
|
method public int getLocationY();
|
||||||
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
|
field @NonNull public static final android.os.Parcelable.Creator<android.nfc.AvailableNfcAntenna> CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
public class FormatException extends java.lang.Exception {
|
public class FormatException extends java.lang.Exception {
|
||||||
ctor public FormatException();
|
ctor public FormatException();
|
||||||
ctor public FormatException(String);
|
ctor public FormatException(String);
|
||||||
@@ -27415,6 +27424,7 @@ package android.nfc {
|
|||||||
method @Deprecated public void enableForegroundNdefPush(android.app.Activity, android.nfc.NdefMessage);
|
method @Deprecated public void enableForegroundNdefPush(android.app.Activity, android.nfc.NdefMessage);
|
||||||
method public void enableReaderMode(android.app.Activity, android.nfc.NfcAdapter.ReaderCallback, int, android.os.Bundle);
|
method public void enableReaderMode(android.app.Activity, android.nfc.NfcAdapter.ReaderCallback, int, android.os.Bundle);
|
||||||
method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context);
|
method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context);
|
||||||
|
method @Nullable public android.nfc.NfcAntennaInfo getNfcAntennaInfo();
|
||||||
method public boolean ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler);
|
method public boolean ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler);
|
||||||
method @Deprecated public boolean invokeBeam(android.app.Activity);
|
method @Deprecated public boolean invokeBeam(android.app.Activity);
|
||||||
method public boolean isEnabled();
|
method public boolean isEnabled();
|
||||||
@@ -27477,6 +27487,17 @@ package android.nfc {
|
|||||||
method public void onTagDiscovered(android.nfc.Tag);
|
method public void onTagDiscovered(android.nfc.Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class NfcAntennaInfo implements android.os.Parcelable {
|
||||||
|
ctor public NfcAntennaInfo(int, int, boolean, @NonNull java.util.List<android.nfc.AvailableNfcAntenna>);
|
||||||
|
method public int describeContents();
|
||||||
|
method @NonNull public java.util.List<android.nfc.AvailableNfcAntenna> getAvailableNfcAntennas();
|
||||||
|
method public int getDeviceHeight();
|
||||||
|
method public int getDeviceWidth();
|
||||||
|
method public boolean isDeviceFoldable();
|
||||||
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
|
field @NonNull public static final android.os.Parcelable.Creator<android.nfc.NfcAntennaInfo> CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
public final class NfcEvent {
|
public final class NfcEvent {
|
||||||
field public final android.nfc.NfcAdapter nfcAdapter;
|
field public final android.nfc.NfcAdapter nfcAdapter;
|
||||||
field public final int peerLlcpMajorVersion;
|
field public final int peerLlcpMajorVersion;
|
||||||
|
|||||||
19
core/java/android/nfc/AvailableNfcAntenna.aidl
Normal file
19
core/java/android/nfc/AvailableNfcAntenna.aidl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.nfc;
|
||||||
|
|
||||||
|
parcelable AvailableNfcAntenna;
|
||||||
117
core/java/android/nfc/AvailableNfcAntenna.java
Normal file
117
core/java/android/nfc/AvailableNfcAntenna.java
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.nfc;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single available Nfc antenna
|
||||||
|
* on an Android device.
|
||||||
|
*/
|
||||||
|
public final class AvailableNfcAntenna implements Parcelable {
|
||||||
|
/**
|
||||||
|
* Location on the antenna on the Y axis in millimeters.
|
||||||
|
* 0 is the bottom-left when the user is facing the screen.
|
||||||
|
*/
|
||||||
|
private final int mLocationX;
|
||||||
|
/**
|
||||||
|
* Location on the antenna on the Y axis in millimeters.
|
||||||
|
* 0 is the bottom-left when the user is facing the screen.
|
||||||
|
*/
|
||||||
|
private final int mLocationY;
|
||||||
|
|
||||||
|
public AvailableNfcAntenna(int locationX, int locationY) {
|
||||||
|
this.mLocationX = locationX;
|
||||||
|
this.mLocationY = locationY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location on the antenna on the X axis in millimeters.
|
||||||
|
* 0 is the bottom-left when the user is facing the screen.
|
||||||
|
*/
|
||||||
|
public int getLocationX() {
|
||||||
|
return mLocationX;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location on the antenna on the Y axis in millimeters.
|
||||||
|
* 0 is the bottom-left when the user is facing the screen.
|
||||||
|
*/
|
||||||
|
public int getLocationY() {
|
||||||
|
return mLocationY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AvailableNfcAntenna(Parcel in) {
|
||||||
|
this.mLocationX = in.readInt();
|
||||||
|
this.mLocationY = in.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final @android.annotation.NonNull Parcelable.Creator<AvailableNfcAntenna>
|
||||||
|
CREATOR = new Parcelable.Creator<AvailableNfcAntenna>() {
|
||||||
|
@Override
|
||||||
|
public AvailableNfcAntenna createFromParcel(Parcel in) {
|
||||||
|
return new AvailableNfcAntenna(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AvailableNfcAntenna[] newArray(int size) {
|
||||||
|
return new AvailableNfcAntenna[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
|
dest.writeInt(mLocationX);
|
||||||
|
dest.writeInt(mLocationY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + mLocationX;
|
||||||
|
result = prime * result + mLocationY;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the specified AvailableNfcAntenna contains
|
||||||
|
* identical specifications.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null) return false;
|
||||||
|
if (getClass() != obj.getClass()) return false;
|
||||||
|
AvailableNfcAntenna other = (AvailableNfcAntenna) obj;
|
||||||
|
if (this.mLocationX != other.mLocationX) return false;
|
||||||
|
return this.mLocationY == other.mLocationY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "AvailableNfcAntenna " + "x: " + mLocationX + " y: " + mLocationY;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@ import android.nfc.INfcFCardEmulation;
|
|||||||
import android.nfc.INfcUnlockHandler;
|
import android.nfc.INfcUnlockHandler;
|
||||||
import android.nfc.ITagRemovedCallback;
|
import android.nfc.ITagRemovedCallback;
|
||||||
import android.nfc.INfcDta;
|
import android.nfc.INfcDta;
|
||||||
|
import android.nfc.NfcAntennaInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,6 +73,7 @@ interface INfcAdapter
|
|||||||
boolean isNfcSecureEnabled();
|
boolean isNfcSecureEnabled();
|
||||||
boolean deviceSupportsNfcSecure();
|
boolean deviceSupportsNfcSecure();
|
||||||
boolean setNfcSecure(boolean enable);
|
boolean setNfcSecure(boolean enable);
|
||||||
|
NfcAntennaInfo getNfcAntennaInfo();
|
||||||
|
|
||||||
boolean setControllerAlwaysOn(boolean value);
|
boolean setControllerAlwaysOn(boolean value);
|
||||||
boolean isControllerAlwaysOn();
|
boolean isControllerAlwaysOn();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.nfc;
|
|||||||
|
|
||||||
import android.annotation.CallbackExecutor;
|
import android.annotation.CallbackExecutor;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.SdkConstant;
|
import android.annotation.SdkConstant;
|
||||||
import android.annotation.SdkConstant.SdkConstantType;
|
import android.annotation.SdkConstant.SdkConstantType;
|
||||||
@@ -1853,6 +1854,36 @@ public final class NfcAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information regarding Nfc antennas on the device
|
||||||
|
* such as their relative positioning on the device.
|
||||||
|
*
|
||||||
|
* @return Information on the nfc antenna(s) on the device.
|
||||||
|
* @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public NfcAntennaInfo getNfcAntennaInfo() {
|
||||||
|
if (!sHasNfcFeature) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return sService.getNfcAntennaInfo();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
attemptDeadServiceRecovery(e);
|
||||||
|
// Try one more time
|
||||||
|
if (sService == null) {
|
||||||
|
Log.e(TAG, "Failed to recover NFC Service.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return sService.getNfcAntennaInfo();
|
||||||
|
} catch (RemoteException ee) {
|
||||||
|
Log.e(TAG, "Failed to recover NFC Service.");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks Secure NFC feature is enabled.
|
* Checks Secure NFC feature is enabled.
|
||||||
*
|
*
|
||||||
|
|||||||
19
core/java/android/nfc/NfcAntennaInfo.aidl
Normal file
19
core/java/android/nfc/NfcAntennaInfo.aidl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.nfc;
|
||||||
|
|
||||||
|
parcelable NfcAntennaInfo;
|
||||||
117
core/java/android/nfc/NfcAntennaInfo.java
Normal file
117
core/java/android/nfc/NfcAntennaInfo.java
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.nfc;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains information on all available Nfc
|
||||||
|
* antennas on an Android device as well as information
|
||||||
|
* on the device itself in relation positioning of the
|
||||||
|
* antennas.
|
||||||
|
*/
|
||||||
|
public final class NfcAntennaInfo implements Parcelable {
|
||||||
|
// Width of the device in millimeters.
|
||||||
|
private final int mDeviceWidth;
|
||||||
|
// Height of the device in millimeters.
|
||||||
|
private final int mDeviceHeight;
|
||||||
|
// Whether the device is foldable.
|
||||||
|
private final boolean mDeviceFoldable;
|
||||||
|
// All available Nfc Antennas on the device.
|
||||||
|
private final List<AvailableNfcAntenna> mAvailableNfcAntennas;
|
||||||
|
|
||||||
|
public NfcAntennaInfo(int deviceWidth, int deviceHeight, boolean deviceFoldable,
|
||||||
|
@NonNull List<AvailableNfcAntenna> availableNfcAntennas) {
|
||||||
|
this.mDeviceWidth = deviceWidth;
|
||||||
|
this.mDeviceHeight = deviceHeight;
|
||||||
|
this.mDeviceFoldable = deviceFoldable;
|
||||||
|
this.mAvailableNfcAntennas = availableNfcAntennas;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Width of the device in millimeters.
|
||||||
|
*/
|
||||||
|
public int getDeviceWidth() {
|
||||||
|
return mDeviceWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Height of the device in millimeters.
|
||||||
|
*/
|
||||||
|
public int getDeviceHeight() {
|
||||||
|
return mDeviceHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the device is foldable. When the device is foldable,
|
||||||
|
* the 0, 0 is considered to be bottom-left when the device is unfolded and
|
||||||
|
* the screens are facing the user. For non-foldable devices 0, 0
|
||||||
|
* is bottom-left when the user is facing the screen.
|
||||||
|
*/
|
||||||
|
public boolean isDeviceFoldable() {
|
||||||
|
return mDeviceFoldable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all NFC antennas that exist on the device.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public List<AvailableNfcAntenna> getAvailableNfcAntennas() {
|
||||||
|
return mAvailableNfcAntennas;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NfcAntennaInfo(Parcel in) {
|
||||||
|
this.mDeviceWidth = in.readInt();
|
||||||
|
this.mDeviceHeight = in.readInt();
|
||||||
|
this.mDeviceFoldable = in.readByte() != 0;
|
||||||
|
this.mAvailableNfcAntennas = new ArrayList<>();
|
||||||
|
in.readParcelableList(this.mAvailableNfcAntennas,
|
||||||
|
AvailableNfcAntenna.class.getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final @NonNull Parcelable.Creator<NfcAntennaInfo> CREATOR =
|
||||||
|
new Parcelable.Creator<NfcAntennaInfo>() {
|
||||||
|
@Override
|
||||||
|
public NfcAntennaInfo createFromParcel(Parcel in) {
|
||||||
|
return new NfcAntennaInfo(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NfcAntennaInfo[] newArray(int size) {
|
||||||
|
return new NfcAntennaInfo[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
|
dest.writeInt(mDeviceWidth);
|
||||||
|
dest.writeInt(mDeviceHeight);
|
||||||
|
dest.writeByte((byte) (mDeviceFoldable ? 1 : 0));
|
||||||
|
dest.writeTypedList(mAvailableNfcAntennas, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user