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

Commit 2562515b authored by archisha's avatar archisha
Browse files

Adding ViewCaptureAwareWindowManager to NavigationBar window.

Bug: 342100136
Flag: com.android.systemui.enable_view_capture_tracing
Test: Ran relevant unit tests locally.

Change-Id: I3054670973148f28c984e10dc19fa61bd112f8cf
parent 87ffd438
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -16,11 +16,16 @@

package com.android.systemui.navigationbar;

import static com.android.systemui.Flags.enableViewCaptureTracing;
import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;

import com.android.app.viewcapture.ViewCapture;
import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.navigationbar.NavigationBarComponent.NavigationBarScope;
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
@@ -28,6 +33,7 @@ import com.android.systemui.navigationbar.views.NavigationBarFrame;
import com.android.systemui.navigationbar.views.NavigationBarView;
import com.android.systemui.res.R;

import dagger.Lazy;
import dagger.Module;
import dagger.Provides;

@@ -73,4 +79,15 @@ public interface NavigationBarModule {
    static WindowManager provideWindowManager(@DisplayId Context context) {
        return context.getSystemService(WindowManager.class);
    }

    /** A ViewCaptureAwareWindowManager specific to the display's context. */
    @Provides
    @NavigationBarScope
    @DisplayId
    static ViewCaptureAwareWindowManager provideViewCaptureAwareWindowManager(
            @DisplayId WindowManager windowManager, Lazy<ViewCapture> daggerLazyViewCapture) {
        return new ViewCaptureAwareWindowManager(windowManager,
                /* lazyViewCapture= */ toKotlinLazy(daggerLazyViewCapture),
                /* isViewCaptureEnabled= */ enableViewCaptureTracing());
    }
}
+8 −4
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ import android.view.inputmethod.InputMethodManager;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEvent;
@@ -196,6 +197,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
    private final Context mContext;
    private final Bundle mSavedState;
    private final WindowManager mWindowManager;
    private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager;
    private final AccessibilityManager mAccessibilityManager;
    private final DeviceProvisionedController mDeviceProvisionedController;
    private final StatusBarStateController mStatusBarStateController;
@@ -556,6 +558,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            @Nullable Bundle savedState,
            @DisplayId Context context,
            @DisplayId WindowManager windowManager,
            @DisplayId ViewCaptureAwareWindowManager viewCaptureAwareWindowManager,
            Lazy<AssistManager> assistManagerLazy,
            AccessibilityManager accessibilityManager,
            DeviceProvisionedController deviceProvisionedController,
@@ -601,6 +604,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        mContext = context;
        mSavedState = savedState;
        mWindowManager = windowManager;
        mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager;
        mAccessibilityManager = accessibilityManager;
        mDeviceProvisionedController = deviceProvisionedController;
        mStatusBarStateController = statusBarStateController;
@@ -721,7 +725,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements

        if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mView);

        mWindowManager.addView(mFrame,
        mViewCaptureAwareWindowManager.addView(mFrame,
                getBarLayoutParams(mContext.getResources().getConfiguration().windowConfiguration
                        .getRotation()));
        mDisplayId = mContext.getDisplayId();
@@ -764,7 +768,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            mCommandQueue.removeCallback(this);
            Trace.beginSection("NavigationBar#removeViewImmediate");
            try {
                mWindowManager.removeViewImmediate(mView.getRootView());
                mViewCaptureAwareWindowManager.removeViewImmediate(mView.getRootView());
            } finally {
                Trace.endSection();
            }
@@ -866,7 +870,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        if (mOrientationHandle != null) {
            resetSecondaryHandle();
            getBarTransitions().removeDarkIntensityListener(mOrientationHandleIntensityListener);
            mWindowManager.removeView(mOrientationHandle);
            mViewCaptureAwareWindowManager.removeView(mOrientationHandle);
            mOrientationHandle.getViewTreeObserver().removeOnGlobalLayoutListener(
                    mOrientationHandleGlobalLayoutListener);
        }
@@ -937,7 +941,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        mOrientationParams.setTitle("SecondaryHomeHandle" + mContext.getDisplayId());
        mOrientationParams.privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION
                | WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
        mWindowManager.addView(mOrientationHandle, mOrientationParams);
        mViewCaptureAwareWindowManager.addView(mOrientationHandle, mOrientationParams);
        mOrientationHandle.setVisibility(View.GONE);

        logNavbarOrientation("initSecondaryHomeHandleForRotation");
+4 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import android.view.inputmethod.InputMethodManager;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.SysuiTestCase;
@@ -215,6 +216,8 @@ public class NavigationBarTest extends SysuiTestCase {
    @Mock
    private WindowManager mWindowManager;
    @Mock
    private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager;
    @Mock
    private TelecomManager mTelecomManager;
    @Mock
    private InputMethodManager mInputMethodManager;
@@ -620,6 +623,7 @@ public class NavigationBarTest extends SysuiTestCase {
                null,
                context,
                mWindowManager,
                mViewCaptureAwareWindowManager,
                () -> mAssistManager,
                mock(AccessibilityManager.class),
                deviceProvisionedController,