Adding support for listening to end callbacks when launching an intent from Launcher

Also moving various state handling to these end callbacks enstead of relying on resume

Bug: 265134143
Test: Verified that the end callback is received
Change-Id: I326a99c80154d244c0e49f678717c476602b6240
This commit is contained in:
Sunny Goyal
2023-05-12 12:08:53 -07:00
parent 7bc6cdee56
commit 4fdc9181dd
7 changed files with 96 additions and 41 deletions

View File

@@ -68,6 +68,7 @@ import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.RectF;
import android.hardware.SensorManager;
@@ -143,6 +144,7 @@ import com.android.launcher3.uioverrides.touchcontrollers.TwoButtonNavbarTouchCo
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.NavigationMode;
import com.android.launcher3.util.ObjectWrapper;
@@ -343,14 +345,16 @@ public class QuickstepLauncher extends Launcher {
}
@Override
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
public RunnableList startActivitySafely(View v, Intent intent, ItemInfo item) {
// Only pause is taskbar controller is not present
mHotseatPredictionController.setPauseUIUpdate(getTaskbarUIController() == null);
boolean started = super.startActivitySafely(v, intent, item);
if (getTaskbarUIController() == null && !started) {
RunnableList result = super.startActivitySafely(v, intent, item);
if (getTaskbarUIController() == null && result == null) {
mHotseatPredictionController.setPauseUIUpdate(false);
} else {
result.add(() -> mHotseatPredictionController.setPauseUIUpdate(false));
}
return started;
return result;
}
@Override
@@ -370,11 +374,6 @@ public class QuickstepLauncher extends Launcher {
| ACTIVITY_STATE_USER_ACTIVE | ACTIVITY_STATE_TRANSITION_ACTIVE)) != 0) {
onStateOrResumeChanging((getActivityFlags() & ACTIVITY_STATE_TRANSITION_ACTIVE) == 0);
}
if (((changeBits & ACTIVITY_STATE_STARTED) != 0
|| (changeBits & getActivityFlags() & ACTIVITY_STATE_DEFERRED_RESUMED) != 0)) {
mHotseatPredictionController.setPauseUIUpdate(false);
}
}
@Override
@@ -1101,6 +1100,17 @@ public class QuickstepLauncher extends Launcher {
return activityOptions;
}
@Override
public ActivityOptionsWrapper makeDefaultActivityOptions(int splashScreenStyle) {
RunnableList callbacks = new RunnableList();
ActivityOptions options = ActivityOptions.makeCustomAnimation(
this, 0, 0, Color.TRANSPARENT,
Executors.MAIN_EXECUTOR.getHandler(), null,
elapsedRealTime -> callbacks.executeAllAndDestroy());
options.setSplashScreenStyle(splashScreenStyle);
return new ActivityOptionsWrapper(options, callbacks);
}
@Override
@BinderThread
public void enterStageSplitFromRunningApp(boolean leftOrTop) {