mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
Fixing LauncherAnimationRunning referring a destroyed activity
Bug: 139137636 Change-Id: Id070a98103a7116179e7ee66fabeeb33fb19b1ff
This commit is contained in:
@@ -86,8 +86,6 @@ import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat;
|
||||
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;
|
||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* {@link LauncherAppTransitionManager} with Quickstep-specific app transitions for launching from
|
||||
* home and/or all-apps. Not used for 3p launchers.
|
||||
@@ -784,52 +782,6 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
|
||||
== PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used with WrappedLauncherAnimationRunner as an interface for the runner to call back to the
|
||||
* implementation.
|
||||
*/
|
||||
protected interface WrappedAnimationRunnerImpl {
|
||||
Handler getHandler();
|
||||
void onCreateAnimation(RemoteAnimationTargetCompat[] appTargets,
|
||||
RemoteAnimationTargetCompat[] wallpaperTargets,
|
||||
LauncherAnimationRunner.AnimationResult result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is needed to wrap any animation runner that is a part of the
|
||||
* RemoteAnimationDefinition:
|
||||
* - Launcher creates a new instance of the LauncherAppTransitionManagerImpl whenever it is
|
||||
* created, which in turn registers a new definition
|
||||
* - When the definition is registered, window manager retains a strong binder reference to the
|
||||
* runner passed in
|
||||
* - If the Launcher activity is recreated, the new definition registered will replace the old
|
||||
* reference in the system's activity record, but until the system server is GC'd, the binder
|
||||
* reference will still exist, which references the runner in the Launcher process, which
|
||||
* references the (old) Launcher activity through this class
|
||||
*
|
||||
* Instead we make the runner provided to the definition static only holding a weak reference to
|
||||
* the runner implementation. When this animation manager is destroyed, we remove the Launcher
|
||||
* reference to the runner, leaving only the weak ref from the runner.
|
||||
*/
|
||||
protected static class WrappedLauncherAnimationRunner<R extends WrappedAnimationRunnerImpl>
|
||||
extends LauncherAnimationRunner {
|
||||
private WeakReference<R> mImpl;
|
||||
|
||||
public WrappedLauncherAnimationRunner(R animationRunnerImpl, boolean startAtFrontOfQueue) {
|
||||
super(animationRunnerImpl.getHandler(), startAtFrontOfQueue);
|
||||
mImpl = new WeakReference<>(animationRunnerImpl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateAnimation(RemoteAnimationTargetCompat[] appTargets,
|
||||
RemoteAnimationTargetCompat[] wallpaperTargets, AnimationResult result) {
|
||||
R animationRunnerImpl = mImpl.get();
|
||||
if (animationRunnerImpl != null) {
|
||||
animationRunnerImpl.onCreateAnimation(appTargets, wallpaperTargets, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote animation runner for animation from the app to Launcher, including recents.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user