Winson Chung | cbb15a9 | 2018-01-25 17:46:16 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.shared.system; |
| 18 | |
| 19 | import android.app.ActivityManager.TaskSnapshot; |
| 20 | import android.os.RemoteException; |
| 21 | import android.util.Log; |
| 22 | import android.view.IRecentsAnimationController; |
| 23 | |
| 24 | import com.android.systemui.shared.recents.model.ThumbnailData; |
| 25 | |
| 26 | public class RecentsAnimationControllerCompat { |
| 27 | |
| 28 | private static final String TAG = RecentsAnimationControllerCompat.class.getSimpleName(); |
| 29 | |
| 30 | private IRecentsAnimationController mAnimationController; |
| 31 | |
Sunny Goyal | 040a10a | 2018-03-19 16:11:50 -0700 | [diff] [blame] | 32 | public RecentsAnimationControllerCompat() { } |
| 33 | |
Winson Chung | cbb15a9 | 2018-01-25 17:46:16 +0000 | [diff] [blame] | 34 | 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 Jaggi | 50bf59c | 2018-03-09 17:29:48 +0100 | [diff] [blame] | 56 | 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 Chung | a840c32 | 2018-04-20 15:58:18 -0700 | [diff] [blame] | 64 | 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 Zhou | 9c675d4 | 2019-04-08 00:32:40 -0700 | [diff] [blame] | 72 | /** |
| 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 Chung | cbb15a9 | 2018-01-25 17:46:16 +0000 | [diff] [blame] | 79 | try { |
Tracy Zhou | 9c675d4 | 2019-04-08 00:32:40 -0700 | [diff] [blame] | 80 | mAnimationController.finish(toHome, sendUserLeaveHint); |
Winson Chung | cbb15a9 | 2018-01-25 17:46:16 +0000 | [diff] [blame] | 81 | } catch (RemoteException e) { |
| 82 | Log.e(TAG, "Failed to finish recents animation", e); |
| 83 | } |
| 84 | } |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 85 | |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 86 | 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 | |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 94 | 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 Zhou | 9e0354f | 2019-10-03 18:05:03 -0700 | [diff] [blame] | 101 | |
| 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 | } |
lumark | 04bceb9 | 2020-03-07 00:03:33 +0800 | [diff] [blame^] | 112 | |
| 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 Chung | cbb15a9 | 2018-01-25 17:46:16 +0000 | [diff] [blame] | 124 | } |