Merge "Revert "Ignore wake up calls when lid closed"" into udc-dev
This commit is contained in:
@@ -6011,12 +6011,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
mKeyguardDelegate.setSwitchingUser(switching);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WindowManagerFuncs.LidState
|
||||
public int getLidState() {
|
||||
return mDefaultDisplayPolicy.getLidState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpDebug(ProtoOutputStream proto, long fieldId) {
|
||||
final long token = proto.start(fieldId);
|
||||
|
||||
@@ -218,14 +218,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
|
||||
* between it and the policy.
|
||||
*/
|
||||
public interface WindowManagerFuncs {
|
||||
@IntDef(prefix = { "LID_" }, value = {
|
||||
LID_ABSENT,
|
||||
LID_CLOSED,
|
||||
LID_OPEN,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface LidState{}
|
||||
|
||||
public static final int LID_ABSENT = -1;
|
||||
public static final int LID_CLOSED = 0;
|
||||
public static final int LID_OPEN = 1;
|
||||
@@ -239,9 +231,8 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
|
||||
public static final int CAMERA_LENS_COVERED = 1;
|
||||
|
||||
/**
|
||||
* Returns a {@link LidState} that describes the current state of the lid switch.
|
||||
* Returns a code that describes the current state of the lid switch.
|
||||
*/
|
||||
@LidState
|
||||
public int getLidState();
|
||||
|
||||
/**
|
||||
@@ -291,7 +282,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
|
||||
/**
|
||||
* Convert the lid state to a human readable format.
|
||||
*/
|
||||
static String lidStateToString(@LidState int lid) {
|
||||
static String lidStateToString(int lid) {
|
||||
switch (lid) {
|
||||
case LID_ABSENT:
|
||||
return "LID_ABSENT";
|
||||
@@ -1250,11 +1241,4 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
|
||||
* @return {@code true} if the key will be handled globally.
|
||||
*/
|
||||
boolean isGlobalKey(int keyCode);
|
||||
|
||||
/**
|
||||
* Returns a {@link WindowManagerFuncs.LidState} that describes the current state of
|
||||
* the lid switch.
|
||||
*/
|
||||
@WindowManagerFuncs.LidState
|
||||
int getLidState();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import static android.os.PowerManagerInternal.isInteractive;
|
||||
import static android.os.PowerManagerInternal.wakefulnessToString;
|
||||
|
||||
import static com.android.internal.util.LatencyTracker.ACTION_TURN_ON_SCREEN;
|
||||
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
@@ -5734,11 +5733,6 @@ public final class PowerManagerService extends SystemService
|
||||
@Override // Binder call
|
||||
public void wakeUp(long eventTime, @WakeReason int reason, String details,
|
||||
String opPackageName) {
|
||||
if (mPolicy.getLidState() == LID_CLOSED) {
|
||||
Slog.d(TAG, "Ignoring wake up call due to the lid being closed");
|
||||
return;
|
||||
}
|
||||
|
||||
final long now = mClock.uptimeMillis();
|
||||
if (eventTime > now) {
|
||||
Slog.e(TAG, "Event time " + eventTime + " cannot be newer than " + now);
|
||||
|
||||
@@ -225,7 +225,6 @@ public class DisplayPolicy {
|
||||
/** Currently it can only be non-null when physical display switch happens. */
|
||||
private DecorInsets.Cache mCachedDecorInsets;
|
||||
|
||||
@WindowManagerFuncs.LidState
|
||||
private volatile int mLidState = LID_ABSENT;
|
||||
private volatile int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED;
|
||||
private volatile boolean mHdmiPlugged;
|
||||
@@ -753,11 +752,10 @@ public class DisplayPolicy {
|
||||
return mNavigationBarCanMove;
|
||||
}
|
||||
|
||||
public void setLidState(@WindowManagerFuncs.LidState int lidState) {
|
||||
public void setLidState(int lidState) {
|
||||
mLidState = lidState;
|
||||
}
|
||||
|
||||
@WindowManagerFuncs.LidState
|
||||
public int getLidState() {
|
||||
return mLidState;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,6 @@ import static android.os.PowerManagerInternal.WAKEFULNESS_AWAKE;
|
||||
import static android.os.PowerManagerInternal.WAKEFULNESS_DOZING;
|
||||
import static android.os.PowerManagerInternal.WAKEFULNESS_DREAMING;
|
||||
|
||||
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
|
||||
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -148,7 +145,6 @@ public class PowerManagerServiceTest {
|
||||
@Mock private ActivityManagerInternal mActivityManagerInternalMock;
|
||||
@Mock private AttentionManagerInternal mAttentionManagerInternalMock;
|
||||
@Mock private DreamManagerInternal mDreamManagerInternalMock;
|
||||
@Mock private WindowManagerPolicy mPolicyMock;
|
||||
@Mock private PowerManagerService.NativeWrapper mNativeWrapperMock;
|
||||
@Mock private Notifier mNotifierMock;
|
||||
@Mock private WirelessChargerDetector mWirelessChargerDetectorMock;
|
||||
@@ -209,7 +205,6 @@ public class PowerManagerServiceTest {
|
||||
.thenReturn(true);
|
||||
when(mSystemPropertiesMock.get(eq(SYSTEM_PROPERTY_QUIESCENT), anyString())).thenReturn("");
|
||||
when(mAmbientDisplayConfigurationMock.ambientDisplayAvailable()).thenReturn(true);
|
||||
when(mPolicyMock.getLidState()).thenReturn(LID_ABSENT);
|
||||
|
||||
addLocalServiceMock(LightsManager.class, mLightsManagerMock);
|
||||
addLocalServiceMock(DisplayManagerInternal.class, mDisplayManagerInternalMock);
|
||||
@@ -217,7 +212,6 @@ public class PowerManagerServiceTest {
|
||||
addLocalServiceMock(ActivityManagerInternal.class, mActivityManagerInternalMock);
|
||||
addLocalServiceMock(AttentionManagerInternal.class, mAttentionManagerInternalMock);
|
||||
addLocalServiceMock(DreamManagerInternal.class, mDreamManagerInternalMock);
|
||||
addLocalServiceMock(WindowManagerPolicy.class, mPolicyMock);
|
||||
|
||||
mContextSpy = spy(new ContextWrapper(ApplicationProvider.getApplicationContext()));
|
||||
mResourcesSpy = spy(mContextSpy.getResources());
|
||||
@@ -684,20 +678,6 @@ public class PowerManagerServiceTest {
|
||||
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_AWAKE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWakefulnessAwake_ShouldNotWakeUpWhenLidClosed() {
|
||||
when(mPolicyMock.getLidState()).thenReturn(LID_CLOSED);
|
||||
createService();
|
||||
startSystem();
|
||||
forceSleep();
|
||||
|
||||
mService.getBinderServiceInstance().wakeUp(mClock.now(),
|
||||
PowerManager.WAKE_REASON_POWER_BUTTON,
|
||||
"testing IPowerManager.wakeUp()", "pkg.name");
|
||||
|
||||
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_ASLEEP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a series of variants that control whether a device wakes-up when it is plugged in
|
||||
* or docked.
|
||||
|
||||
@@ -18,8 +18,6 @@ package com.android.server.wm;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE;
|
||||
|
||||
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
@@ -356,9 +354,4 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
|
||||
public boolean isGlobalKey(int keyCode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLidState() {
|
||||
return LID_ABSENT;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user