Winson Chung | 7048fea | 2014-03-18 12:21:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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.recents; |
| 18 | |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 19 | import android.content.ContentResolver; |
Dave Mankoff | a5d8a39 | 2019-10-10 12:21:09 -0400 | [diff] [blame] | 20 | import android.content.Context; |
Winson Chung | 7048fea | 2014-03-18 12:21:24 -0700 | [diff] [blame] | 21 | import android.content.res.Configuration; |
Jorim Jaggi | 9ea2f7b | 2015-11-23 18:08:28 -0800 | [diff] [blame] | 22 | import android.graphics.Rect; |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 23 | import android.provider.Settings; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 24 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 25 | import com.android.systemui.SystemUI; |
Jason Monk | 764da99 | 2017-02-02 14:11:20 -0500 | [diff] [blame] | 26 | import com.android.systemui.statusbar.CommandQueue; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 27 | |
Winson Chung | ee69756 | 2017-05-18 14:29:43 -0700 | [diff] [blame] | 28 | import java.io.FileDescriptor; |
| 29 | import java.io.PrintWriter; |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 30 | |
Winson | 190fe3bf | 2015-10-20 14:57:24 -0700 | [diff] [blame] | 31 | /** |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 32 | * A proxy to a Recents implementation. |
Winson | 190fe3bf | 2015-10-20 14:57:24 -0700 | [diff] [blame] | 33 | */ |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 34 | public class Recents extends SystemUI implements CommandQueue.Callbacks { |
Winson | 190fe3bf | 2015-10-20 14:57:24 -0700 | [diff] [blame] | 35 | |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 36 | private final RecentsImplementation mImpl; |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 37 | private final CommandQueue mCommandQueue; |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 38 | |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 39 | public Recents(Context context, RecentsImplementation impl, CommandQueue commandQueue) { |
Dave Mankoff | a5d8a39 | 2019-10-10 12:21:09 -0400 | [diff] [blame] | 40 | super(context); |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 41 | mImpl = impl; |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 42 | mCommandQueue = commandQueue; |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 43 | } |
Winson | c742f97 | 2015-11-12 11:32:21 -0800 | [diff] [blame] | 44 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 45 | @Override |
| 46 | public void start() { |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 47 | mCommandQueue.addCallback(this); |
Dave Mankoff | 95754e7 | 2019-11-14 11:39:18 -0500 | [diff] [blame] | 48 | mImpl.onStart(mContext); |
Winson Chung | 5abdceb | 2014-06-05 10:58:05 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 51 | @Override |
Winson Chung | 8bf05af | 2014-09-29 13:42:49 -0700 | [diff] [blame] | 52 | public void onBootCompleted() { |
Winson | 190fe3bf | 2015-10-20 14:57:24 -0700 | [diff] [blame] | 53 | mImpl.onBootCompleted(); |
Winson Chung | 8bf05af | 2014-09-29 13:42:49 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 56 | @Override |
| 57 | public void onConfigurationChanged(Configuration newConfig) { |
| 58 | mImpl.onConfigurationChanged(newConfig); |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 61 | @Override |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 62 | public void appTransitionFinished(int displayId) { |
| 63 | if (mContext.getDisplayId() == displayId) { |
| 64 | mImpl.onAppTransitionFinished(); |
| 65 | } |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | public void growRecents() { |
| 69 | mImpl.growRecents(); |
| 70 | } |
| 71 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 72 | @Override |
Winson Chung | dff7a73 | 2017-12-11 12:17:06 -0800 | [diff] [blame] | 73 | public void showRecentApps(boolean triggeredFromAltTab) { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 74 | // Ensure the device has been provisioned before allowing the user to interact with |
| 75 | // recents |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 76 | if (!isUserSetup()) { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 77 | return; |
| 78 | } |
| 79 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 80 | mImpl.showRecentApps(triggeredFromAltTab); |
Winson Chung | 2002cf5 | 2014-12-08 17:26:44 -0800 | [diff] [blame] | 81 | } |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 82 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 83 | @Override |
Jason Monk | 764da99 | 2017-02-02 14:11:20 -0500 | [diff] [blame] | 84 | public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 85 | // Ensure the device has been provisioned before allowing the user to interact with |
| 86 | // recents |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 87 | if (!isUserSetup()) { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 88 | return; |
| 89 | } |
| 90 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 91 | mImpl.hideRecentApps(triggeredFromAltTab, triggeredFromHomeKey); |
Winson Chung | 2002cf5 | 2014-12-08 17:26:44 -0800 | [diff] [blame] | 92 | } |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 93 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 94 | @Override |
Winson Chung | ebe1ba1 | 2017-05-18 15:47:14 -0700 | [diff] [blame] | 95 | public void toggleRecentApps() { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 96 | // Ensure the device has been provisioned before allowing the user to interact with |
| 97 | // recents |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 98 | if (!isUserSetup()) { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 99 | return; |
| 100 | } |
| 101 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 102 | mImpl.toggleRecentApps(); |
Winson Chung | 2002cf5 | 2014-12-08 17:26:44 -0800 | [diff] [blame] | 103 | } |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 104 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 105 | @Override |
Winson Chung | ebe1ba1 | 2017-05-18 15:47:14 -0700 | [diff] [blame] | 106 | public void preloadRecentApps() { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 107 | // Ensure the device has been provisioned before allowing the user to interact with |
| 108 | // recents |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 109 | if (!isUserSetup()) { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 110 | return; |
| 111 | } |
| 112 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 113 | mImpl.preloadRecentApps(); |
Winson Chung | 7048fea | 2014-03-18 12:21:24 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 116 | @Override |
Jason Monk | 764da99 | 2017-02-02 14:11:20 -0500 | [diff] [blame] | 117 | public void cancelPreloadRecentApps() { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 118 | // Ensure the device has been provisioned before allowing the user to interact with |
| 119 | // recents |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 120 | if (!isUserSetup()) { |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 121 | return; |
| 122 | } |
| 123 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 124 | mImpl.cancelPreloadRecentApps(); |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 127 | public boolean splitPrimaryTask(int stackCreateMode, Rect initialBounds, |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 128 | int metricsDockAction) { |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 129 | // Ensure the device has been provisioned before allowing the user to interact with |
| 130 | // recents |
| 131 | if (!isUserSetup()) { |
| 132 | return false; |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 133 | } |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 134 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 135 | return mImpl.splitPrimaryTask(stackCreateMode, initialBounds, metricsDockAction); |
Winson | 190fe3bf | 2015-10-20 14:57:24 -0700 | [diff] [blame] | 136 | } |
Winson | 4727ab9 | 2015-11-02 14:35:34 -0800 | [diff] [blame] | 137 | |
| 138 | /** |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 139 | * @return whether this device is provisioned and the current user is set up. |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 140 | */ |
Winson | e6309aa | 2016-01-08 11:19:21 -0800 | [diff] [blame] | 141 | private boolean isUserSetup() { |
| 142 | ContentResolver cr = mContext.getContentResolver(); |
| 143 | return (Settings.Global.getInt(cr, Settings.Global.DEVICE_PROVISIONED, 0) != 0) && |
| 144 | (Settings.Secure.getInt(cr, Settings.Secure.USER_SETUP_COMPLETE, 0) != 0); |
Winson | e924356 | 2015-11-10 16:07:13 -0800 | [diff] [blame] | 145 | } |
| 146 | |
Winson Chung | ee69756 | 2017-05-18 14:29:43 -0700 | [diff] [blame] | 147 | @Override |
| 148 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 149 | mImpl.dump(pw); |
Winson Chung | ee69756 | 2017-05-18 14:29:43 -0700 | [diff] [blame] | 150 | } |
Winson Chung | 7048fea | 2014-03-18 12:21:24 -0700 | [diff] [blame] | 151 | } |