1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.wm.shell.transition; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.os.IBinder; 22 import android.util.Slog; 23 import android.view.SurfaceControl; 24 import android.window.TransitionInfo; 25 import android.window.TransitionRequestInfo; 26 import android.window.WindowContainerTransaction; 27 28 /** 29 * A Simple handler that tracks SLEEP transitions. We track them specially since we (ab)use these 30 * as sentinels for fast-forwarding through animations when the screen is off. 31 * 32 * There should only be one SleepHandler and it is used explicitly by {@link Transitions} so we 33 * don't register it like a normal handler. 34 */ 35 class SleepHandler implements Transitions.TransitionHandler { 36 @Override startAnimation(@onNull IBinder transition, @NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull Transitions.TransitionFinishCallback finishCallback)37 public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info, 38 @NonNull SurfaceControl.Transaction startTransaction, 39 @NonNull SurfaceControl.Transaction finishTransaction, 40 @NonNull Transitions.TransitionFinishCallback finishCallback) { 41 if (info.hasChangesOrSideEffects()) { 42 Slog.e(Transitions.TAG, "Real changes included in a SLEEP transition"); 43 return false; 44 } else { 45 startTransaction.apply(); 46 finishCallback.onTransitionFinished(null); 47 return true; 48 } 49 } 50 51 @Override 52 @Nullable handleRequest(@onNull IBinder transition, @NonNull TransitionRequestInfo request)53 public WindowContainerTransaction handleRequest(@NonNull IBinder transition, 54 @NonNull TransitionRequestInfo request) { 55 return new WindowContainerTransaction(); 56 } 57 } 58