Loading packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java +11 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 */); Loading packages/SystemUI/src/com/android/systemui/power/PowerUI.java +10 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 = Loading Loading @@ -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; Loading @@ -167,6 +174,7 @@ public class PowerUI implements mPowerManager = powerManager; mWakefulnessLifecycle = wakefulnessLifecycle; mUserTracker = userTracker; mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture); } public void start() { Loading Loading @@ -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(); Loading packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java +6 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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() { Loading Loading @@ -705,7 +709,8 @@ public class PowerUITest extends SysuiTestCase { mEnhancedEstimates, mWakefulnessLifecycle, mPowerManager, mUserTracker); mUserTracker, mLazyViewCapture); mPowerUI.mThermalService = mThermalServiceMock; } Loading Loading
packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java +11 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 */); Loading
packages/SystemUI/src/com/android/systemui/power/PowerUI.java +10 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 = Loading Loading @@ -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; Loading @@ -167,6 +174,7 @@ public class PowerUI implements mPowerManager = powerManager; mWakefulnessLifecycle = wakefulnessLifecycle; mUserTracker = userTracker; mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture); } public void start() { Loading Loading @@ -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(); Loading
packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java +6 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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() { Loading Loading @@ -705,7 +709,8 @@ public class PowerUITest extends SysuiTestCase { mEnhancedEstimates, mWakefulnessLifecycle, mPowerManager, mUserTracker); mUserTracker, mLazyViewCapture); mPowerUI.mThermalService = mThermalServiceMock; } Loading