Make CentralSurfaces optional
CentralSurfaces will instacrash on TV devices if it doesn't haave all
of its dependencies available. Since it is included by SystemUIBinder
via CentralSurfacesModule, we need to remove SystemUIBinder from TV.
When we do that, we find that BouncerSwipeTouchHandler has a hard
dependency on phone.CentralSurfaces meaning that CentralSurfaces was
not actually optional any more.
So we need to convert the dependency there to Optional<>. In future
the fact that TV does not have a CentralSurfaces should guarantee
compile errors if this happens again and keep CentralSurfaces actually
Optional as the javadocs say.
We also need to remove a lot of phone-specific assumptions under the
dreams/touch area, as the following classes remain present even after
this change:
- com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController
- com.android.systemui.statusbar.phone.NotificationShadeWindowControllerImpl
- com.android.systemui.statusbar.phone.ConfigurationControllerImpl
- com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
- com.android.systemui.statusbar.phone.DozeParameters
But that's a much larger task for another day.
Bug: 228414760
Change-Id: Id0a5e35e113bb1d0268c7f687cbd54799a1d9b77
(cherry picked from commit 0c673b1148)
Merged-In: Id0a5e35e113bb1d0268c7f687cbd54799a1d9b77
This commit is contained in:
committed by
Cherrypicker Worker
parent
3313823970
commit
217caf6028
@@ -42,6 +42,7 @@ import com.android.systemui.statusbar.phone.KeyguardBouncer;
|
|||||||
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
|
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
|
||||||
import com.android.wm.shell.animation.FlingAnimationUtils;
|
import com.android.wm.shell.animation.FlingAnimationUtils;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
@@ -77,7 +78,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
|||||||
|
|
||||||
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
|
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
|
||||||
private float mCurrentExpansion;
|
private float mCurrentExpansion;
|
||||||
private final CentralSurfaces mCentralSurfaces;
|
private final Optional<CentralSurfaces> mCentralSurfaces;
|
||||||
|
|
||||||
private VelocityTracker mVelocityTracker;
|
private VelocityTracker mVelocityTracker;
|
||||||
|
|
||||||
@@ -107,7 +108,9 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
|||||||
// If the user scrolling favors a vertical direction, begin capturing
|
// If the user scrolling favors a vertical direction, begin capturing
|
||||||
// scrolls.
|
// scrolls.
|
||||||
mCapture = Math.abs(distanceY) > Math.abs(distanceX);
|
mCapture = Math.abs(distanceY) > Math.abs(distanceX);
|
||||||
mBouncerInitiallyShowing = mCentralSurfaces.isBouncerShowing();
|
mBouncerInitiallyShowing = mCentralSurfaces
|
||||||
|
.map(CentralSurfaces::isBouncerShowing)
|
||||||
|
.orElse(false);
|
||||||
|
|
||||||
if (mCapture) {
|
if (mCapture) {
|
||||||
// Since the user is dragging the bouncer up, set scrimmed to false.
|
// Since the user is dragging the bouncer up, set scrimmed to false.
|
||||||
@@ -129,13 +132,17 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mCentralSurfaces.isPresent()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// For consistency, we adopt the expansion definition found in the
|
// For consistency, we adopt the expansion definition found in the
|
||||||
// PanelViewController. In this case, expansion refers to the view above the
|
// PanelViewController. In this case, expansion refers to the view above the
|
||||||
// bouncer. As that view's expansion shrinks, the bouncer appears. The bouncer
|
// bouncer. As that view's expansion shrinks, the bouncer appears. The bouncer
|
||||||
// is fully hidden at full expansion (1) and fully visible when fully collapsed
|
// is fully hidden at full expansion (1) and fully visible when fully collapsed
|
||||||
// (0).
|
// (0).
|
||||||
final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY())
|
final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY())
|
||||||
/ mCentralSurfaces.getDisplayHeight();
|
/ mCentralSurfaces.get().getDisplayHeight();
|
||||||
setPanelExpansion(mBouncerInitiallyShowing
|
setPanelExpansion(mBouncerInitiallyShowing
|
||||||
? screenTravelPercentage : 1 - screenTravelPercentage);
|
? screenTravelPercentage : 1 - screenTravelPercentage);
|
||||||
return true;
|
return true;
|
||||||
@@ -144,8 +151,8 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
|||||||
|
|
||||||
private void setPanelExpansion(float expansion) {
|
private void setPanelExpansion(float expansion) {
|
||||||
mCurrentExpansion = expansion;
|
mCurrentExpansion = expansion;
|
||||||
mCentralSurfaces.setBouncerShowingOverDream(
|
mCentralSurfaces.ifPresent(centralSurfaces -> centralSurfaces.setBouncerShowingOverDream(
|
||||||
mCurrentExpansion != KeyguardBouncer.EXPANSION_HIDDEN);
|
mCurrentExpansion != KeyguardBouncer.EXPANSION_HIDDEN));
|
||||||
mStatusBarKeyguardViewManager.onPanelExpansionChanged(mCurrentExpansion, false, true);
|
mStatusBarKeyguardViewManager.onPanelExpansionChanged(mCurrentExpansion, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +180,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
|||||||
public BouncerSwipeTouchHandler(
|
public BouncerSwipeTouchHandler(
|
||||||
DisplayMetrics displayMetrics,
|
DisplayMetrics displayMetrics,
|
||||||
StatusBarKeyguardViewManager statusBarKeyguardViewManager,
|
StatusBarKeyguardViewManager statusBarKeyguardViewManager,
|
||||||
CentralSurfaces centralSurfaces,
|
Optional<CentralSurfaces> centralSurfaces,
|
||||||
NotificationShadeWindowController notificationShadeWindowController,
|
NotificationShadeWindowController notificationShadeWindowController,
|
||||||
ValueAnimatorCreator valueAnimatorCreator,
|
ValueAnimatorCreator valueAnimatorCreator,
|
||||||
VelocityTrackerFactory velocityTrackerFactory,
|
VelocityTrackerFactory velocityTrackerFactory,
|
||||||
@@ -197,7 +204,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getTouchInitiationRegion(Region region) {
|
public void getTouchInitiationRegion(Region region) {
|
||||||
if (mCentralSurfaces.isBouncerShowing()) {
|
if (mCentralSurfaces.map(CentralSurfaces::isBouncerShowing).orElse(false)) {
|
||||||
region.op(new Rect(0, 0, mDisplayMetrics.widthPixels,
|
region.op(new Rect(0, 0, mDisplayMetrics.widthPixels,
|
||||||
Math.round(
|
Math.round(
|
||||||
mDisplayMetrics.heightPixels * mBouncerZoneScreenPercentage)),
|
mDisplayMetrics.heightPixels * mBouncerZoneScreenPercentage)),
|
||||||
@@ -308,8 +315,12 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void flingToExpansion(float velocity, float expansion) {
|
protected void flingToExpansion(float velocity, float expansion) {
|
||||||
|
if (!mCentralSurfaces.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// The animation utils deal in pixel units, rather than expansion height.
|
// The animation utils deal in pixel units, rather than expansion height.
|
||||||
final float viewHeight = mCentralSurfaces.getDisplayHeight();
|
final float viewHeight = mCentralSurfaces.get().getDisplayHeight();
|
||||||
final float currentHeight = viewHeight * mCurrentExpansion;
|
final float currentHeight = viewHeight * mCurrentExpansion;
|
||||||
final float targetHeight = viewHeight * expansion;
|
final float targetHeight = viewHeight * expansion;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ import com.android.systemui.dagger.SysUIComponent;
|
|||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
import com.android.systemui.dagger.SystemUIBinder;
|
import com.android.systemui.dagger.SystemUIBinder;
|
||||||
import com.android.systemui.dagger.SystemUIModule;
|
import com.android.systemui.dagger.SystemUIModule;
|
||||||
|
import com.android.systemui.statusbar.dagger.CentralSurfacesDependenciesModule;
|
||||||
|
import com.android.systemui.statusbar.notification.dagger.NotificationsModule;
|
||||||
|
import com.android.systemui.statusbar.notification.row.NotificationRowModule;
|
||||||
|
|
||||||
|
import com.android.systemui.keyguard.dagger.KeyguardModule;
|
||||||
|
import com.android.systemui.recents.RecentsModule;
|
||||||
|
|
||||||
import dagger.Subcomponent;
|
import dagger.Subcomponent;
|
||||||
|
|
||||||
@@ -30,13 +36,17 @@ import dagger.Subcomponent;
|
|||||||
*/
|
*/
|
||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
@Subcomponent(modules = {
|
@Subcomponent(modules = {
|
||||||
|
CentralSurfacesDependenciesModule.class,
|
||||||
DefaultComponentBinder.class,
|
DefaultComponentBinder.class,
|
||||||
DependencyProvider.class,
|
DependencyProvider.class,
|
||||||
SystemUIBinder.class,
|
KeyguardModule.class,
|
||||||
|
NotificationRowModule.class,
|
||||||
|
NotificationsModule.class,
|
||||||
|
RecentsModule.class,
|
||||||
SystemUIModule.class,
|
SystemUIModule.class,
|
||||||
|
TvSystemUIBinder.class,
|
||||||
TVSystemUICoreStartableModule.class,
|
TVSystemUICoreStartableModule.class,
|
||||||
TvSystemUIModule.class,
|
TvSystemUIModule.class})
|
||||||
TvSystemUIBinder.class})
|
|
||||||
public interface TvSysUIComponent extends SysUIComponent {
|
public interface TvSysUIComponent extends SysUIComponent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner.class)
|
@RunWith(AndroidTestingRunner.class)
|
||||||
public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
|
public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
|
||||||
@@ -110,7 +112,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
|
|||||||
mTouchHandler = new BouncerSwipeTouchHandler(
|
mTouchHandler = new BouncerSwipeTouchHandler(
|
||||||
mDisplayMetrics,
|
mDisplayMetrics,
|
||||||
mStatusBarKeyguardViewManager,
|
mStatusBarKeyguardViewManager,
|
||||||
mCentralSurfaces,
|
Optional.of(mCentralSurfaces),
|
||||||
mNotificationShadeWindowController,
|
mNotificationShadeWindowController,
|
||||||
mValueAnimatorCreator,
|
mValueAnimatorCreator,
|
||||||
mVelocityTrackerFactory,
|
mVelocityTrackerFactory,
|
||||||
|
|||||||
Reference in New Issue
Block a user