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

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

Merge "Adding ViewCaptureAwareWindowManager to InattentiveSleepWarningView window." into main

parents aa960910 cb5f9c2d
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.power;

import static com.android.systemui.Flags.enableViewCaptureTracing;

import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
@@ -29,21 +31,27 @@ import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.android.app.viewcapture.ViewCapture;
import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.systemui.res.R;

import kotlin.Lazy;

/**
 * View that shows a warning shortly before the device goes into sleep
 * after prolonged user inactivity when bound to.
 */
public class InattentiveSleepWarningView extends FrameLayout {
    private final IBinder mWindowToken = new Binder();
    private final WindowManager mWindowManager;
    private final ViewCaptureAwareWindowManager mWindowManager;
    private Animator mFadeOutAnimator;
    private boolean mDismissing;

    InattentiveSleepWarningView(Context context) {
    InattentiveSleepWarningView(Context context, Lazy<ViewCapture> lazyViewCapture) {
        super(context);
        mWindowManager = mContext.getSystemService(WindowManager.class);
        WindowManager wm = mContext.getSystemService(WindowManager.class);
        mWindowManager = new ViewCaptureAwareWindowManager(wm, lazyViewCapture,
                enableViewCaptureTracing());

        final LayoutInflater layoutInflater = LayoutInflater.from(mContext);
        layoutInflater.inflate(R.layout.inattentive_sleep_warning, this, true /* attachToRoot */);
+10 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.power;

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

import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -44,6 +46,7 @@ import android.util.Slog;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.app.viewcapture.ViewCapture;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.fuelgauge.Estimate;
import com.android.settingslib.utils.ThreadUtils;
@@ -56,6 +59,8 @@ import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.policy.ConfigurationController;

import kotlin.Lazy;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.concurrent.Future;
@@ -117,6 +122,7 @@ public class PowerUI implements
    private final Context mContext;
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final CommandQueue mCommandQueue;
    private final Lazy<ViewCapture> mLazyViewCapture;
    @Nullable
    private final IVrManager mVrManager;
    private final WakefulnessLifecycle.Observer mWakefulnessObserver =
@@ -157,7 +163,8 @@ public class PowerUI implements
            EnhancedEstimates enhancedEstimates,
            WakefulnessLifecycle wakefulnessLifecycle,
            PowerManager powerManager,
            UserTracker userTracker) {
            UserTracker userTracker,
            dagger.Lazy<ViewCapture> daggerLazyViewCapture) {
        mContext = context;
        mBroadcastDispatcher = broadcastDispatcher;
        mCommandQueue = commandQueue;
@@ -167,6 +174,7 @@ public class PowerUI implements
        mPowerManager = powerManager;
        mWakefulnessLifecycle = wakefulnessLifecycle;
        mUserTracker = userTracker;
        mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture);
    }

    public void start() {
@@ -641,7 +649,7 @@ public class PowerUI implements
    @Override
    public void showInattentiveSleepWarning() {
        if (mOverlayView == null) {
            mOverlayView = new InattentiveSleepWarningView(mContext);
            mOverlayView = new InattentiveSleepWarningView(mContext, mLazyViewCapture);
        }

        mOverlayView.show();
+6 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.testing.TestableResources;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.app.viewcapture.ViewCapture;
import com.android.settingslib.fuelgauge.Estimate;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
@@ -54,6 +55,8 @@ import com.android.systemui.res.R;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.CommandQueue;

import dagger.Lazy;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -94,6 +97,7 @@ public class PowerUITest extends SysuiTestCase {
    @Mock private BroadcastDispatcher mBroadcastDispatcher;
    @Mock private CommandQueue mCommandQueue;
    @Mock private IVrManager mVrManager;
    @Mock private Lazy<ViewCapture> mLazyViewCapture;

    @Before
    public void setup() {
@@ -705,7 +709,8 @@ public class PowerUITest extends SysuiTestCase {
                mEnhancedEstimates,
                mWakefulnessLifecycle,
                mPowerManager,
                mUserTracker);
                mUserTracker,
                mLazyViewCapture);
        mPowerUI.mThermalService = mThermalServiceMock;
    }