From 54d06ff61ab5f4c574296dc78163aa2be8ca411f Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 10 Dec 2024 22:29:30 +0000 Subject: [PATCH] Add onUnbind from OverviewProxyService, and destroy taskbar When unbound, destroy taskbar immediately instead of waiting for TIS#onDestroy. And then send the reply back to OverviewProxyService so it can bind to a new TIS. Fixes: 375315062 Test: Switch users 10 times, no crash (also check logs) Flag: EXEMPT bug fix Change-Id: I737c47c7df87e11608672a4e16eb3e9fd645e487 --- .../quickstep/TouchInteractionService.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index a06029b013..4ed5d5a413 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -47,7 +47,9 @@ import android.content.res.Configuration; import android.graphics.Region; import android.os.Bundle; import android.os.IBinder; +import android.os.IRemoteCallback; import android.os.Looper; +import android.os.RemoteException; import android.os.SystemClock; import android.os.Trace; import android.util.Log; @@ -396,6 +398,20 @@ public class TouchInteractionService extends Service { taskbarManager.onNavigationBarLumaSamplingEnabled(displayId, enable)); } + @Override + public void onUnbind(IRemoteCallback reply) { + // Run everything in the same main thread block to ensure the cleanup happens before + // sending the reply. + MAIN_EXECUTOR.execute(() -> { + executeForTaskbarManager(TaskbarManager::destroy); + try { + reply.sendResult(null); + } catch (RemoteException e) { + Log.w(TAG, "onUnbind: Failed to reply to OverviewProxyService", e); + } + }); + } + private void executeForTouchInteractionService( @NonNull Consumer tisConsumer) { TouchInteractionService tis = mTis.get();