Fixing potential NullPointer exceptions when Launcher is

created before TouchInteractionService is initialized

SystemUiProxy is a wrapper opject which holds the state information
until the actual proxy is initialized. It is safe to be initialized
lazily.

Bug: 221961069
Test: Verified on device
Change-Id: I1a621cad52e5b8384439ef02de6b95c6452bcb06
This commit is contained in:
Sunny Goyal
2022-04-18 15:29:45 -07:00
parent 7ee087f53f
commit 25137534a1
7 changed files with 17 additions and 41 deletions
@@ -19,6 +19,7 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS;
import android.content.Context;
import android.os.RemoteException;
import android.util.Log;
import android.view.IRecentsAnimationController;
@@ -97,24 +98,20 @@ public class RecentsAnimationController {
* Indicates that the gesture has crossed the window boundary threshold and we should minimize
* if we are in splitscreen.
*/
public void setSplitScreenMinimized(boolean splitScreenMinimized) {
public void setSplitScreenMinimized(Context context, boolean splitScreenMinimized) {
if (!mAllowMinimizeSplitScreen) {
return;
}
if (mSplitScreenMinimized != splitScreenMinimized) {
mSplitScreenMinimized = splitScreenMinimized;
UI_HELPER_EXECUTOR.execute(() -> {
SystemUiProxy p = SystemUiProxy.INSTANCE.getNoCreate();
if (p != null) {
p.setSplitScreenMinimized(splitScreenMinimized);
}
});
UI_HELPER_EXECUTOR.execute(() -> SystemUiProxy.INSTANCE.get(context)
.setSplitScreenMinimized(splitScreenMinimized));
}
}
/**
* Remove task remote animation target from
* {@link RecentsAnimationCallbacks#onTaskAppeared(RemoteAnimationTargetCompat)}}.
* {@link RecentsAnimationCallbacks#onTasksAppeared}}.
*/
@UiThread
public void removeTaskTarget(@NonNull RemoteAnimationTargetCompat target) {