Loading packages/SystemUI/tests/AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ <uses-permission android:name="android.permission.USE_FINGERPRINT" /> <uses-permission android:name="android.permission.DEVICE_POWER" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.STATUS_BAR" /> <uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" /> <uses-permission android:name="android.permission.REAL_GET_TASKS" /> <application> <uses-library android:name="android.test.runner" /> Loading packages/SystemUI/tests/src/com/android/systemui/SysuiTestCase.java +13 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.MessageQueue; import android.os.ParcelFileDescriptor; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.testing.LeakCheck; Loading @@ -34,6 +35,8 @@ import org.junit.Rule; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.io.FileInputStream; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; Loading Loading @@ -84,6 +87,16 @@ public abstract class SysuiTestCase { return mContext; } protected void runShellCommand(String command) throws IOException { ParcelFileDescriptor pfd = mRealInstrumentation.getUiAutomation() .executeShellCommand(command); // Read the input stream fully. FileInputStream fis = new ParcelFileDescriptor.AutoCloseInputStream(pfd); while (fis.read() != -1); fis.close(); } protected void waitForIdleSync() { if (mHandler == null) { mHandler = new Handler(Looper.getMainLooper()); Loading packages/SystemUI/tests/src/com/android/systemui/recents/RecentsTest.java 0 → 100644 +69 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.recents; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static com.android.systemui.recents.RecentsImpl.RECENTS_ACTIVITY; import static com.android.systemui.recents.RecentsImpl.RECENTS_PACKAGE; import static org.junit.Assert.fail; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.app.IActivityManager; import android.os.SystemClock; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import com.android.systemui.SysuiTestCase; import org.junit.Test; import org.junit.runner.RunWith; import java.util.List; @RunWith(AndroidJUnit4.class) @MediumTest public class RecentsTest extends SysuiTestCase { @Test public void testRecentsActivityType() throws Exception { // Clear the state final IActivityManager am = ActivityManager.getService(); am.removeStacksWithActivityTypes(new int[] { ACTIVITY_TYPE_RECENTS }); // Toggle recents, use a shell command because it is not exported runShellCommand("am start -n " + RECENTS_PACKAGE + "/" + RECENTS_ACTIVITY); // Verify that an activity was launched with the right activity type int retryCount = 0; while (retryCount < 10) { List<RunningTaskInfo> tasks = am.getTasks(Integer.MAX_VALUE); for (RunningTaskInfo info : tasks) { if (info.configuration.windowConfiguration.getActivityType() == ACTIVITY_TYPE_RECENTS) { // Found a recents activity with the right activity type return; } } SystemClock.sleep(50); retryCount++; } fail("Expected Recents activity with ACTIVITY_TYPE_RECENTS"); } } No newline at end of file services/core/java/com/android/server/am/ActivityRecord.java +4 −1 Original line number Diff line number Diff line Loading @@ -201,6 +201,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo private static final String TAG_STATES = TAG + POSTFIX_STATES; private static final String TAG_SWITCH = TAG + POSTFIX_SWITCH; private static final String TAG_VISIBILITY = TAG + POSTFIX_VISIBILITY; // TODO(b/67864419): Remove once recents component is overridden private static final String LEGACY_RECENTS_PACKAGE_NAME = "com.android.systemui.recents"; private static final boolean SHOW_ACTIVITY_START_TIME = true; Loading Loading @@ -1057,7 +1059,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo // We only allow home activities to be resizeable if they explicitly requested it. info.resizeMode = RESIZE_MODE_UNRESIZEABLE; } } else if (service.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) { } else if (realActivity.getClassName().contains(LEGACY_RECENTS_PACKAGE_NAME) || service.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) { activityType = ACTIVITY_TYPE_RECENTS; } else if (options != null && options.getLaunchActivityType() == ACTIVITY_TYPE_ASSISTANT && canLaunchAssistActivity(launchedFromPackage)) { Loading Loading
packages/SystemUI/tests/AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ <uses-permission android:name="android.permission.USE_FINGERPRINT" /> <uses-permission android:name="android.permission.DEVICE_POWER" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.STATUS_BAR" /> <uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" /> <uses-permission android:name="android.permission.REAL_GET_TASKS" /> <application> <uses-library android:name="android.test.runner" /> Loading
packages/SystemUI/tests/src/com/android/systemui/SysuiTestCase.java +13 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.MessageQueue; import android.os.ParcelFileDescriptor; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.testing.LeakCheck; Loading @@ -34,6 +35,8 @@ import org.junit.Rule; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.io.FileInputStream; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; Loading Loading @@ -84,6 +87,16 @@ public abstract class SysuiTestCase { return mContext; } protected void runShellCommand(String command) throws IOException { ParcelFileDescriptor pfd = mRealInstrumentation.getUiAutomation() .executeShellCommand(command); // Read the input stream fully. FileInputStream fis = new ParcelFileDescriptor.AutoCloseInputStream(pfd); while (fis.read() != -1); fis.close(); } protected void waitForIdleSync() { if (mHandler == null) { mHandler = new Handler(Looper.getMainLooper()); Loading
packages/SystemUI/tests/src/com/android/systemui/recents/RecentsTest.java 0 → 100644 +69 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.recents; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static com.android.systemui.recents.RecentsImpl.RECENTS_ACTIVITY; import static com.android.systemui.recents.RecentsImpl.RECENTS_PACKAGE; import static org.junit.Assert.fail; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.app.IActivityManager; import android.os.SystemClock; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import com.android.systemui.SysuiTestCase; import org.junit.Test; import org.junit.runner.RunWith; import java.util.List; @RunWith(AndroidJUnit4.class) @MediumTest public class RecentsTest extends SysuiTestCase { @Test public void testRecentsActivityType() throws Exception { // Clear the state final IActivityManager am = ActivityManager.getService(); am.removeStacksWithActivityTypes(new int[] { ACTIVITY_TYPE_RECENTS }); // Toggle recents, use a shell command because it is not exported runShellCommand("am start -n " + RECENTS_PACKAGE + "/" + RECENTS_ACTIVITY); // Verify that an activity was launched with the right activity type int retryCount = 0; while (retryCount < 10) { List<RunningTaskInfo> tasks = am.getTasks(Integer.MAX_VALUE); for (RunningTaskInfo info : tasks) { if (info.configuration.windowConfiguration.getActivityType() == ACTIVITY_TYPE_RECENTS) { // Found a recents activity with the right activity type return; } } SystemClock.sleep(50); retryCount++; } fail("Expected Recents activity with ACTIVITY_TYPE_RECENTS"); } } No newline at end of file
services/core/java/com/android/server/am/ActivityRecord.java +4 −1 Original line number Diff line number Diff line Loading @@ -201,6 +201,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo private static final String TAG_STATES = TAG + POSTFIX_STATES; private static final String TAG_SWITCH = TAG + POSTFIX_SWITCH; private static final String TAG_VISIBILITY = TAG + POSTFIX_VISIBILITY; // TODO(b/67864419): Remove once recents component is overridden private static final String LEGACY_RECENTS_PACKAGE_NAME = "com.android.systemui.recents"; private static final boolean SHOW_ACTIVITY_START_TIME = true; Loading Loading @@ -1057,7 +1059,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo // We only allow home activities to be resizeable if they explicitly requested it. info.resizeMode = RESIZE_MODE_UNRESIZEABLE; } } else if (service.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) { } else if (realActivity.getClassName().contains(LEGACY_RECENTS_PACKAGE_NAME) || service.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) { activityType = ACTIVITY_TYPE_RECENTS; } else if (options != null && options.getLaunchActivityType() == ACTIVITY_TYPE_ASSISTANT && canLaunchAssistActivity(launchedFromPackage)) { Loading