Fixing out of order taskbar callbacks

OnCreate can come before onDestroy for a previous activity which can
cause the callbacks for taskbar to get cleared

Bug: 190170303
Test: Presubmit
Change-Id: I48334605384d4604043a50ffc3d137f84575148a
This commit is contained in:
Sunny Goyal
2021-06-18 12:41:22 -07:00
parent 485796e814
commit 6e1ce8ccb8
3 changed files with 19 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ import android.content.Context;
import android.hardware.display.DisplayManager;
import android.view.Display;
import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.DeviceProfile;
@@ -103,14 +103,25 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen
}
/**
* Sets or clears a launcher to act as taskbar callback
* Sets a launcher to act as taskbar callback
*/
public void setLauncher(@Nullable BaseQuickstepLauncher launcher) {
public void setLauncher(@NonNull BaseQuickstepLauncher launcher) {
mLauncher = launcher;
if (mTaskbarActivityContext != null) {
mTaskbarActivityContext.setUIController(mLauncher == null
? TaskbarUIController.DEFAULT
: new LauncherTaskbarUIController(launcher, mTaskbarActivityContext));
mTaskbarActivityContext.setUIController(
new LauncherTaskbarUIController(launcher, mTaskbarActivityContext));
}
}
/**
* Clears a previously set Launcher
*/
public void clearLauncher(@NonNull BaseQuickstepLauncher launcher) {
if (mLauncher == launcher) {
mLauncher = null;
if (mTaskbarActivityContext != null) {
mTaskbarActivityContext.setUIController(TaskbarUIController.DEFAULT);
}
}
}