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

Commit 43c4ff6c authored by Omer Ozer's avatar Omer Ozer
Browse files

AIDL and java files for NfcAntenna Location Api.

Test: Manual test
Bug: 241447186
Change-Id: I32c51f4fc54624e5d2600bf2b146775f986eb8f0
parent 0b703be0
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -27354,6 +27354,15 @@ package android.net.vcn {
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 {
    ctor public FormatException();
    ctor public FormatException(String);
@@ -27415,6 +27424,7 @@ package android.nfc {
    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 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 @Deprecated public boolean invokeBeam(android.app.Activity);
    method public boolean isEnabled();
@@ -27477,6 +27487,17 @@ package android.nfc {
    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 {
    field public final android.nfc.NfcAdapter nfcAdapter;
    field public final int peerLlcpMajorVersion;
+19 −0
Original line number Diff line number Diff line
/*
 * 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 −0
Original line number Diff line number Diff line
/*
 * 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;
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.nfc.INfcFCardEmulation;
import android.nfc.INfcUnlockHandler;
import android.nfc.ITagRemovedCallback;
import android.nfc.INfcDta;
import android.nfc.NfcAntennaInfo;
import android.os.Bundle;

/**
@@ -72,6 +73,7 @@ interface INfcAdapter
    boolean isNfcSecureEnabled();
    boolean deviceSupportsNfcSecure();
    boolean setNfcSecure(boolean enable);
    NfcAntennaInfo getNfcAntennaInfo();

    boolean setControllerAlwaysOn(boolean value);
    boolean isControllerAlwaysOn();
+31 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.nfc;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
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.
     *
Loading