Merge "SpatializerHelper: Add properties for enable defaults" am: 0e16d2d831
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2501115 Change-Id: Ib442b8b0eed9def5583180b3c947d0f03069f5ed Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1014,9 +1014,14 @@ public class AudioService extends IAudioService.Stub
|
|||||||
|
|
||||||
mSfxHelper = new SoundEffectsHelper(mContext, playerBase -> ignorePlayerLogs(playerBase));
|
mSfxHelper = new SoundEffectsHelper(mContext, playerBase -> ignorePlayerLogs(playerBase));
|
||||||
|
|
||||||
final boolean headTrackingDefault = mContext.getResources().getBoolean(
|
final boolean binauralEnabledDefault = SystemProperties.getBoolean(
|
||||||
|
"ro.audio.spatializer_binaural_enabled_default", true);
|
||||||
|
final boolean transauralEnabledDefault = SystemProperties.getBoolean(
|
||||||
|
"ro.audio.spatializer_transaural_enabled_default", true);
|
||||||
|
final boolean headTrackingEnabledDefault = mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_spatial_audio_head_tracking_enabled_default);
|
com.android.internal.R.bool.config_spatial_audio_head_tracking_enabled_default);
|
||||||
mSpatializerHelper = new SpatializerHelper(this, mAudioSystem, headTrackingDefault);
|
mSpatializerHelper = new SpatializerHelper(this, mAudioSystem,
|
||||||
|
binauralEnabledDefault, transauralEnabledDefault, headTrackingEnabledDefault);
|
||||||
|
|
||||||
mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
mHasVibrator = mVibrator == null ? false : mVibrator.hasVibrator();
|
mHasVibrator = mVibrator == null ? false : mVibrator.hasVibrator();
|
||||||
|
|||||||
@@ -171,13 +171,17 @@ public class SpatializerHelper {
|
|||||||
// initialization
|
// initialization
|
||||||
@SuppressWarnings("StaticAssignmentInConstructor")
|
@SuppressWarnings("StaticAssignmentInConstructor")
|
||||||
SpatializerHelper(@NonNull AudioService mother, @NonNull AudioSystemAdapter asa,
|
SpatializerHelper(@NonNull AudioService mother, @NonNull AudioSystemAdapter asa,
|
||||||
boolean headTrackingEnabledByDefault) {
|
boolean binauralEnabledDefault,
|
||||||
|
boolean transauralEnabledDefault,
|
||||||
|
boolean headTrackingEnabledDefault) {
|
||||||
mAudioService = mother;
|
mAudioService = mother;
|
||||||
mASA = asa;
|
mASA = asa;
|
||||||
// "StaticAssignmentInConstructor" warning is suppressed as the SpatializerHelper being
|
// "StaticAssignmentInConstructor" warning is suppressed as the SpatializerHelper being
|
||||||
// constructed here is the factory for SADeviceState, thus SADeviceState and its
|
// constructed here is the factory for SADeviceState, thus SADeviceState and its
|
||||||
// private static field sHeadTrackingEnabledDefault should never be accessed directly.
|
// private static field sHeadTrackingEnabledDefault should never be accessed directly.
|
||||||
SADeviceState.sHeadTrackingEnabledDefault = headTrackingEnabledByDefault;
|
SADeviceState.sBinauralEnabledDefault = binauralEnabledDefault;
|
||||||
|
SADeviceState.sTransauralEnabledDefault = transauralEnabledDefault;
|
||||||
|
SADeviceState.sHeadTrackingEnabledDefault = headTrackingEnabledDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void initForTest(boolean hasBinaural, boolean hasTransaural) {
|
synchronized void initForTest(boolean hasBinaural, boolean hasTransaural) {
|
||||||
@@ -1539,10 +1543,12 @@ public class SpatializerHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ static final class SADeviceState {
|
/*package*/ static final class SADeviceState {
|
||||||
|
private static boolean sBinauralEnabledDefault = true;
|
||||||
|
private static boolean sTransauralEnabledDefault = true;
|
||||||
private static boolean sHeadTrackingEnabledDefault = false;
|
private static boolean sHeadTrackingEnabledDefault = false;
|
||||||
final @AudioDeviceInfo.AudioDeviceType int mDeviceType;
|
final @AudioDeviceInfo.AudioDeviceType int mDeviceType;
|
||||||
final @NonNull String mDeviceAddress;
|
final @NonNull String mDeviceAddress;
|
||||||
boolean mEnabled = true; // by default, SA is enabled on any device
|
boolean mEnabled;
|
||||||
boolean mHasHeadTracker = false;
|
boolean mHasHeadTracker = false;
|
||||||
boolean mHeadTrackerEnabled;
|
boolean mHeadTrackerEnabled;
|
||||||
static final String SETTING_FIELD_SEPARATOR = ",";
|
static final String SETTING_FIELD_SEPARATOR = ",";
|
||||||
@@ -1558,6 +1564,12 @@ public class SpatializerHelper {
|
|||||||
SADeviceState(@AudioDeviceInfo.AudioDeviceType int deviceType, @Nullable String address) {
|
SADeviceState(@AudioDeviceInfo.AudioDeviceType int deviceType, @Nullable String address) {
|
||||||
mDeviceType = deviceType;
|
mDeviceType = deviceType;
|
||||||
mDeviceAddress = isWireless(deviceType) ? Objects.requireNonNull(address) : "";
|
mDeviceAddress = isWireless(deviceType) ? Objects.requireNonNull(address) : "";
|
||||||
|
final int spatMode = SPAT_MODE_FOR_DEVICE_TYPE.get(deviceType, Integer.MIN_VALUE);
|
||||||
|
mEnabled = spatMode == SpatializationMode.SPATIALIZER_BINAURAL
|
||||||
|
? sBinauralEnabledDefault
|
||||||
|
: spatMode == SpatializationMode.SPATIALIZER_TRANSAURAL
|
||||||
|
? sTransauralEnabledDefault
|
||||||
|
: false;
|
||||||
mHeadTrackerEnabled = sHeadTrackingEnabledDefault;
|
mHeadTrackerEnabled = sHeadTrackingEnabledDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,9 @@ public class SpatializerHelperTest {
|
|||||||
mSpyAudioSystem = spy(new NoOpAudioSystemAdapter());
|
mSpyAudioSystem = spy(new NoOpAudioSystemAdapter());
|
||||||
|
|
||||||
mSpatHelper = new SpatializerHelper(mMockAudioService, mSpyAudioSystem,
|
mSpatHelper = new SpatializerHelper(mMockAudioService, mSpyAudioSystem,
|
||||||
false /*headTrackingEnabledByDefault*/);
|
true /*binauralEnabledDefault*/,
|
||||||
|
true /*transauralEnabledDefault*/,
|
||||||
|
false /*headTrackingEnabledDefault*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user