Fix AudioMix.equals()

Use Object.equals() when comparing Objects instead of '=='

Test: Added unit tests (see topic).  Verified that test failed before changes and passed afterwards.
Change-Id: I12d8cb24207c64b96d2fe65d4b2045873b080bc3
Merged-In: I12d8cb24207c64b96d2fe65d4b2045873b080bc3
This commit is contained in:
Alex Leung
2023-03-08 19:42:51 -08:00
committed by Eric Laurent
parent f4df7dd3e1
commit 46456d7af4

View File

@@ -25,6 +25,8 @@ import android.media.AudioFormat;
import android.media.AudioSystem;
import android.os.Build;
import com.android.internal.annotations.VisibleForTesting;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
@@ -252,10 +254,10 @@ public class AudioMix {
if (o == null || getClass() != o.getClass()) return false;
final AudioMix that = (AudioMix) o;
return (this.mRouteFlags == that.mRouteFlags)
&& (this.mRule == that.mRule)
&& (this.mMixType == that.mMixType)
&& (this.mFormat == that.mFormat);
return Objects.equals(this.mRouteFlags, that.mRouteFlags)
&& Objects.equals(this.mRule, that.mRule)
&& Objects.equals(this.mMixType, that.mMixType)
&& Objects.equals(this.mFormat, that.mFormat);
}
/** @hide */
@@ -340,7 +342,8 @@ public class AudioMix {
* @param address
* @return the same Builder instance.
*/
Builder setDevice(int deviceType, String address) {
@VisibleForTesting
public Builder setDevice(int deviceType, String address) {
mDeviceSystemType = deviceType;
mDeviceAddress = address;
return this;