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

Commit eb641a70 authored by archisha's avatar archisha
Browse files

Adding ViewCaptureAwareWindowManager to WirelessChargingAnimation window.

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

Change-Id: Ib0ba7e1ec2c092f50d2768c50c90576189795ec5
parent 0ab15474
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.util.Slog;
import android.view.Gravity;
import android.view.WindowManager;

import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.surfaceeffects.ripple.RippleShader.RippleShape;
@@ -59,10 +60,11 @@ public class WirelessChargingAnimation {
     */
    private WirelessChargingAnimation(@NonNull Context context, @Nullable Looper looper,
            int transmittingBatteryLevel, int batteryLevel, Callback callback, boolean isDozing,
            RippleShape rippleShape, UiEventLogger uiEventLogger) {
            RippleShape rippleShape, UiEventLogger uiEventLogger,
            ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) {
        mCurrentWirelessChargingView = new WirelessChargingView(context, looper,
                transmittingBatteryLevel, batteryLevel, callback, isDozing,
                rippleShape, uiEventLogger);
                rippleShape, uiEventLogger, viewCaptureAwareWindowManager);
    }

    /**
@@ -73,9 +75,11 @@ public class WirelessChargingAnimation {
    public static WirelessChargingAnimation makeWirelessChargingAnimation(@NonNull Context context,
            @Nullable Looper looper, int transmittingBatteryLevel, int batteryLevel,
            Callback callback, boolean isDozing, RippleShape rippleShape,
            UiEventLogger uiEventLogger) {
            UiEventLogger uiEventLogger,
            ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) {
        return new WirelessChargingAnimation(context, looper, transmittingBatteryLevel,
                batteryLevel, callback, isDozing, rippleShape, uiEventLogger);
                batteryLevel, callback, isDozing, rippleShape, uiEventLogger,
                viewCaptureAwareWindowManager);
    }

    /**
@@ -83,10 +87,11 @@ public class WirelessChargingAnimation {
     * battery level without charging number shown.
     */
    public static WirelessChargingAnimation makeChargingAnimationWithNoBatteryLevel(
            @NonNull Context context, RippleShape rippleShape, UiEventLogger uiEventLogger) {
            @NonNull Context context, RippleShape rippleShape, UiEventLogger uiEventLogger,
            ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) {
        return makeWirelessChargingAnimation(context, null,
                UNKNOWN_BATTERY_LEVEL, UNKNOWN_BATTERY_LEVEL, null, false,
                rippleShape, uiEventLogger);
                rippleShape, uiEventLogger, viewCaptureAwareWindowManager);
    }

    /**
@@ -118,17 +123,19 @@ public class WirelessChargingAnimation {
        private int mGravity;
        private WirelessChargingLayout mView;
        private WirelessChargingLayout mNextView;
        private WindowManager mWM;
        private ViewCaptureAwareWindowManager mWM;
        private Callback mCallback;

        public WirelessChargingView(Context context, @Nullable Looper looper,
                int transmittingBatteryLevel, int batteryLevel, Callback callback,
                boolean isDozing, RippleShape rippleShape, UiEventLogger uiEventLogger) {
                boolean isDozing, RippleShape rippleShape, UiEventLogger uiEventLogger,
                ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) {
            mCallback = callback;
            mNextView = new WirelessChargingLayout(context, transmittingBatteryLevel, batteryLevel,
                    isDozing, rippleShape);
            mGravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER;
            mUiEventLogger = uiEventLogger;
            mWM = viewCaptureAwareWindowManager;

            final WindowManager.LayoutParams params = mParams;
            params.height = WindowManager.LayoutParams.MATCH_PARENT;
@@ -200,7 +207,6 @@ public class WirelessChargingAnimation {
                if (context == null) {
                    context = mView.getContext();
                }
                mWM = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
                mParams.packageName = packageName;
                mParams.hideTimeoutMilliseconds = DURATION;

+8 −2
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleRegistry;

import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.logging.MetricsLogger;
@@ -596,6 +597,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {

    private final EmergencyGestureIntentFactory mEmergencyGestureIntentFactory;

    private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager;

    /**
     * Public constructor for CentralSurfaces.
     *
@@ -708,7 +711,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
            ActivityStarter activityStarter,
            BrightnessMirrorShowingInteractor brightnessMirrorShowingInteractor,
            GlanceableHubContainerController glanceableHubContainerController,
            EmergencyGestureIntentFactory emergencyGestureIntentFactory
            EmergencyGestureIntentFactory emergencyGestureIntentFactory,
            ViewCaptureAwareWindowManager viewCaptureAwareWindowManager
    ) {
        mContext = context;
        mNotificationsController = notificationsController;
@@ -842,6 +846,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
        mLightRevealScrimViewModelLazy = lightRevealScrimViewModelLazy;
        mLightRevealScrim = lightRevealScrim;

        mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager;

        if (PredictiveBackSysUiFlag.isEnabled()) {
            mContext.getApplicationInfo().setEnableOnBackInvokedCallback(true);
        }
@@ -1683,7 +1689,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
                        mNotificationShadeWindowController.setRequestTopUi(false, TAG);
                    }
                }, /* isDozing= */ false, RippleShape.CIRCLE,
                sUiEventLogger).show(animationDelay);
                sUiEventLogger, mViewCaptureAwareWindowManager).show(animationDelay);
    }

    @Override
+4 −1
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ import android.view.WindowMetrics;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.compose.animation.scene.ObservableTransitionState;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.logging.UiEventLogger;
@@ -344,6 +345,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
    @Mock private GlanceableHubContainerController mGlanceableHubContainerController;
    @Mock private EmergencyGestureIntentFactory mEmergencyGestureIntentFactory;
    @Mock private NotificationSettingsInteractor mNotificationSettingsInteractor;
    @Mock private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager;
    private ShadeController mShadeController;
    private final FakeSystemClock mFakeSystemClock = new FakeSystemClock();
    private final FakeGlobalSettings mFakeGlobalSettings = new FakeGlobalSettings();
@@ -603,7 +605,8 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
                mActivityStarter,
                mBrightnessMirrorShowingInteractor,
                mGlanceableHubContainerController,
                mEmergencyGestureIntentFactory
                mEmergencyGestureIntentFactory,
                mViewCaptureAwareWindowManager
        );
        mScreenLifecycle.addObserver(mCentralSurfaces.mScreenObserver);
        mCentralSurfaces.initShadeVisibilityListener();