Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 1 | /* |
Wale Ogunwale | 5950709 | 2018-10-29 09:00:30 -0700 | [diff] [blame^] | 2 | * Copyright (C) 2018 The Android Open Source Project |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 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 |
Wale Ogunwale | 5950709 | 2018-10-29 09:00:30 -0700 | [diff] [blame^] | 14 | * limitations under the License |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
Wale Ogunwale | 5950709 | 2018-10-29 09:00:30 -0700 | [diff] [blame^] | 17 | package com.android.server.wm; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 18 | |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 19 | import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 20 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 21 | import static org.junit.Assert.assertEquals; |
| 22 | import static org.junit.Assert.assertFalse; |
| 23 | import static org.junit.Assert.assertTrue; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 24 | |
| 25 | import android.app.Activity; |
Sudheer Shanka | dc589ac | 2016-11-10 15:30:17 -0800 | [diff] [blame] | 26 | import android.app.ActivityManager; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 27 | import android.app.ActivityManager.TaskDescription; |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 28 | import android.app.ActivityTaskManager; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 29 | import android.app.IActivityManager; |
| 30 | import android.app.ITaskStackListener; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 31 | import android.app.Instrumentation.ActivityMonitor; |
| 32 | import android.app.TaskStackListener; |
| 33 | import android.content.ComponentName; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 34 | import android.content.Context; |
| 35 | import android.content.Intent; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 36 | import android.content.pm.ActivityInfo; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 37 | import android.os.RemoteException; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 38 | import android.support.test.uiautomator.UiDevice; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 39 | import android.text.TextUtils; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 40 | |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 41 | import androidx.test.filters.MediumTest; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 42 | |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 43 | import com.android.internal.annotations.GuardedBy; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 44 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 45 | import org.junit.After; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 46 | import org.junit.Before; |
| 47 | import org.junit.Test; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 48 | |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 49 | import java.util.concurrent.CountDownLatch; |
| 50 | import java.util.concurrent.TimeUnit; |
| 51 | |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 52 | /** |
| 53 | * Build/Install/Run: |
| 54 | * atest WmTests:TaskStackChangedListenerTest |
| 55 | */ |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 56 | @MediumTest |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 57 | public class TaskStackChangedListenerTest { |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 58 | |
| 59 | private IActivityManager mService; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 60 | private ITaskStackListener mTaskStackListener; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 61 | |
| 62 | private static final Object sLock = new Object(); |
| 63 | @GuardedBy("sLock") |
| 64 | private static boolean sTaskStackChangedCalled; |
| 65 | private static boolean sActivityBResumed; |
| 66 | |
| 67 | @Before |
| 68 | public void setUp() throws Exception { |
Sudheer Shanka | dc589ac | 2016-11-10 15:30:17 -0800 | [diff] [blame] | 69 | mService = ActivityManager.getService(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | @After |
| 73 | public void tearDown() throws Exception { |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 74 | ActivityTaskManager.getService().unregisterTaskStackListener(mTaskStackListener); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 75 | mTaskStackListener = null; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | @Test |
| 79 | public void testTaskStackChanged_afterFinish() throws Exception { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 80 | registerTaskStackChangedListener(new TaskStackListener() { |
| 81 | @Override |
| 82 | public void onTaskStackChanged() throws RemoteException { |
| 83 | synchronized (sLock) { |
| 84 | sTaskStackChangedCalled = true; |
| 85 | } |
| 86 | } |
| 87 | }); |
| 88 | |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 89 | Context context = getInstrumentation().getContext(); |
| 90 | context.startActivity(new Intent(context, ActivityA.class)); |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 91 | UiDevice.getInstance(getInstrumentation()).waitForIdle(); |
| 92 | synchronized (sLock) { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 93 | assertTrue(sTaskStackChangedCalled); |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 94 | } |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 95 | assertTrue(sActivityBResumed); |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 96 | } |
| 97 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 98 | @Test |
| 99 | public void testTaskDescriptionChanged() throws Exception { |
| 100 | final Object[] params = new Object[2]; |
| 101 | final CountDownLatch latch = new CountDownLatch(1); |
| 102 | registerTaskStackChangedListener(new TaskStackListener() { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 103 | int mTaskId = -1; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 104 | |
| 105 | @Override |
| 106 | public void onTaskCreated(int taskId, ComponentName componentName) |
| 107 | throws RemoteException { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 108 | mTaskId = taskId; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 109 | } |
| 110 | @Override |
| 111 | public void onTaskDescriptionChanged(int taskId, TaskDescription td) |
| 112 | throws RemoteException { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 113 | if (mTaskId == taskId && !TextUtils.isEmpty(td.getLabel())) { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 114 | params[0] = taskId; |
| 115 | params[1] = td; |
| 116 | latch.countDown(); |
| 117 | } |
| 118 | } |
| 119 | }); |
| 120 | final Activity activity = startTestActivity(ActivityTaskDescriptionChange.class); |
| 121 | waitForCallback(latch); |
| 122 | assertEquals(activity.getTaskId(), params[0]); |
| 123 | assertEquals("Test Label", ((TaskDescription) params[1]).getLabel()); |
| 124 | } |
| 125 | |
| 126 | @Test |
| 127 | public void testActivityRequestedOrientationChanged() throws Exception { |
| 128 | final int[] params = new int[2]; |
| 129 | final CountDownLatch latch = new CountDownLatch(1); |
| 130 | registerTaskStackChangedListener(new TaskStackListener() { |
| 131 | @Override |
| 132 | public void onActivityRequestedOrientationChanged(int taskId, |
| 133 | int requestedOrientation) { |
| 134 | params[0] = taskId; |
| 135 | params[1] = requestedOrientation; |
| 136 | latch.countDown(); |
| 137 | } |
| 138 | }); |
| 139 | final Activity activity = startTestActivity(ActivityRequestedOrientationChange.class); |
| 140 | waitForCallback(latch); |
| 141 | assertEquals(activity.getTaskId(), params[0]); |
| 142 | assertEquals(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, params[1]); |
| 143 | } |
| 144 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 145 | /** |
| 146 | * Tests for onTaskCreated, onTaskMovedToFront, onTaskRemoved and onTaskRemovalStarted. |
| 147 | */ |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 148 | @Test |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 149 | public void testTaskChangeCallBacks() throws Exception { |
| 150 | final Object[] params = new Object[2]; |
| 151 | final CountDownLatch taskCreatedLaunchLatch = new CountDownLatch(1); |
| 152 | final CountDownLatch taskMovedToFrontLatch = new CountDownLatch(1); |
| 153 | final CountDownLatch taskRemovedLatch = new CountDownLatch(1); |
| 154 | final CountDownLatch taskRemovalStartedLatch = new CountDownLatch(1); |
| 155 | final CountDownLatch onDetachedFromWindowLatch = new CountDownLatch(1); |
| 156 | registerTaskStackChangedListener(new TaskStackListener() { |
| 157 | @Override |
| 158 | public void onTaskCreated(int taskId, ComponentName componentName) |
| 159 | throws RemoteException { |
| 160 | params[0] = taskId; |
| 161 | params[1] = componentName; |
| 162 | taskCreatedLaunchLatch.countDown(); |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public void onTaskMovedToFront(int taskId) throws RemoteException { |
| 167 | params[0] = taskId; |
| 168 | taskMovedToFrontLatch.countDown(); |
| 169 | } |
| 170 | |
| 171 | @Override |
| 172 | public void onTaskRemovalStarted(int taskId) { |
| 173 | params[0] = taskId; |
| 174 | taskRemovalStartedLatch.countDown(); |
| 175 | } |
| 176 | |
| 177 | @Override |
| 178 | public void onTaskRemoved(int taskId) throws RemoteException { |
| 179 | params[0] = taskId; |
| 180 | taskRemovedLatch.countDown(); |
| 181 | } |
| 182 | }); |
| 183 | |
| 184 | final ActivityTaskChangeCallbacks activity = |
| 185 | (ActivityTaskChangeCallbacks) startTestActivity(ActivityTaskChangeCallbacks.class); |
Andrii Kulian | 6a6c4f1 | 2018-07-16 21:23:33 -0700 | [diff] [blame] | 186 | activity.setDetachedFromWindowLatch(onDetachedFromWindowLatch); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 187 | final int id = activity.getTaskId(); |
| 188 | |
| 189 | // Test for onTaskCreated. |
| 190 | waitForCallback(taskCreatedLaunchLatch); |
| 191 | assertEquals(id, params[0]); |
| 192 | ComponentName componentName = (ComponentName) params[1]; |
| 193 | assertEquals(ActivityTaskChangeCallbacks.class.getName(), componentName.getClassName()); |
| 194 | |
| 195 | // Test for onTaskMovedToFront. |
| 196 | assertEquals(1, taskMovedToFrontLatch.getCount()); |
| 197 | mService.moveTaskToFront(id, 0, null); |
| 198 | waitForCallback(taskMovedToFrontLatch); |
| 199 | assertEquals(activity.getTaskId(), params[0]); |
| 200 | |
| 201 | // Test for onTaskRemovalStarted. |
| 202 | assertEquals(1, taskRemovalStartedLatch.getCount()); |
| 203 | activity.finishAndRemoveTask(); |
| 204 | waitForCallback(taskRemovalStartedLatch); |
| 205 | // onTaskRemovalStarted happens before the activity's window is removed. |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 206 | assertFalse(activity.mOnDetachedFromWindowCalled); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 207 | assertEquals(id, params[0]); |
| 208 | |
| 209 | // Test for onTaskRemoved. |
| 210 | assertEquals(1, taskRemovedLatch.getCount()); |
| 211 | waitForCallback(taskRemovedLatch); |
| 212 | assertEquals(id, params[0]); |
Andrii Kulian | 6a6c4f1 | 2018-07-16 21:23:33 -0700 | [diff] [blame] | 213 | waitForCallback(onDetachedFromWindowLatch); |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 214 | assertTrue(activity.mOnDetachedFromWindowCalled); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | /** |
| 218 | * Starts the provided activity and returns the started instance. |
| 219 | */ |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 220 | private TestActivity startTestActivity(Class<?> activityClass) throws InterruptedException { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 221 | final ActivityMonitor monitor = new ActivityMonitor(activityClass.getName(), null, false); |
| 222 | getInstrumentation().addMonitor(monitor); |
| 223 | final Context context = getInstrumentation().getContext(); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 224 | context.startActivity(new Intent(context, activityClass)); |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 225 | final TestActivity activity = (TestActivity) monitor.waitForActivityWithTimeout(1000); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 226 | if (activity == null) { |
| 227 | throw new RuntimeException("Timed out waiting for Activity"); |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 228 | } |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 229 | activity.waitForResumeStateChange(true); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 230 | return activity; |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 231 | } |
| 232 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 233 | private void registerTaskStackChangedListener(ITaskStackListener listener) throws Exception { |
| 234 | mTaskStackListener = listener; |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 235 | ActivityTaskManager.getService().registerTaskStackListener(listener); |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 236 | } |
| 237 | |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 238 | private void waitForCallback(CountDownLatch latch) { |
| 239 | try { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 240 | final boolean result = latch.await(2, TimeUnit.SECONDS); |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 241 | if (!result) { |
| 242 | throw new RuntimeException("Timed out waiting for task stack change notification"); |
| 243 | } |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 244 | } catch (InterruptedException e) { |
| 245 | } |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 246 | } |
| 247 | |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 248 | public static class TestActivity extends Activity { |
| 249 | boolean mIsResumed = false; |
| 250 | |
| 251 | @Override |
| 252 | protected void onPostResume() { |
| 253 | super.onPostResume(); |
| 254 | synchronized (this) { |
| 255 | mIsResumed = true; |
| 256 | notifyAll(); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | @Override |
| 261 | protected void onPause() { |
| 262 | super.onPause(); |
| 263 | synchronized (this) { |
| 264 | mIsResumed = false; |
| 265 | notifyAll(); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * If isResumed is {@code true}, sleep the thread until the activity is resumed. |
| 271 | * if {@code false}, sleep the thread until the activity is paused. |
| 272 | */ |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 273 | @SuppressWarnings("WaitNotInLoop") |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 274 | public void waitForResumeStateChange(boolean isResumed) throws InterruptedException { |
| 275 | synchronized (this) { |
| 276 | if (mIsResumed == isResumed) { |
| 277 | return; |
| 278 | } |
| 279 | wait(5000); |
| 280 | } |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 281 | assertEquals("The activity resume state change timed out", isResumed, mIsResumed); |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
| 285 | public static class ActivityA extends TestActivity { |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 286 | |
| 287 | private boolean mActivityBLaunched = false; |
| 288 | |
| 289 | @Override |
| 290 | protected void onPostResume() { |
| 291 | super.onPostResume(); |
| 292 | if (mActivityBLaunched) { |
| 293 | return; |
| 294 | } |
| 295 | mActivityBLaunched = true; |
| 296 | finish(); |
| 297 | startActivity(new Intent(this, ActivityB.class)); |
| 298 | } |
| 299 | } |
| 300 | |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 301 | public static class ActivityB extends TestActivity { |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 302 | |
| 303 | @Override |
| 304 | protected void onPostResume() { |
| 305 | super.onPostResume(); |
| 306 | synchronized (sLock) { |
| 307 | sTaskStackChangedCalled = false; |
| 308 | } |
| 309 | sActivityBResumed = true; |
| 310 | finish(); |
| 311 | } |
| 312 | } |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 313 | |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 314 | public static class ActivityRequestedOrientationChange extends TestActivity { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 315 | @Override |
| 316 | protected void onPostResume() { |
| 317 | super.onPostResume(); |
| 318 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| 319 | finish(); |
| 320 | } |
| 321 | } |
| 322 | |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 323 | public static class ActivityTaskDescriptionChange extends TestActivity { |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 324 | @Override |
| 325 | protected void onPostResume() { |
| 326 | super.onPostResume(); |
| 327 | setTaskDescription(new TaskDescription("Test Label")); |
| 328 | finish(); |
| 329 | } |
| 330 | } |
| 331 | |
Kazuki Takise | 9a0be72 | 2018-08-08 14:44:15 +0900 | [diff] [blame] | 332 | public static class ActivityTaskChangeCallbacks extends TestActivity { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 333 | public boolean mOnDetachedFromWindowCalled = false; |
| 334 | private CountDownLatch mOnDetachedFromWindowCountDownLatch; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 335 | |
| 336 | @Override |
| 337 | public void onDetachedFromWindow() { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 338 | mOnDetachedFromWindowCalled = true; |
| 339 | mOnDetachedFromWindowCountDownLatch.countDown(); |
Andrii Kulian | 6a6c4f1 | 2018-07-16 21:23:33 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | void setDetachedFromWindowLatch(CountDownLatch countDownLatch) { |
Tadashi G. Takaoka | 74ccec2 | 2018-10-23 11:07:13 +0900 | [diff] [blame] | 343 | mOnDetachedFromWindowCountDownLatch = countDownLatch; |
Yorke Lee | bd54c2a | 2016-10-25 13:49:23 -0700 | [diff] [blame] | 344 | } |
| 345 | } |
Jorim Jaggi | 7b61437 | 2016-09-28 15:17:50 +0200 | [diff] [blame] | 346 | } |