Moved TISBinder lifecycle handling to TISBinderHelper

- All instances where we used TISBinder will now use TISBinderHelper#getBinder. This will allow TISBinderHelper to handle its lifecycle
- Moved all instance of TaskbarManager and OverviewCommandHelper as well since TIS and TISBinder handle their lifecycles
- Cleaning up launcher instance from TaskbarManager when TISBinder is being destroyed

Flag: not needed
Bug: 283490010
Test: ran launcher and performed gestures
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:248794e698417b1156bf911adb31682186fe2e34)
Change-Id: I8415a6b2c1dba0776e7c0e1ee32ad3c683100bde
This commit is contained in:
Schneider Victor-tulias
2023-05-31 10:34:24 -07:00
parent 8d90ac04e3
commit 871d7fc351
6 changed files with 85 additions and 60 deletions

View File

@@ -29,6 +29,7 @@ import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentCallbacks;
import android.content.Context;
@@ -56,6 +57,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.taskbar.unfold.NonDestroyableScopedUnfoldTransitionProgressProvider;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.ActivityLifecycleCallbacksAdapter;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.NavigationMode;
import com.android.launcher3.util.SettingsCache;
@@ -144,6 +146,25 @@ public class TaskbarManager {
}
};
private final ActivityLifecycleCallbacksAdapter mLifecycleCallbacks =
new ActivityLifecycleCallbacksAdapter() {
@Override
public void onActivityDestroyed(Activity activity) {
if (mActivity != activity) return;
if (mActivity != null) {
mActivity.removeOnDeviceProfileChangeListener(
mDebugActivityDeviceProfileChanged);
mActivity.unregisterActivityLifecycleCallbacks(this);
}
mActivity = null;
debugWhyTaskbarNotDestroyed("clearActivity");
if (mTaskbarActivityContext != null) {
mTaskbarActivityContext.setUIController(TaskbarUIController.DEFAULT);
}
mUnfoldProgressProvider.setSourceProvider(null);
}
};
@SuppressLint("WrongConstant")
public TaskbarManager(TouchInteractionService service) {
mDisplayController = DisplayController.INSTANCE.get(service);
@@ -306,10 +327,12 @@ public class TaskbarManager {
}
if (mActivity != null) {
mActivity.removeOnDeviceProfileChangeListener(mDebugActivityDeviceProfileChanged);
mActivity.unregisterActivityLifecycleCallbacks(mLifecycleCallbacks);
}
mActivity = activity;
debugWhyTaskbarNotDestroyed("Set mActivity=" + mActivity);
mActivity.addOnDeviceProfileChangeListener(mDebugActivityDeviceProfileChanged);
mActivity.registerActivityLifecycleCallbacks(mLifecycleCallbacks);
UnfoldTransitionProgressProvider unfoldTransitionProgressProvider =
getUnfoldTransitionProgressProviderForActivity(activity);
mUnfoldProgressProvider.setSourceProvider(unfoldTransitionProgressProvider);
@@ -348,21 +371,6 @@ public class TaskbarManager {
return TaskbarUIController.DEFAULT;
}
/**
* Clears a previously set {@link StatefulActivity}
*/
public void clearActivity(@NonNull StatefulActivity activity) {
if (mActivity == activity) {
mActivity.removeOnDeviceProfileChangeListener(mDebugActivityDeviceProfileChanged);
mActivity = null;
debugWhyTaskbarNotDestroyed("clearActivity");
if (mTaskbarActivityContext != null) {
mTaskbarActivityContext.setUIController(TaskbarUIController.DEFAULT);
}
mUnfoldProgressProvider.setSourceProvider(null);
}
}
/**
* This method is called multiple times (ex. initial init, then when user unlocks) in which case
* we fully want to destroy an existing taskbar and create a new one.