Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f2919ec authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Remove permissions for SCVH test." into main

parents 5270dab9 1e2477c4
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -16,10 +16,8 @@

package com.android.server.wm;

import static android.Manifest.permission.ACCESS_SURFACE_FLINGER;
import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
import static android.server.wm.CtsWindowInfoUtils.waitForWindowVisible;
import static android.server.wm.CtsWindowInfoUtils.waitForWindowFocus;
import static android.server.wm.CtsWindowInfoUtils.waitForWindowVisible;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;

import static org.junit.Assert.assertTrue;
@@ -78,17 +76,11 @@ public class SurfaceControlViewHostTests {
    @Before
    public void setUp() throws Exception {
        mInstrumentation = InstrumentationRegistry.getInstrumentation();

        // ACCESS_SURFACE_FLINGER is necessary to call waitForWindow
        // INTERNAL_SYSTEM_WINDOW is necessary to add SCVH with no host parent
        mInstrumentation.getUiAutomation().adoptShellPermissionIdentity(ACCESS_SURFACE_FLINGER,
                INTERNAL_SYSTEM_WINDOW);
        mActivity = mActivityRule.launchActivity(null);
    }

    @After
    public void tearDown() {
        mInstrumentation.getUiAutomation().dropShellPermissionIdentity();
        CommonUtils.waitUntilActivityRemoved(mActivity);
    }

@@ -102,14 +94,15 @@ public class SurfaceControlViewHostTests {
        mView2 = new Button(mActivity);

        mInstrumentation.runOnMainSync(() -> {
            TestWindowlessWindowManager wwm = new TestWindowlessWindowManager(
                    mActivity.getResources().getConfiguration(), sc, null);

            try {
                mActivity.attachToSurfaceView(sc);
            } catch (InterruptedException e) {
            }

            TestWindowlessWindowManager wwm = new TestWindowlessWindowManager(
                    mActivity.getResources().getConfiguration(), sc,
                    mActivity.mSurfaceView.getHostToken());

            mScvh1 = new SurfaceControlViewHost(mActivity, mActivity.getDisplay(),
                    wwm, "requestFocusWithMultipleWindows");
            mScvh2 = new SurfaceControlViewHost(mActivity, mActivity.getDisplay(),
@@ -130,11 +123,13 @@ public class SurfaceControlViewHostTests {
        assertTrue("Failed to wait for view1", waitForWindowVisible(mView1));
        assertTrue("Failed to wait for view2", waitForWindowVisible(mView2));

        WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(null /* window */,
        IWindow window = IWindow.Stub.asInterface(mActivity.mSurfaceView.getWindowToken());

        WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(window,
                mScvh1.getFocusGrantToken(), true);
        assertTrue("Failed to gain focus for view1", waitForWindowFocus(mView1, true));

        WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(null /* window */,
        WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(window,
                mScvh2.getFocusGrantToken(), true);
        assertTrue("Failed to gain focus for view2", waitForWindowFocus(mView2, true));
    }