blob: 76513c6ff3d53499ee61c16442ff7786dec21a08 [file] [log] [blame]
Winson Chungcbb15a92018-01-25 17:46:16 +00001/*
2 * Copyright (C) 2018 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
17package com.android.systemui.shared.system;
18
19import android.app.ActivityManager.TaskSnapshot;
20import android.os.RemoteException;
21import android.util.Log;
22import android.view.IRecentsAnimationController;
23
24import com.android.systemui.shared.recents.model.ThumbnailData;
25
26public class RecentsAnimationControllerCompat {
27
28 private static final String TAG = RecentsAnimationControllerCompat.class.getSimpleName();
29
30 private IRecentsAnimationController mAnimationController;
31
Sunny Goyal040a10a2018-03-19 16:11:50 -070032 public RecentsAnimationControllerCompat() { }
33
Winson Chungcbb15a92018-01-25 17:46:16 +000034 public RecentsAnimationControllerCompat(IRecentsAnimationController animationController) {
35 mAnimationController = animationController;
36 }
37
38 public ThumbnailData screenshotTask(int taskId) {
39 try {
40 TaskSnapshot snapshot = mAnimationController.screenshotTask(taskId);
41 return snapshot != null ? new ThumbnailData(snapshot) : new ThumbnailData();
42 } catch (RemoteException e) {
43 Log.e(TAG, "Failed to screenshot task", e);
44 return new ThumbnailData();
45 }
46 }
47
48 public void setInputConsumerEnabled(boolean enabled) {
49 try {
50 mAnimationController.setInputConsumerEnabled(enabled);
51 } catch (RemoteException e) {
52 Log.e(TAG, "Failed to set input consumer enabled state", e);
53 }
54 }
55
Jorim Jaggi50bf59c2018-03-09 17:29:48 +010056 public void setAnimationTargetsBehindSystemBars(boolean behindSystemBars) {
57 try {
58 mAnimationController.setAnimationTargetsBehindSystemBars(behindSystemBars);
59 } catch (RemoteException e) {
60 Log.e(TAG, "Failed to set whether animation targets are behind system bars", e);
61 }
62 }
63
Winson Chunga840c322018-04-20 15:58:18 -070064 public void hideCurrentInputMethod() {
65 try {
66 mAnimationController.hideCurrentInputMethod();
67 } catch (RemoteException e) {
68 Log.e(TAG, "Failed to set hide input method", e);
69 }
70 }
71
Tracy Zhou9c675d42019-04-08 00:32:40 -070072 /**
73 * Finish the current recents animation.
74 * @param toHome Going to home or back to the previous app.
75 * @param sendUserLeaveHint determines whether userLeaveHint will be set true to the previous
76 * app.
77 */
78 public void finish(boolean toHome, boolean sendUserLeaveHint) {
Winson Chungcbb15a92018-01-25 17:46:16 +000079 try {
Tracy Zhou9c675d42019-04-08 00:32:40 -070080 mAnimationController.finish(toHome, sendUserLeaveHint);
Winson Chungcbb15a92018-01-25 17:46:16 +000081 } catch (RemoteException e) {
82 Log.e(TAG, "Failed to finish recents animation", e);
83 }
84 }
lumark54284462019-03-05 20:44:27 +080085
Winson Chung7a545ae2019-07-16 14:52:13 -070086 public void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot) {
87 try {
88 mAnimationController.setDeferCancelUntilNextTransition(defer, screenshot);
89 } catch (RemoteException e) {
90 Log.e(TAG, "Failed to set deferred cancel with screenshot", e);
91 }
92 }
93
lumark54284462019-03-05 20:44:27 +080094 public void cleanupScreenshot() {
95 try {
96 mAnimationController.cleanupScreenshot();
97 } catch (RemoteException e) {
98 Log.e(TAG, "Failed to clean up screenshot of recents animation", e);
99 }
100 }
Tracy Zhou9e0354f2019-10-03 18:05:03 -0700101
102 /**
103 * @see {{@link IRecentsAnimationController#setWillFinishToHome(boolean)}}.
104 */
105 public void setWillFinishToHome(boolean willFinishToHome) {
106 try {
107 mAnimationController.setWillFinishToHome(willFinishToHome);
108 } catch (RemoteException e) {
109 Log.e(TAG, "Failed to set overview reached state", e);
110 }
111 }
lumark04bceb92020-03-07 00:03:33 +0800112
113 /**
114 * @see IRecentsAnimationController#removeTask
115 */
116 public boolean removeTask(int taskId) {
117 try {
118 return mAnimationController.removeTask(taskId);
119 } catch (RemoteException e) {
120 Log.e(TAG, "Failed to remove remote animation target", e);
121 return false;
122 }
123 }
Winson Chungcbb15a92018-01-25 17:46:16 +0000124}