Merge "Add cleanup for KeyguardService.wrap()" into udc-dev
This commit is contained in:
@@ -62,6 +62,7 @@ import android.window.IRemoteTransition;
|
|||||||
import android.window.IRemoteTransitionFinishedCallback;
|
import android.window.IRemoteTransitionFinishedCallback;
|
||||||
import android.window.TransitionInfo;
|
import android.window.TransitionInfo;
|
||||||
|
|
||||||
|
import com.android.internal.annotations.GuardedBy;
|
||||||
import com.android.internal.policy.IKeyguardDismissCallback;
|
import com.android.internal.policy.IKeyguardDismissCallback;
|
||||||
import com.android.internal.policy.IKeyguardDrawnCallback;
|
import com.android.internal.policy.IKeyguardDrawnCallback;
|
||||||
import com.android.internal.policy.IKeyguardExitCallback;
|
import com.android.internal.policy.IKeyguardExitCallback;
|
||||||
@@ -156,15 +157,19 @@ public class KeyguardService extends Service {
|
|||||||
// Note: Also used for wrapping occlude by Dream animation. It works (with some redundancy).
|
// Note: Also used for wrapping occlude by Dream animation. It works (with some redundancy).
|
||||||
public static IRemoteTransition wrap(IRemoteAnimationRunner runner) {
|
public static IRemoteTransition wrap(IRemoteAnimationRunner runner) {
|
||||||
return new IRemoteTransition.Stub() {
|
return new IRemoteTransition.Stub() {
|
||||||
final ArrayMap<IBinder, IRemoteTransitionFinishedCallback> mFinishCallbacks =
|
|
||||||
new ArrayMap<>();
|
|
||||||
private final ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = new ArrayMap<>();
|
private final ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = new ArrayMap<>();
|
||||||
|
|
||||||
|
@GuardedBy("mLeashMap")
|
||||||
|
private IRemoteTransitionFinishedCallback mFinishCallback = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startAnimation(IBinder transition, TransitionInfo info,
|
public void startAnimation(IBinder transition, TransitionInfo info,
|
||||||
SurfaceControl.Transaction t, IRemoteTransitionFinishedCallback finishCallback)
|
SurfaceControl.Transaction t, IRemoteTransitionFinishedCallback finishCallback)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
Slog.d(TAG, "Starts IRemoteAnimationRunner: info=" + info);
|
Slog.d(TAG, "Starts IRemoteAnimationRunner: info=" + info);
|
||||||
|
|
||||||
|
synchronized (mLeashMap) {
|
||||||
final RemoteAnimationTarget[] apps =
|
final RemoteAnimationTarget[] apps =
|
||||||
wrap(info, false /* wallpapers */, t, mLeashMap);
|
wrap(info, false /* wallpapers */, t, mLeashMap);
|
||||||
final RemoteAnimationTarget[] wallpapers =
|
final RemoteAnimationTarget[] wallpapers =
|
||||||
@@ -181,39 +186,32 @@ public class KeyguardService extends Service {
|
|||||||
initAlphaForAnimationTargets(t, apps);
|
initAlphaForAnimationTargets(t, apps);
|
||||||
initAlphaForAnimationTargets(t, wallpapers);
|
initAlphaForAnimationTargets(t, wallpapers);
|
||||||
t.apply();
|
t.apply();
|
||||||
synchronized (mFinishCallbacks) {
|
mFinishCallback = finishCallback;
|
||||||
mFinishCallbacks.put(transition, finishCallback);
|
runner.onAnimationStart(
|
||||||
}
|
getTransitionOldType(info.getType(), info.getFlags(), apps),
|
||||||
runner.onAnimationStart(getTransitionOldType(info.getType(), info.getFlags(), apps),
|
|
||||||
apps, wallpapers, nonApps,
|
apps, wallpapers, nonApps,
|
||||||
new IRemoteAnimationFinishedCallback.Stub() {
|
new IRemoteAnimationFinishedCallback.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationFinished() throws RemoteException {
|
public void onAnimationFinished() throws RemoteException {
|
||||||
synchronized (mFinishCallbacks) {
|
synchronized (mLeashMap) {
|
||||||
if (mFinishCallbacks.remove(transition) == null) return;
|
|
||||||
}
|
|
||||||
info.releaseAllSurfaces();
|
|
||||||
Slog.d(TAG, "Finish IRemoteAnimationRunner.");
|
Slog.d(TAG, "Finish IRemoteAnimationRunner.");
|
||||||
finishCallback.onTransitionFinished(null /* wct */, null /* t */);
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void mergeAnimation(IBinder candidateTransition, TransitionInfo candidateInfo,
|
public void mergeAnimation(IBinder candidateTransition, TransitionInfo candidateInfo,
|
||||||
SurfaceControl.Transaction candidateT, IBinder currentTransition,
|
SurfaceControl.Transaction candidateT, IBinder currentTransition,
|
||||||
IRemoteTransitionFinishedCallback candidateFinishCallback) {
|
IRemoteTransitionFinishedCallback candidateFinishCallback)
|
||||||
|
throws RemoteException {
|
||||||
try {
|
try {
|
||||||
final IRemoteTransitionFinishedCallback currentFinishCB;
|
synchronized (mLeashMap) {
|
||||||
synchronized (mFinishCallbacks) {
|
|
||||||
currentFinishCB = mFinishCallbacks.remove(currentTransition);
|
|
||||||
}
|
|
||||||
if (currentFinishCB == null) {
|
|
||||||
Slog.e(TAG, "Called mergeAnimation, but finish callback is missing");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
runner.onAnimationCancelled();
|
runner.onAnimationCancelled();
|
||||||
currentFinishCB.onTransitionFinished(null /* wct */, null /* t */);
|
finish();
|
||||||
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// nothing, we'll just let it finish on its own I guess.
|
// nothing, we'll just let it finish on its own I guess.
|
||||||
}
|
}
|
||||||
@@ -226,6 +224,16 @@ public class KeyguardService extends Service {
|
|||||||
t.setAlpha(target.leash, 0.f);
|
t.setAlpha(target.leash, 0.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GuardedBy("mLeashMap")
|
||||||
|
private void finish() throws RemoteException {
|
||||||
|
mLeashMap.clear();
|
||||||
|
final IRemoteTransitionFinishedCallback finishCallback = mFinishCallback;
|
||||||
|
if (finishCallback != null) {
|
||||||
|
mFinishCallback = null;
|
||||||
|
finishCallback.onTransitionFinished(null /* wct */, null /* t */);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user