This commit is contained in:
MrSluffy
2024-12-05 14:37:31 +08:00
parent a7f92325b9
commit 70fcc22f20
2 changed files with 12 additions and 8 deletions

View File

@@ -1055,19 +1055,12 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer
/** Receives animation progress from sysui process. */
private void initRemotelyCalculatedUnfoldAnimation(UnfoldTransitionConfig config) {
Handler handler;
try {
handler = getMainThreadHandler();
} catch (Throwable t) {
handler = new Handler(Looper.getMainLooper());
}
RemoteUnfoldSharedComponent unfoldComponent =
UnfoldTransitionFactory.createRemoteUnfoldSharedComponent(
/* context= */ this,
config,
getMainExecutor(),
handler,
getMainThreadHandler(),
/* backgroundExecutor= */ UI_HELPER_EXECUTOR,
/* bgHandler= */ UI_HELPER_EXECUTOR.getHandler(),
/* tracingTagPrefix= */ "launcher",

View File

@@ -28,6 +28,8 @@ import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.window.OnBackInvokedDispatcher;
@@ -392,6 +394,15 @@ public abstract class BaseActivity extends ComponentActivity implements Activity
mEventCallbacks[event].add(callback);
}
@Override
public Handler getMainThreadHandler() {
try {
return new Handler(Looper.getMainLooper());
} catch (Throwable t) {
return super.getMainThreadHandler();
}
}
/** Removes a previously added callback */
public void removeEventCallback(@ActivityEvent int event, Runnable callback) {
mEventCallbacks[event].remove(callback);