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

Commit ea76da3a authored by Roshan Pius's avatar Roshan Pius Committed by Android (Google) Code Review
Browse files

Merge "nfc(api): Address API council feedback for setReaderMode" into main

parents 8a703f20 af9cc1f7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ package android.nfc {
    method @FlaggedApi("android.nfc.enable_nfc_charging") public void registerWlcStateListener(@NonNull java.util.concurrent.Executor, @NonNull android.nfc.NfcAdapter.WlcStateListener);
    method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean removeNfcUnlockHandler(android.nfc.NfcAdapter.NfcUnlockHandler);
    method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean setControllerAlwaysOn(boolean);
    method @FlaggedApi("android.nfc.enable_nfc_mainline") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setReaderMode(boolean);
    method @FlaggedApi("android.nfc.enable_nfc_mainline") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setReaderModePollingEnabled(boolean);
    method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int setTagIntentAppPreferenceForUser(int, @NonNull String, boolean);
    method @FlaggedApi("android.nfc.enable_nfc_charging") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean setWlcEnabled(boolean);
    method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public void unregisterControllerAlwaysOnListener(@NonNull android.nfc.NfcAdapter.ControllerAlwaysOnListener);
+5 −3
Original line number Diff line number Diff line
@@ -1764,7 +1764,9 @@ public final class NfcAdapter {
    private static final int ENABLE_POLLING_FLAGS = 0x0000;

    /**
     * Privileged API to enable disable reader polling.
     * Privileged API to enable or disable reader polling.
     * Unlike {@link #enableReaderMode(Activity, ReaderCallback, int, Bundle)}, this API does not
     * need a foreground activity to control reader mode parameters
     * Note: Use with caution! The app is responsible for ensuring that the polling state is
     * returned to normal.
     *
@@ -1778,14 +1780,14 @@ public final class NfcAdapter {
    @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
    @FlaggedApi(Flags.FLAG_ENABLE_NFC_MAINLINE)
    @SuppressLint("VisiblySynchronized")
    public void setReaderMode(boolean enablePolling) {
    public void setReaderModePollingEnabled(boolean enable) {
        synchronized (sLock) {
            if (!sHasNfcFeature) {
                throw new UnsupportedOperationException();
            }
        }
        Binder token = new Binder();
        int flags = enablePolling ? ENABLE_POLLING_FLAGS : DISABLE_POLLING_FLAGS;
        int flags = enable ? ENABLE_POLLING_FLAGS : DISABLE_POLLING_FLAGS;
        try {
            NfcAdapter.sService.setReaderMode(token, null, flags, null);
        } catch (RemoteException e) {
+1 −1
Original line number Diff line number Diff line
@@ -1292,7 +1292,7 @@ public class CameraServiceProxy extends SystemService
            return;
        }
        if (DEBUG) Slog.v(TAG, "Setting NFC reader mode. enablePolling: " + enablePolling);
        nfcAdapter.setReaderMode(enablePolling);
        nfcAdapter.setReaderModePollingEnabled(enablePolling);
    }

    private static int[] toArray(Collection<Integer> c) {