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

Commit 7f93443c authored by Archisha Baranwal's avatar Archisha Baranwal Committed by Android (Google) Code Review
Browse files

Merge "Adding ViewCaptureAwareWindowManager to WirelessChargingAnimation window." into main

parents 0673f3f7 eb641a70
Loading
Loading
Loading
Loading
+15 −9
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.util.Slog;
import android.view.Gravity;
import android.view.Gravity;
import android.view.WindowManager;
import android.view.WindowManager;


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


    /**
    /**
@@ -73,9 +75,11 @@ public class WirelessChargingAnimation {
    public static WirelessChargingAnimation makeWirelessChargingAnimation(@NonNull Context context,
    public static WirelessChargingAnimation makeWirelessChargingAnimation(@NonNull Context context,
            @Nullable Looper looper, int transmittingBatteryLevel, int batteryLevel,
            @Nullable Looper looper, int transmittingBatteryLevel, int batteryLevel,
            Callback callback, boolean isDozing, RippleShape rippleShape,
            Callback callback, boolean isDozing, RippleShape rippleShape,
            UiEventLogger uiEventLogger) {
            UiEventLogger uiEventLogger,
            ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) {
        return new WirelessChargingAnimation(context, looper, transmittingBatteryLevel,
        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.
     * battery level without charging number shown.
     */
     */
    public static WirelessChargingAnimation makeChargingAnimationWithNoBatteryLevel(
    public static WirelessChargingAnimation makeChargingAnimationWithNoBatteryLevel(
            @NonNull Context context, RippleShape rippleShape, UiEventLogger uiEventLogger) {
            @NonNull Context context, RippleShape rippleShape, UiEventLogger uiEventLogger,
            ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) {
        return makeWirelessChargingAnimation(context, null,
        return makeWirelessChargingAnimation(context, null,
                UNKNOWN_BATTERY_LEVEL, UNKNOWN_BATTERY_LEVEL, null, false,
                UNKNOWN_BATTERY_LEVEL, UNKNOWN_BATTERY_LEVEL, null, false,
                rippleShape, uiEventLogger);
                rippleShape, uiEventLogger, viewCaptureAwareWindowManager);
    }
    }


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


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


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


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


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


    private final EmergencyGestureIntentFactory mEmergencyGestureIntentFactory;
    private final EmergencyGestureIntentFactory mEmergencyGestureIntentFactory;


    private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager;

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


        mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager;

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


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


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