Update region sampling to account for window visibility

- Similar to the nav bar, we should also disable region sampling then
  the window is no longer visible (ie. when in immersive mode) otherwise
  we fall back into gpu composition which consumes more battery

Fixes: 268280575
Test: Enter immersive mode and verify region sampling is disabled
Change-Id: I99bf8986c6f22fd8d480d255d10cfcd39cfb79e3
This commit is contained in:
Winson Chung
2023-02-11 01:02:35 +00:00
parent 8fe24e0893
commit 8bce18a562
2 changed files with 19 additions and 1 deletions
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.taskbar;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -36,6 +38,7 @@ import com.android.launcher3.util.Executors;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
import com.android.systemui.shared.system.QuickStepContract;
import java.io.PrintWriter;
@@ -78,6 +81,10 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
private float mStartProgressForNextRevealAnim;
private boolean mWasLastRevealAnimReversed;
// States that affect whether region sampling is enabled or not
private boolean mIsStashed;
private boolean mTaskbarHidden;
public StashedHandleViewController(TaskbarActivityContext activity,
StashedHandleView stashedHandleView) {
mActivity = activity;
@@ -218,7 +225,8 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
/** Called when taskbar is stashed or unstashed. */
public void onIsStashedChanged(boolean isStashed) {
mRegionSamplingHelper.setWindowVisible(isStashed);
mIsStashed = isStashed;
updateRegionSamplingWindowVisibility();
if (isStashed) {
mStashedHandleView.updateSampledRegion(mStashedHandleBounds);
mRegionSamplingHelper.start(mStashedHandleView.getSampledRegion());
@@ -247,6 +255,15 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
homeDisabled ? 0 : 1);
}
public void updateStateForSysuiFlags(int systemUiStateFlags) {
mTaskbarHidden = (systemUiStateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) != 0;
updateRegionSamplingWindowVisibility();
}
private void updateRegionSamplingWindowVisibility() {
mRegionSamplingHelper.setWindowVisible(mIsStashed && !mTaskbarHidden);
}
public boolean isStashedHandleVisible() {
return mStashedHandleView.getVisibility() == View.VISIBLE;
}