[Taskbar] Fix leaked thread "TaskbarUiThread" that is not destroyed upon taskbar recreation.

We use to create a "TaskbarUiThread" for each new taskbar context but forget to destroy the thread.

We fix it by creating a static thread named as "TASKBAR_UI_THREAD"

Fix: TBD
Flag: com.android.launcher3.enable_taskbar_ui_thread
Test: manual
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:66e79baa21573579802ceb7e283c5bb5954a4365)
Merged-In: Idd54c76c39b32a2765c64da1e519c9faa79dac75
Change-Id: Idd54c76c39b32a2765c64da1e519c9faa79dac75
This commit is contained in:
Fengjiang Li authored and Android Build Coastguard Worker committed 2025-07-07 20:32:20 -07:00
1 parent 53ef8c19a2
commit eb62f2825f
1 file changed
+4 -4
@@ -159,6 +159,9 @@ public class TaskbarManagerImpl implements DisplayDecorationListener {
private static final Uri NAV_BAR_KIDS_MODE = Settings.Secure.getUriFor(
Settings.Secure.NAV_BAR_KIDS_MODE);
private static final LooperExecutor TASKBAR_UI_THREAD =
new LooperExecutor("TASKBAR_UI_THREAD", THREAD_PRIORITY_FOREGROUND);
private final Context mBaseContext;
private final int mPrimaryDisplayId;
private final TaskbarNavButtonCallbacks mNavCallbacks;
@@ -172,9 +175,6 @@ public class TaskbarManagerImpl implements DisplayDecorationListener {
private final SimpleBroadcastReceiver mShutdownReceiver;
private final DisplaysWithDecorationsRepositoryCompat mDisplaysWithDecorationsRepositoryCompat;
private final LooperExecutor mPerWindowUiExecutor =
new LooperExecutor("TaskbarUiThread", THREAD_PRIORITY_FOREGROUND);
// The source for this provider is set when Launcher is available
// We use 'non-destroyable' version here so the original provider won't be destroyed
// as it is tied to the activity lifecycle, not the taskbar lifecycle.
@@ -538,7 +538,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener {
}
public LooperExecutor getPerWindowUiExecutor() {
return mPerWindowUiExecutor;
return TASKBAR_UI_THREAD;
}
private void handleDisplayUpdatesForPerceptibleTasks() {