Merge "Spatializer: Fix lost settings after reboot" into tm-qpr-dev am: a22527d9fa am: 37a9a02102

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19374229

Change-Id: I12b678cd6913cecfcf0a310fecf49312d064740a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Andy Hung
2022-07-21 17:40:42 +00:00
committed by Automerger Merge Worker
2 changed files with 11 additions and 7 deletions

View File

@@ -9185,11 +9185,8 @@ public class AudioService extends IAudioService.Stub
Settings.Secure.SPATIAL_AUDIO_ENABLED, UserHandle.USER_CURRENT);
if (settings == null) {
Log.e(TAG, "error reading spatial audio device settings");
} else {
Log.v(TAG, "restoring spatial audio device settings: " + settings);
mSpatializerHelper.setSADeviceSettings(settings);
}
mSpatializerHelper.init(/*effectExpected*/ mHasSpatializerEffect);
mSpatializerHelper.init(/*effectExpected*/ mHasSpatializerEffect, settings);
mSpatializerHelper.setFeatureEnabled(mHasSpatializerEffect);
}

View File

@@ -175,7 +175,7 @@ public class SpatializerHelper {
mASA = asa;
}
synchronized void init(boolean effectExpected) {
synchronized void init(boolean effectExpected, @Nullable String settings) {
loglogi("init effectExpected=" + effectExpected);
if (!effectExpected) {
loglogi("init(): setting state to STATE_NOT_SUPPORTED due to effect not expected");
@@ -278,6 +278,13 @@ public class SpatializerHelper {
mSACapableDeviceTypes.add(SPAT_MODE_FOR_DEVICE_TYPE.keyAt(i));
}
}
// When initialized from AudioService, the settings string will be non-null.
// Saved settings need to be applied after spatialization support is initialized above.
if (settings != null) {
setSADeviceSettings(settings);
}
// for both transaural / binaural, we are not forcing enablement as the init() method
// could have been called another time after boot in case of audioserver restart
addCompatibleAudioDevice(
@@ -316,7 +323,7 @@ public class SpatializerHelper {
mState = STATE_UNINITIALIZED;
mSpatLevel = Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_NONE;
mActualHeadTrackingMode = Spatializer.HEAD_TRACKING_MODE_UNSUPPORTED;
init(true);
init(true, null /* settings */);
setSpatializerEnabledInt(featureEnabled);
}
@@ -731,7 +738,7 @@ public class SpatializerHelper {
return;
}
if (mState == STATE_UNINITIALIZED) {
init(true);
init(true, null /* settings */);
}
setSpatializerEnabledInt(true);
} else {