summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Tufvesson <lus@google.com>2020-04-02 13:47:14 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-04-02 13:47:14 +0000
commit8bda847980ce6e284e9548da01e2cd2f1f4b07a3 (patch)
tree168f44d5151c334558fcb19603c95de3b8cc39e1
parent8c2d594e2d5d51da464ab65cfbf957dd108584e3 (diff)
parent668291193b0cf7726c9cb163d3331b6102337314 (diff)
downloadcts-8bda847980ce6e284e9548da01e2cd2f1f4b07a3.tar.gz
RESTRICT AUTOMERGE am: 668291193b
Change-Id: Ice67cae1323d9ed42df6ad321a47758f6da9d5d7
-rwxr-xr-xtests/framework/base/windowmanager/app/AndroidManifest.xml3
-rw-r--r--tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java7
-rw-r--r--tests/framework/base/windowmanager/app/src/android/server/wm/app/PresentationActivity.java62
-rw-r--r--tests/framework/base/windowmanager/src/android/server/wm/PresentationTest.java106
4 files changed, 1 insertions, 177 deletions
diff --git a/tests/framework/base/windowmanager/app/AndroidManifest.xml b/tests/framework/base/windowmanager/app/AndroidManifest.xml
index 29257a9d45e..67cafd479b1 100755
--- a/tests/framework/base/windowmanager/app/AndroidManifest.xml
+++ b/tests/framework/base/windowmanager/app/AndroidManifest.xml
@@ -536,9 +536,6 @@
<receiver
android:name=".ToastReceiver"
android:exported="true" />
- <activity
- android:name=".PresentationActivity"
- android:exported="true" />
</application>
</manifest>
diff --git a/tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java b/tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java
index 27e11897cf3..734b482220e 100644
--- a/tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java
+++ b/tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java
@@ -17,8 +17,8 @@
package android.server.wm.app;
import android.content.ComponentName;
-import android.server.wm.TestJournalProvider;
import android.server.wm.component.ComponentsBase;
+import android.server.wm.TestJournalProvider;
public class Components extends ComponentsBase {
public static final ComponentName ALT_LAUNCHING_ACTIVITY = component("AltLaunchingActivity");
@@ -73,7 +73,6 @@ public class Components extends ComponentsBase {
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 =
@@ -422,10 +421,6 @@ public class Components extends ComponentsBase {
public static final String ACTION_TOAST_TAP_DETECTED = "toast_tap_detected";
}
- 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/windowmanager/app/src/android/server/wm/app/PresentationActivity.java b/tests/framework/base/windowmanager/app/src/android/server/wm/app/PresentationActivity.java
deleted file mode 100644
index fc5490ecd98..00000000000
--- a/tests/framework/base/windowmanager/app/src/android/server/wm/app/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.wm.app;
-
-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/windowmanager/src/android/server/wm/PresentationTest.java b/tests/framework/base/windowmanager/src/android/server/wm/PresentationTest.java
deleted file mode 100644
index 4f300c2551b..00000000000
--- a/tests/framework/base/windowmanager/src/android/server/wm/PresentationTest.java
+++ /dev/null
@@ -1,106 +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.wm;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Intent;
-import android.hardware.display.DisplayManager;
-import android.platform.test.annotations.Presubmit;
-import android.server.wm.app.Components;
-import android.view.Display;
-
-import org.junit.Test;
-
-import java.util.List;
-
-@Presubmit
-public class PresentationTest extends MultiDisplayTestBase {
-
- // 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);
- assertThat(presentationWindows).isEmpty();
- }
-
- private void assertPresentationOnDisplay(int displayId) {
- final List<WindowManagerState.WindowState> presentationWindows =
- mAmWmState.getWmState()
- .getWindowsByPackageName(
- Components.PRESENTATION_ACTIVITY.getPackageName(), TYPE_PRESENTATION);
- assertThat(presentationWindows).hasSize(1);
- WindowManagerState.WindowState presentationWindowState = presentationWindows.get(0);
- assertThat(presentationWindowState.getDisplayId()).isEqualTo(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");
- }
-}