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

Commit 7cc283ab authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use PollingFrame class instead of Bundles to represent polling frames...

Merge "Use PollingFrame class instead of Bundles to represent polling frames in NFC stack" into main
parents 7a53f2da d65fbe17
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.nfc.INfcDta;
import android.nfc.INfcWlcStateListener;
import android.nfc.NfcAntennaInfo;
import android.nfc.WlcListenerDeviceInfo;
import android.nfc.cardemulation.PollingFrame;
import android.os.Bundle;

/**
@@ -101,7 +102,7 @@ interface INfcAdapter

    void updateDiscoveryTechnology(IBinder b, int pollFlags, int listenFlags);

    void notifyPollingLoop(in Bundle frame);
    void notifyPollingLoop(in PollingFrame frame);
    void notifyHceDeactivated();
    int sendVendorNciMessage(int mt, int gid, int oid, in byte[] payload);
    void registerVendorExtensionCallback(in INfcVendorNciCallback callbacks);
+2 −3
Original line number Diff line number Diff line
@@ -2803,12 +2803,11 @@ public final class NfcAdapter {
    @TestApi
    @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
    public void notifyPollingLoop(@NonNull PollingFrame pollingFrame) {
        Bundle frame = pollingFrame.toBundle();
        try {
            if (sService == null) {
                attemptDeadServiceRecovery(null);
            }
            sService.notifyPollingLoop(frame);
            sService.notifyPollingLoop(pollingFrame);
        } catch (RemoteException e) {
            attemptDeadServiceRecovery(e);
            // Try one more time
@@ -2817,7 +2816,7 @@ public final class NfcAdapter {
                return;
            }
            try {
                sService.notifyPollingLoop(frame);
                sService.notifyPollingLoop(pollingFrame);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to recover NFC Service.");
            }
+5 −8
Original line number Diff line number Diff line
@@ -325,15 +325,12 @@ public abstract class HostApduService extends Service {
                }
                break;
                case MSG_POLLING_LOOP:
                    ArrayList<Bundle> frames =
                            msg.getData().getParcelableArrayList(KEY_POLLING_LOOP_FRAMES_BUNDLE,
                            Bundle.class);
                    if (android.nfc.Flags.nfcReadPollingLoop()) {
                        ArrayList<PollingFrame> pollingFrames =
                            new ArrayList<PollingFrame>(frames.size());
                    for (Bundle frame : frames) {
                        pollingFrames.add(new PollingFrame(frame));
                    }
                                msg.getData().getParcelableArrayList(
                                    KEY_POLLING_LOOP_FRAMES_BUNDLE, PollingFrame.class);
                        processPollingFrames(pollingFrames);
                    }
                    break;
            default:
                super.handleMessage(msg);
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.cardemulation;

parcelable PollingFrame;
 No newline at end of file
+18 −23
Original line number Diff line number Diff line
@@ -101,47 +101,37 @@ public final class PollingFrame implements Parcelable{
    /**
     * KEY_POLLING_LOOP_TYPE is the Bundle key for the type of
     * polling loop frame in the Bundle included in MSG_POLLING_LOOP.
     *
     * @hide
     */
    @FlaggedApi(android.nfc.Flags.FLAG_NFC_READ_POLLING_LOOP)
    public static final String KEY_POLLING_LOOP_TYPE = "android.nfc.cardemulation.TYPE";
    private static final String KEY_POLLING_LOOP_TYPE = "android.nfc.cardemulation.TYPE";

    /**
     * KEY_POLLING_LOOP_DATA is the Bundle key for the raw data of captured from
     * the polling loop frame in the Bundle included in MSG_POLLING_LOOP.
     *
     * @hide
     */
    @FlaggedApi(android.nfc.Flags.FLAG_NFC_READ_POLLING_LOOP)
    public static final String KEY_POLLING_LOOP_DATA = "android.nfc.cardemulation.DATA";
    private static final String KEY_POLLING_LOOP_DATA = "android.nfc.cardemulation.DATA";

    /**
     * KEY_POLLING_LOOP_GAIN is the Bundle key for the field strength of
     * the polling loop frame in the Bundle included in MSG_POLLING_LOOP.
     *
     * @hide
    */
    @FlaggedApi(android.nfc.Flags.FLAG_NFC_READ_POLLING_LOOP)
    public static final String KEY_POLLING_LOOP_GAIN = "android.nfc.cardemulation.GAIN";
    private static final String KEY_POLLING_LOOP_GAIN = "android.nfc.cardemulation.GAIN";

    /**
     * KEY_POLLING_LOOP_TIMESTAMP is the Bundle key for the timestamp of
     * the polling loop frame in the Bundle included in MSG_POLLING_LOOP.
     *
     * @hide
    */
    @FlaggedApi(android.nfc.Flags.FLAG_NFC_READ_POLLING_LOOP)
    public static final String KEY_POLLING_LOOP_TIMESTAMP = "android.nfc.cardemulation.TIMESTAMP";
    private static final String KEY_POLLING_LOOP_TIMESTAMP = "android.nfc.cardemulation.TIMESTAMP";

    /**
     * KEY_POLLING_LOOP_TIMESTAMP is the Bundle key for whether this polling frame triggered
     * autoTransact in the Bundle included in MSG_POLLING_LOOP.
     *
     * @hide
    */
    @FlaggedApi(android.nfc.Flags.FLAG_NFC_READ_POLLING_LOOP)
    public static final String KEY_POLLING_LOOP_TRIGGERED_AUTOTRANSACT =
    private static final String KEY_POLLING_LOOP_TRIGGERED_AUTOTRANSACT =
            "android.nfc.cardemulation.TRIGGERED_AUTOTRANSACT";


@@ -151,7 +141,7 @@ public final class PollingFrame implements Parcelable{
    private final int mGain;
    @DurationMillisLong
    private final long mTimestamp;
    private final boolean mTriggeredAutoTransact;
    private boolean mTriggeredAutoTransact;

    public static final @NonNull Parcelable.Creator<PollingFrame> CREATOR =
            new Parcelable.Creator<>() {
@@ -166,7 +156,7 @@ public final class PollingFrame implements Parcelable{
                }
            };

    PollingFrame(Bundle frame) {
    private PollingFrame(Bundle frame) {
        mType = frame.getInt(KEY_POLLING_LOOP_TYPE);
        byte[] data = frame.getByteArray(KEY_POLLING_LOOP_DATA);
        mData = (data == null) ? new byte[0] : data;
@@ -238,6 +228,13 @@ public final class PollingFrame implements Parcelable{
        return mTimestamp;
    }

    /**
     * @hide
     */
    public void setTriggeredAutoTransact(boolean triggeredAutoTransact) {
        mTriggeredAutoTransact = triggeredAutoTransact;
    }

    /**
     * Returns whether this frame triggered the device to automatically disable observe mode and
     * allow one transaction.
@@ -257,11 +254,9 @@ public final class PollingFrame implements Parcelable{
    }

    /**
     *
     * @hide
     * @return a Bundle representing this frame
     */
    public Bundle toBundle() {
    private Bundle toBundle() {
        Bundle frame = new Bundle();
        frame.putInt(KEY_POLLING_LOOP_TYPE, getType());
        if (getVendorSpecificGain() != -1) {