Merge "Hook WakefulnessLifecycle for best timing of LockedDisabled" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aadedc76b6
@@ -87,4 +87,9 @@ public interface OneHanded {
|
||||
* Notifies when user switch complete
|
||||
*/
|
||||
void onUserSwitch(int userId);
|
||||
|
||||
/**
|
||||
* Notifies when keyguard visibility changed
|
||||
*/
|
||||
void onKeyguardVisibilityChanged(boolean showing);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
|
||||
private volatile boolean mIsSwipeToNotificationEnabled;
|
||||
private boolean mTaskChangeToExit;
|
||||
private boolean mLockedDisabled;
|
||||
private boolean mKeyguardShowing;
|
||||
private int mUserId;
|
||||
private float mOffSetFraction;
|
||||
|
||||
@@ -357,7 +358,7 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
|
||||
|
||||
@VisibleForTesting
|
||||
void startOneHanded() {
|
||||
if (isLockedDisabled()) {
|
||||
if (isLockedDisabled() || mKeyguardShowing) {
|
||||
Slog.d(TAG, "Temporary lock disabled");
|
||||
return;
|
||||
}
|
||||
@@ -692,6 +693,10 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
|
||||
mTutorialHandler.onConfigurationChanged();
|
||||
}
|
||||
|
||||
private void onKeyguardVisibilityChanged(boolean showing) {
|
||||
mKeyguardShowing = showing;
|
||||
}
|
||||
|
||||
private void onUserSwitch(int newUserId) {
|
||||
unregisterSettingObservers();
|
||||
mUserId = newUserId;
|
||||
@@ -838,6 +843,13 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
|
||||
OneHandedController.this.onUserSwitch(userId);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyguardVisibilityChanged(boolean showing) {
|
||||
mMainExecutor.execute(() -> {
|
||||
OneHandedController.this.onKeyguardVisibilityChanged(showing);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dagger.WMComponent;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.keyguard.ScreenLifecycle;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.model.SysUiState;
|
||||
import com.android.systemui.navigationbar.NavigationModeController;
|
||||
import com.android.systemui.shared.tracing.ProtoTraceable;
|
||||
@@ -114,6 +115,7 @@ public final class WMShell extends SystemUI
|
||||
private final NavigationModeController mNavigationModeController;
|
||||
private final ScreenLifecycle mScreenLifecycle;
|
||||
private final SysUiState mSysUiState;
|
||||
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
private final ProtoTracer mProtoTracer;
|
||||
private final Executor mSysUiMainExecutor;
|
||||
|
||||
@@ -121,6 +123,7 @@ public final class WMShell extends SystemUI
|
||||
private KeyguardUpdateMonitorCallback mSplitScreenKeyguardCallback;
|
||||
private KeyguardUpdateMonitorCallback mPipKeyguardCallback;
|
||||
private KeyguardUpdateMonitorCallback mOneHandedKeyguardCallback;
|
||||
private WakefulnessLifecycle.Observer mWakefulnessObserver;
|
||||
|
||||
@Inject
|
||||
public WMShell(Context context,
|
||||
@@ -136,6 +139,7 @@ public final class WMShell extends SystemUI
|
||||
ScreenLifecycle screenLifecycle,
|
||||
SysUiState sysUiState,
|
||||
ProtoTracer protoTracer,
|
||||
WakefulnessLifecycle wakefulnessLifecycle,
|
||||
@Main Executor sysUiMainExecutor) {
|
||||
super(context);
|
||||
mCommandQueue = commandQueue;
|
||||
@@ -148,6 +152,7 @@ public final class WMShell extends SystemUI
|
||||
mSplitScreenOptional = splitScreenOptional;
|
||||
mOneHandedOptional = oneHandedOptional;
|
||||
mHideDisplayCutoutOptional = hideDisplayCutoutOptional;
|
||||
mWakefulnessLifecycle = wakefulnessLifecycle;
|
||||
mProtoTracer = protoTracer;
|
||||
mShellCommandHandler = shellCommandHandler;
|
||||
mSysUiMainExecutor = sysUiMainExecutor;
|
||||
@@ -265,22 +270,9 @@ public final class WMShell extends SystemUI
|
||||
});
|
||||
|
||||
mOneHandedKeyguardCallback = new KeyguardUpdateMonitorCallback() {
|
||||
@Override
|
||||
public void onKeyguardBouncerChanged(boolean bouncer) {
|
||||
if (bouncer) {
|
||||
oneHanded.stopOneHanded();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyguardVisibilityChanged(boolean showing) {
|
||||
if (showing) {
|
||||
// When keyguard shown, temperory lock OHM disabled to avoid mis-trigger.
|
||||
oneHanded.setLockedDisabled(true /* locked */, false /* enabled */);
|
||||
} else {
|
||||
// Reset locked.
|
||||
oneHanded.setLockedDisabled(false /* locked */, false /* enabled */);
|
||||
}
|
||||
oneHanded.onKeyguardVisibilityChanged(showing);
|
||||
oneHanded.stopOneHanded();
|
||||
}
|
||||
|
||||
@@ -291,6 +283,24 @@ public final class WMShell extends SystemUI
|
||||
};
|
||||
mKeyguardUpdateMonitor.registerCallback(mOneHandedKeyguardCallback);
|
||||
|
||||
mWakefulnessObserver =
|
||||
new WakefulnessLifecycle.Observer() {
|
||||
@Override
|
||||
public void onFinishedWakingUp() {
|
||||
// Reset locked for the case keyguard not shown.
|
||||
oneHanded.setLockedDisabled(false /* locked */, false /* enabled */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartedGoingToSleep() {
|
||||
oneHanded.stopOneHanded();
|
||||
// When user press power button going to sleep, temperory lock OHM disabled
|
||||
// to avoid mis-trigger.
|
||||
oneHanded.setLockedDisabled(true /* locked */, false /* enabled */);
|
||||
}
|
||||
};
|
||||
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
|
||||
|
||||
mScreenLifecycle.addObserver(new ScreenLifecycle.Observer() {
|
||||
@Override
|
||||
public void onScreenTurningOff() {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.keyguard.ScreenLifecycle;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.model.SysUiState;
|
||||
import com.android.systemui.navigationbar.NavigationModeController;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
@@ -70,6 +71,7 @@ public class WMShellTest extends SysuiTestCase {
|
||||
@Mock LegacySplitScreen mLegacySplitScreen;
|
||||
@Mock OneHanded mOneHanded;
|
||||
@Mock HideDisplayCutout mHideDisplayCutout;
|
||||
@Mock WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
@Mock ProtoTracer mProtoTracer;
|
||||
@Mock ShellCommandHandler mShellCommandHandler;
|
||||
@Mock ShellExecutor mSysUiMainExecutor;
|
||||
@@ -82,7 +84,8 @@ public class WMShellTest extends SysuiTestCase {
|
||||
Optional.of(mOneHanded), Optional.of(mHideDisplayCutout),
|
||||
Optional.of(mShellCommandHandler), mCommandQueue, mConfigurationController,
|
||||
mKeyguardUpdateMonitor, mNavigationModeController,
|
||||
mScreenLifecycle, mSysUiState, mProtoTracer, mSysUiMainExecutor);
|
||||
mScreenLifecycle, mSysUiState, mProtoTracer, mWakefulnessLifecycle,
|
||||
mSysUiMainExecutor);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user