diff options
| author | 2023-03-10 21:53:40 +0000 | |
|---|---|---|
| committer | 2023-03-16 16:08:44 +0000 | |
| commit | 76536d72f674dc8acd0c7b9c0f093b5d197fbffb (patch) | |
| tree | 0ff622bca7b2d46897bf1fd871657697733f2ace | |
| parent | 10be070b98124b7681e95a3c43bf830367990428 (diff) | |
ViewRootImpl: lazy initialization of mFastScrollSoundEffectsEnabled
mFastScrollSoundEffectsEnabled was initialized in the constructor
from a used-once instance of AudioManager.
Move initialization of this varialble to a lazy-initialization
where mAudioManager is also lazy-initialized, getAudioManager(),
which is only ever called in playSoundEffect(int), which reads
mFastScrollSoundEffectsEnabled.
Bug: 272459959
Bug: 266370934
Test: see steps in bug
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:a5ba10f05931bba7be80e2484ed3889b04764c62)
Merged-In: Ib0bd59288197c05b13b9cb8a69d79960338c3c18
Change-Id: Ib0bd59288197c05b13b9cb8a69d79960338c3c18
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index fb25e7a6bfe1..2be6b9ae26bc 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -417,7 +417,8 @@ public final class ViewRootImpl implements ViewParent, private boolean mUseBLASTAdapter; private boolean mForceDisableBLAST; - private boolean mFastScrollSoundEffectsEnabled; + /** lazily-initialized in getAudioManager() */ + private boolean mFastScrollSoundEffectsEnabled = false; /** * Signals that compatibility booleans have been initialized according to @@ -1028,8 +1029,6 @@ public final class ViewRootImpl implements ViewParent, loadSystemProperties(); mImeFocusController = new ImeFocusController(this); - AudioManager audioManager = mContext.getSystemService(AudioManager.class); - mFastScrollSoundEffectsEnabled = audioManager.areNavigationRepeatSoundEffectsEnabled(); mScrollCaptureRequestTimeout = SCROLL_CAPTURE_REQUEST_TIMEOUT_MILLIS; mOnBackInvokedDispatcher = new WindowOnBackInvokedDispatcher(context); @@ -8340,6 +8339,7 @@ public final class ViewRootImpl implements ViewParent, } if (mAudioManager == null) { mAudioManager = (AudioManager) mView.getContext().getSystemService(Context.AUDIO_SERVICE); + mFastScrollSoundEffectsEnabled = mAudioManager.areNavigationRepeatSoundEffectsEnabled(); } return mAudioManager; } |