RESTRICT AUTOMERGE
Revert submission 10446362-type-presentation-p
Reason for revert: Breaks apps using Presentation in combination with private virtual displays
Reverted Changes:
I2aaab1903:RESTRICT AUTOMERGE Block TYPE_PRESENTATION windows...
Ib5a24f8be:RESTRICT AUTOMERGE Add test for Presentation
Bug: 141745510
Change-Id: Iabb838c6a280e3cb4f41e4972921ec09a5aba287
diff --git a/tests/framework/base/activitymanager/app/AndroidManifest.xml b/tests/framework/base/activitymanager/app/AndroidManifest.xml
index 58a30a0..b787a31 100755
--- a/tests/framework/base/activitymanager/app/AndroidManifest.xml
+++ b/tests/framework/base/activitymanager/app/AndroidManifest.xml
@@ -419,9 +419,6 @@
<receiver
android:name=".ToastReceiver"
android:exported="true" />
- <activity
- android:name=".PresentationActivity"
- android:exported="true" />
</application>
</manifest>
diff --git a/tests/framework/base/activitymanager/app/src/android/server/am/Components.java b/tests/framework/base/activitymanager/app/src/android/server/am/Components.java
index 7377031..a02fe85 100644
--- a/tests/framework/base/activitymanager/app/src/android/server/am/Components.java
+++ b/tests/framework/base/activitymanager/app/src/android/server/am/Components.java
@@ -68,7 +68,6 @@
public static final ComponentName NO_HISTORY_ACTIVITY = component("NoHistoryActivity");
public static final ComponentName NO_RELAUNCH_ACTIVITY = component("NoRelaunchActivity");
public static final ComponentName NON_RESIZEABLE_ACTIVITY = component("NonResizeableActivity");
- public static final ComponentName PRESENTATION_ACTIVITY = component("PresentationActivity");
public static final ComponentName PIP_ACTIVITY = component("PipActivity");
public static final ComponentName PIP_ACTIVITY2 = component("PipActivity2");
public static final ComponentName PIP_ACTIVITY_WITH_SAME_AFFINITY =
@@ -329,17 +328,12 @@
public static final String KEY_LAUNCH_TARGET_COMPONENT = "launch_target_component";
public static final String KEY_PUBLIC_DISPLAY = "public_display";
public static final String KEY_RESIZE_DISPLAY = "resize_display";
- public static final String KEY_PRESENTATION_DISPLAY = "presentation_display";
// Value constants of {@link #KEY_COMMAND}.
public static final String COMMAND_CREATE_DISPLAY = "create_display";
public static final String COMMAND_DESTROY_DISPLAY = "destroy_display";
public static final String COMMAND_RESIZE_DISPLAY = "resize_display";
}
- public static class PresentationActivity {
- public static final String KEY_DISPLAY_ID = "display_id";
- }
-
private static ComponentName component(String className) {
return component(Components.class, className);
}
diff --git a/tests/framework/base/activitymanager/app/src/android/server/am/PresentationActivity.java b/tests/framework/base/activitymanager/app/src/android/server/am/PresentationActivity.java
deleted file mode 100644
index 0036aaf..0000000
--- a/tests/framework/base/activitymanager/app/src/android/server/am/PresentationActivity.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2020 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 android.server.am;
-
-import android.app.Activity;
-import android.app.Presentation;
-import android.graphics.Color;
-import android.hardware.display.DisplayManager;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Display;
-import android.view.Gravity;
-import android.view.WindowManager;
-import android.widget.TextView;
-
-public class PresentationActivity extends Activity {
-
- private static final String TAG = PresentationActivity.class.getSimpleName();
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- int displayId = getIntent().getExtras().getInt(
- Components.PresentationActivity.KEY_DISPLAY_ID);
-
- Display presentationDisplay =
- getSystemService(DisplayManager.class).getDisplay(displayId);
-
- createPresentationWindow(presentationDisplay);
- }
-
- private void createPresentationWindow(Display display) {
- final TextView view = new TextView(this);
- view.setText("I'm a presentation");
- view.setGravity(Gravity.CENTER);
- view.setBackgroundColor(Color.RED);
-
- final Presentation presentation = new Presentation(this, display);
- presentation.setContentView(view);
- presentation.setTitle(getPackageName());
- try {
- presentation.show();
- } catch (WindowManager.InvalidDisplayException e) {
- Log.w(TAG, "Presentation blocked", e);
- }
- }
-}
diff --git a/tests/framework/base/activitymanager/app/src/android/server/am/VirtualDisplayActivity.java b/tests/framework/base/activitymanager/app/src/android/server/am/VirtualDisplayActivity.java
index 2d02733..8b1cdb1 100644
--- a/tests/framework/base/activitymanager/app/src/android/server/am/VirtualDisplayActivity.java
+++ b/tests/framework/base/activitymanager/app/src/android/server/am/VirtualDisplayActivity.java
@@ -17,7 +17,6 @@
package android.server.am;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY;
-import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
import static android.server.am.ActivityLauncher.KEY_DISPLAY_ID;
import static android.server.am.ActivityLauncher.KEY_LAUNCH_ACTIVITY;
@@ -31,7 +30,6 @@
import static android.server.am.Components.VirtualDisplayActivity.KEY_COUNT;
import static android.server.am.Components.VirtualDisplayActivity.KEY_DENSITY_DPI;
import static android.server.am.Components.VirtualDisplayActivity.KEY_LAUNCH_TARGET_COMPONENT;
-import static android.server.am.Components.VirtualDisplayActivity.KEY_PRESENTATION_DISPLAY;
import static android.server.am.Components.VirtualDisplayActivity.KEY_PUBLIC_DISPLAY;
import static android.server.am.Components.VirtualDisplayActivity.KEY_RESIZE_DISPLAY;
import static android.server.am.Components.VirtualDisplayActivity.VIRTUAL_DISPLAY_PREFIX;
@@ -187,11 +185,6 @@
flags |= VIRTUAL_DISPLAY_FLAG_PUBLIC | VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY;
}
- final boolean presentationDisplay = entry.extras.getBoolean(KEY_PRESENTATION_DISPLAY);
- if (presentationDisplay) {
- flags |= VIRTUAL_DISPLAY_FLAG_PRESENTATION;
- }
-
Log.d(TAG, "createVirtualDisplay: " + width + "x" + height + ", dpi: "
+ densityDpi + ", canShowWithInsecureKeyguard=" + canShowWithInsecureKeyguard
+ ", publicDisplay=" + publicDisplay);
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerDisplayTestBase.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerDisplayTestBase.java
index 77ba78d..a82ae2d 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerDisplayTestBase.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerDisplayTestBase.java
@@ -28,7 +28,6 @@
import static android.server.am.Components.VirtualDisplayActivity.KEY_COUNT;
import static android.server.am.Components.VirtualDisplayActivity.KEY_DENSITY_DPI;
import static android.server.am.Components.VirtualDisplayActivity.KEY_LAUNCH_TARGET_COMPONENT;
-import static android.server.am.Components.VirtualDisplayActivity.KEY_PRESENTATION_DISPLAY;
import static android.server.am.Components.VirtualDisplayActivity.KEY_PUBLIC_DISPLAY;
import static android.server.am.Components.VirtualDisplayActivity.KEY_RESIZE_DISPLAY;
import static android.server.am.Components.VirtualDisplayActivity.VIRTUAL_DISPLAY_PREFIX;
@@ -213,7 +212,6 @@
private boolean mCanShowWithInsecureKeyguard = false;
private boolean mPublicDisplay = false;
private boolean mResizeDisplay = true;
- private boolean mPresentationDisplay = false;
private ComponentName mLaunchActivity = null;
private boolean mSimulateDisplay = false;
private boolean mMustBeCreated = true;
@@ -247,11 +245,6 @@
return this;
}
- VirtualDisplaySession setPresentationDisplay(boolean presentationDisplay) {
- mPresentationDisplay = presentationDisplay;
- return this;
- }
-
VirtualDisplaySession setLaunchActivity(ComponentName launchActivity) {
mLaunchActivity = launchActivity;
return this;
@@ -360,8 +353,7 @@
.append(" --ez " + KEY_CAN_SHOW_WITH_INSECURE_KEYGUARD + " ")
.append(mCanShowWithInsecureKeyguard)
.append(" --ez " + KEY_PUBLIC_DISPLAY + " ").append(mPublicDisplay)
- .append(" --ez " + KEY_RESIZE_DISPLAY + " ").append(mResizeDisplay)
- .append(" --ez " + KEY_PRESENTATION_DISPLAY + " ").append(mPresentationDisplay);
+ .append(" --ez " + KEY_RESIZE_DISPLAY + " ").append(mResizeDisplay);
if (mLaunchActivity != null) {
createVirtualDisplayCommand
.append(" --es " + KEY_LAUNCH_TARGET_COMPONENT + " ")
diff --git a/tests/framework/base/activitymanager/src/android/server/am/PresentationTest.java b/tests/framework/base/activitymanager/src/android/server/am/PresentationTest.java
deleted file mode 100644
index b7ead09..0000000
--- a/tests/framework/base/activitymanager/src/android/server/am/PresentationTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2020 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 android.server.am;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-import android.content.Intent;
-import android.hardware.display.DisplayManager;
-import android.platform.test.annotations.Presubmit;
-import android.server.am.Components;
-import android.server.am.ActivityManagerState.ActivityDisplay;
-import android.view.Display;
-
-import org.junit.Test;
-
-import java.util.List;
-
-@Presubmit
-public class PresentationTest extends ActivityManagerDisplayTestBase {
-
- // WindowManager.LayoutParams.TYPE_PRESENTATION
- private static final int TYPE_PRESENTATION = 2037;
-
- @Test
- public void testPresentationFollowsDisplayFlag() {
- DisplayManager displayManager = mContext.getSystemService(DisplayManager.class);
- for (Display display : displayManager.getDisplays()) {
- launchPresentationActivity(display.getDisplayId());
- if ((display.getFlags() & Display.FLAG_PRESENTATION) != Display.FLAG_PRESENTATION) {
- assertNoPresentationDisplayed();
- } else {
- assertPresentationOnDisplay(display.getDisplayId());
- }
- }
- }
-
- @Test
- public void testPresentationAllowedOnPresentationDisplay() throws Exception {
- try (final VirtualDisplaySession virtualDisplaySession = new VirtualDisplaySession()) {
- ActivityManagerState.ActivityDisplay display =
- virtualDisplaySession
- .setPresentationDisplay(true)
- .setPublicDisplay(true)
- .createDisplay();
-
- launchPresentationActivity(display.mId);
- assertPresentationOnDisplay(display.mId);
- }
- }
-
- @Test
- public void testPresentationBlockedOnNonPresentationDisplay() throws Exception {
- try(final VirtualDisplaySession virtualDisplaySession = new VirtualDisplaySession()) {
- ActivityManagerState.ActivityDisplay display =
- virtualDisplaySession
- .setPresentationDisplay(false)
- .createDisplay();
-
- launchPresentationActivity(display.mId);
- assertNoPresentationDisplayed();
- }
- }
-
- private void assertNoPresentationDisplayed() {
- final List<WindowManagerState.WindowState> presentationWindows =
- mAmWmState.getWmState()
- .getWindowsByPackageName(
- Components.PRESENTATION_ACTIVITY.getPackageName(), TYPE_PRESENTATION);
- assertTrue(presentationWindows.isEmpty());
- }
-
- private void assertPresentationOnDisplay(int displayId) {
- final List<WindowManagerState.WindowState> presentationWindows =
- mAmWmState.getWmState()
- .getWindowsByPackageName(
- Components.PRESENTATION_ACTIVITY.getPackageName(), TYPE_PRESENTATION);
- assertEquals(presentationWindows.size(), 1);
- WindowManagerState.WindowState presentationWindowState = presentationWindows.get(0);
- assertEquals(presentationWindowState.getDisplayId(), displayId);
- }
-
- private void launchPresentationActivity(int displayId) {
- Intent intent = new Intent();
- intent.setComponent(Components.PRESENTATION_ACTIVITY);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(Components.PresentationActivity.KEY_DISPLAY_ID, displayId);
- mContext.startActivity(intent);
- waitAndAssertTopResumedActivity(
- Components.PRESENTATION_ACTIVITY,
- Display.DEFAULT_DISPLAY,
- "Launched activity must be on top");
- }
-}
diff --git a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
index bc9eec1..192a1ac 100644
--- a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
+++ b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
@@ -68,7 +68,6 @@
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -530,28 +529,6 @@
return mContext.getResources().getConfiguration().smallestScreenWidthDp >= 600;
}
- public void waitAndAssertTopResumedActivity(ComponentName activityName, int displayId,
- String message) {
- mAmWmState.waitForValidState(activityName);
- mAmWmState.waitForActivityState(activityName, STATE_RESUMED);
- final String activityClassName = getActivityName(activityName);
- mAmWmState.waitForWithAmState(state ->
- activityClassName.equals(state.getFocusedActivity()),
- "Waiting for activity to be on top");
-
- mAmWmState.assertSanity();
- mAmWmState.assertFocusedActivity(message, activityName);
- assertTrue("Activity must be resumed",
- mAmWmState.getAmState().hasActivityState(activityName, STATE_RESUMED));
- final int frontStackId = mAmWmState.getAmState().getFrontStackId(displayId);
- ActivityManagerState.ActivityStack frontStackOnDisplay =
- mAmWmState.getAmState().getStackById(frontStackId);
- assertEquals("Resumed activity of front stack of the target display must match. " + message,
- activityClassName, frontStackOnDisplay.mResumedActivity);
- mAmWmState.assertFocusedStack("Top activity's stack must also be on top", frontStackId);
- mAmWmState.assertVisibility(activityName, true /* visible */);
- }
-
// TODO: Switch to using a feature flag, when available.
protected static boolean isUiModeLockedToVrHeadset() {
final String output = runCommandAndPrintOutput("dumpsys uimode");