Disable hinge sensor while the screen is off

This allows to save some power while the device is unfolded but with screen off.

+ Avoiding registering more listeners if HingeSensorAngleProvider.start() is called multiple times sequentially without a `stop` in the middle. It seems that otherwise we would get duplicated callbacks.

+ Adding onScreenTurningOn and onScreenTurningOff callbacks to forward to Launcher (as only sysui is receiving them)

Bug: 240661156
Bug: 240374404
Test: DeviceFoldStateProviderTest && LauncherFoldAnimationTest (e2e)
Change-Id: I769643321c4819c145aac1b0a32a80d5738951c2
This commit is contained in:
Nicolo' Mazzucato
2022-08-05 09:19:59 +00:00
parent d6f79830e5
commit bd819cdf0f
2 changed files with 22 additions and 0 deletions
@@ -270,6 +270,18 @@ public class TouchInteractionService extends Service
MAIN_EXECUTOR.execute(ProxyScreenStatusProvider.INSTANCE::onScreenTurnedOn);
}
@BinderThread
@Override
public void onScreenTurningOn() {
MAIN_EXECUTOR.execute(ProxyScreenStatusProvider.INSTANCE::onScreenTurningOn);
}
@BinderThread
@Override
public void onScreenTurningOff() {
MAIN_EXECUTOR.execute(ProxyScreenStatusProvider.INSTANCE::onScreenTurningOff);
}
/**
* Preloads the Overview activity.
*
@@ -39,6 +39,16 @@ public class ProxyScreenStatusProvider implements ScreenStatusProvider {
mListeners.forEach(ScreenListener::onScreenTurnedOn);
}
/** Called when the screen is starting to turn on. */
public void onScreenTurningOn() {
mListeners.forEach(ScreenListener::onScreenTurningOn);
}
/** Called when the screen is starting to turn off. */
public void onScreenTurningOff() {
mListeners.forEach(ScreenListener::onScreenTurningOff);
}
@Override
public void addCallback(@NonNull ScreenListener listener) {
mListeners.add(listener);