[Galaxy S 4 i9505 Original Android Development] darkassain:
you can build it now? because this patch in particular https://github.com/JDCTeam/android_frameworks_base/commit/eaccc85a96df0f8ead3ca487c94bae4ac7aff494

expects that dreamManager has LidState (and everything that comes with it) which in its opt-cm14.1 branch does not (at least pushed to GH), just a matter of adding it in but as of right now it doesnt compile because of it.

here the patch

diff --git a/core/java/android/service/dreams/IDreamManager.aidl b/core/java/android/service/dreams/IDreamManager.aidl
index 983d8a35c88..78dda0cba27 100644
--- a/core/java/android/service/dreams/IDreamManager.aidl
+++ b/core/java/android/service/dreams/IDreamManager.aidl
@@ -34,4 +34,6 @@ interface IDreamManager {
void finishSelf(in IBinder token, boolean immediate);
void startDozing(in IBinder token, int screenState, int screenBrightness);
void stopDozing(in IBinder token);
+ void setLidState(int state);
+ int getLidState();
}
diff --git a/services/core/java/com/android/server/dreams/DreamManagerService.java b/services/core/java/com/android/server/dreams/DreamManagerService.java
index b81d3370c3f..f618f8d6537 100644
--- a/services/core/java/com/android/server/dreams/DreamManagerService.java
+++ b/services/core/java/com/android/server/dreams/DreamManagerService.java
@@ -19,6 +19,7 @@ package com.android.server.dreams;
import static android.Manifest.permission.BIND_DREAM_SERVICE;

import com.android.internal.hardware.AmbientDisplayConfiguration;
+import android.view.WindowManagerPolicy;
import com.android.internal.util.DumpUtils;
import com.android.server.FgThread;
import com.android.server.LocalServices;
@@ -88,6 +89,7 @@ public final class DreamManagerService extends SystemService {
private boolean mCurrentDreamIsWaking;
private int mCurrentDreamDozeScreenState = Display.STATE_UNKNOWN;
private int mCurrentDreamDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT;
+ private int mLidState = WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;

private AmbientDisplayConfiguration mDozeConfig;

@@ -237,7 +239,8 @@ public final class DreamManagerService extends SystemService {
}

synchronized (mLock) {
- if (mCurrentDreamToken == token && mCurrentDreamCanDoze) {
+ if (mCurrentDreamToken == token && mCurrentDreamCanDoze
+ && mLidState != WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED) {
mCurrentDreamDozeScreenState = screenState;
mCurrentDreamDozeScreenBrightness = screenBrightness;
mPowerManagerInternal.setDozeOverrideFromDreamManager(
@@ -250,6 +253,42 @@ public final class DreamManagerService extends SystemService {
}
}

+ private int getLidStateInternal() {
+ return mLidState;
+ }
+
+ private void setLidStateInternal(int state) {
+ synchronized (mLock) {
+ if (mLidState == state) {
+ return;
+ }
+ mLidState = state;
+ }
+ switch (state) {
+ case WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT:
+ // do nothing
+ break;
+ case WindowManagerPolicy.WindowManagerFuncs.LID_OPEN:
+ synchronized (mLock) {
+ mPowerManagerInternal.setDozeOverrideFromDreamManager(
+ Display.STATE_UNKNOWN, PowerManager.BRIGHTNESS_DEFAULT);
+ }
+ break;
+ case WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED:
+ // mimicing logic from stopDozingInternal(), stop any thing when the lid is closed.
+ synchronized (mLock) {
+ if (mCurrentDreamIsDozing) {
+ mCurrentDreamIsDozing = false;
+ if (mDozeWakeLock.isHeld()) {
+ mDozeWakeLock.release();
+ }
+ mPowerManagerInternal.setDozeOverrideFromDreamManager(
+ Display.STATE_OFF, PowerManager.BRIGHTNESS_OFF);
+ }
+ }
+ break;
+ }
+ }
private void stopDozingInternal(IBinder token) {
if (DEBUG) {
Slog.d(TAG, "Dream requested to stop dozing: " + token);
@@ -656,6 +695,30 @@ public final class DreamManagerService extends SystemService {
Binder.restoreCallingIdentity(ident);
}
}
+
+ @Override
+ public void setLidState(int lidState) {
+ checkPermission(android.Manifest.permission.WRITE_DREAM_STATE);
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ setLidStateInternal(lidState);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public int getLidState() {
+ checkPermission(Manifest.permission.READ_DREAM_STATE);
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ return getLidStateInternal();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
}

private final class LocalService extends DreamManagerInternal {