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

Commit 54efee93 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Visualizer: mark listerner arguments as @Nullable

The implementation and docs allow passing a null listener,
and absence of @Nullable annotation confuses static checkers.

Bug: 194286307
Test: m
Change-Id: I8610c328c3a26fe8bad08f921453b851a74449ee
parent 1909a429
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24311,7 +24311,7 @@ package android.media.audiofx {
    method public int getWaveForm(byte[]) throws java.lang.IllegalStateException;
    method public void release();
    method public int setCaptureSize(int) throws java.lang.IllegalStateException;
    method public int setDataCaptureListener(android.media.audiofx.Visualizer.OnDataCaptureListener, int, boolean, boolean);
    method public int setDataCaptureListener(@Nullable android.media.audiofx.Visualizer.OnDataCaptureListener, int, boolean, boolean);
    method public int setEnabled(boolean) throws java.lang.IllegalStateException;
    method public int setMeasurementMode(int) throws java.lang.IllegalStateException;
    method public int setScalingMode(int) throws java.lang.IllegalStateException;
+6 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.media.audiofx;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.AttributionSource;
import android.content.AttributionSource.ScopedParcelState;
@@ -183,17 +184,17 @@ public class Visualizer {
     * Handler for events coming from the native code
     */
    @GuardedBy("mListenerLock")
    private Handler mNativeEventHandler = null;
    @Nullable private Handler mNativeEventHandler = null;
    /**
     *  PCM and FFT capture listener registered by client
     */
    @GuardedBy("mListenerLock")
    private OnDataCaptureListener mCaptureListener = null;
    @Nullable private OnDataCaptureListener mCaptureListener = null;
    /**
     *  Server Died listener registered by client
     */
    @GuardedBy("mListenerLock")
    private OnServerDiedListener mServerDiedListener = null;
    @Nullable private OnServerDiedListener mServerDiedListener = null;

    // accessed by native methods
    private long mNativeVisualizer;  // guarded by a static lock in native code
@@ -618,7 +619,7 @@ public class Visualizer {
     * @return {@link #SUCCESS} in case of success,
     * {@link #ERROR_NO_INIT} or {@link #ERROR_BAD_VALUE} in case of failure.
     */
    public int setDataCaptureListener(OnDataCaptureListener listener,
    public int setDataCaptureListener(@Nullable OnDataCaptureListener listener,
            int rate, boolean waveform, boolean fft) {
        if (listener == null) {
            // make sure capture callback is stopped in native code
@@ -678,7 +679,7 @@ public class Visualizer {
     * <p>Call this method with a null listener to stop receiving server death notifications.
     * @return {@link #SUCCESS} in case of success,
     */
    public int setServerDiedListener(OnServerDiedListener listener) {
    public int setServerDiedListener(@Nullable OnServerDiedListener listener) {
        synchronized (mListenerLock) {
            mServerDiedListener = listener;
        }