Revert "Ignore wake up calls when lid closed"
This reverts commit 9740d55ec1aa2cb7c3dea93190a3379082f57526.
Reason for revert: b/284406751
Change-Id: If035d17ff5824b113e0612ea9e0fec52c1866c57
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index a148de6..d7eff52 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -6010,12 +6010,6 @@
}
@Override
- @WindowManagerFuncs.LidState
- public int getLidState() {
- return mDefaultDisplayPolicy.getLidState();
- }
-
- @Override
public void dumpDebug(ProtoOutputStream proto, long fieldId) {
final long token = proto.start(fieldId);
proto.write(ROTATION_MODE, mDefaultDisplayRotation.getUserRotationMode());
diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
index 3da7812..887f946 100644
--- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java
+++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
@@ -218,14 +218,6 @@
* 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 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 @@
/**
* 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 @@
* @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();
}
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 712be36..b8c5b3f 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -33,7 +33,6 @@
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 @@
@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);
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 46141f8..77e70a2 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -225,7 +225,6 @@
/** 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 @@
return mNavigationBarCanMove;
}
- public void setLidState(@WindowManagerFuncs.LidState int lidState) {
+ public void setLidState(int lidState) {
mLidState = lidState;
}
- @WindowManagerFuncs.LidState
public int getLidState() {
return mLidState;
}
diff --git a/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java
index 7aec045..933f002 100644
--- a/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java
@@ -26,9 +26,6 @@
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 @@
@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 @@
.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 @@
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 @@
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.
diff --git a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java
index 192632c..adf3f39 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java
@@ -18,8 +18,6 @@
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 @@
public boolean isGlobalKey(int keyCode) {
return false;
}
-
- @Override
- public int getLidState() {
- return LID_ABSENT;
- }
}