Wait for the Launcher activity to bind to TIS before animating
- Mainly a test issue where we destroy the activity and immediately enter overview without preloading launcher. In this case, the task bar does not animate due to the delayed cycled of activity create -> bind service -> service connected -> taskbar ui controller init. As a result, the bar can occlude content from Launcher preventing the test from finding the overview actions. Instead, in cases where we need to animate with launcher, we wait for Launcher to be created (generally already the case) and the service has bound before proceeding. Bug: 189807374 Bug: 204891006 Test: atest NexusLauncherTests:com.android.quickstep.StartLauncherViaGestureTests Change-Id: I2cfccae67ac0e5a591639c6c99df032451dae16d
This commit is contained in:
1 parent
be0360c6d8
commit
8581dfc218
5 files changed
+89
-32
No files matched your search
@@ -26,6 +26,7 @@ import android.util.Log;
|
||||
import com.android.quickstep.TouchInteractionService;
|
||||
import com.android.quickstep.TouchInteractionService.TISBinder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -44,9 +45,11 @@ public class TISBindHelper implements ServiceConnection {
|
||||
private final Runnable mConnectionRunnable = this::internalBindToTIS;
|
||||
private final Context mContext;
|
||||
private final Consumer<TISBinder> mConnectionCallback;
|
||||
private final ArrayList<Runnable> mPendingConnectedCallbacks = new ArrayList<>();
|
||||
|
||||
private short mConnectionAttempts;
|
||||
private boolean mTisServiceBound;
|
||||
private boolean mIsConnected;
|
||||
|
||||
public TISBindHelper(Context context, Consumer<TISBinder> connectionCallback) {
|
||||
mContext = context;
|
||||
@@ -66,7 +69,13 @@ public class TISBindHelper implements ServiceConnection {
|
||||
}
|
||||
|
||||
Log.d(TAG, "TIS service connected");
|
||||
mIsConnected = true;
|
||||
mConnectionCallback.accept((TISBinder) iBinder);
|
||||
// Flush the pending callbacks
|
||||
for (Runnable r : mPendingConnectedCallbacks) {
|
||||
r.run();
|
||||
}
|
||||
mPendingConnectedCallbacks.clear();
|
||||
resetServiceBindRetryState();
|
||||
}
|
||||
|
||||
@@ -79,6 +88,16 @@ public class TISBindHelper implements ServiceConnection {
|
||||
internalBindToTIS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the given {@param r} runnable when the service is connected.
|
||||
*/
|
||||
public void runOnBindToTouchInteractionService(Runnable r) {
|
||||
if (mIsConnected) {
|
||||
r.run();
|
||||
} else {
|
||||
mPendingConnectedCallbacks.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds to {@link TouchInteractionService}. If the binding fails, attempts to retry via
|
||||
@@ -120,5 +139,7 @@ public class TISBindHelper implements ServiceConnection {
|
||||
public void onDestroy() {
|
||||
internalUnbindToTIS();
|
||||
resetServiceBindRetryState();
|
||||
mIsConnected = false;
|
||||
mPendingConnectedCallbacks.clear();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user