Merge "Add a method in IDreamManager to check if dreaming OR in dream preview" into tm-qpr-dev

This commit is contained in:
Mady Mellor
2022-08-17 18:51:28 +00:00
committed by Android (Google) Code Review
2 changed files with 23 additions and 0 deletions

View File

@@ -35,6 +35,8 @@ interface IDreamManager {
void testDream(int userId, in ComponentName componentName); void testDream(int userId, in ComponentName componentName);
@UnsupportedAppUsage @UnsupportedAppUsage
boolean isDreaming(); boolean isDreaming();
@UnsupportedAppUsage
boolean isDreamingOrInPreview();
void finishSelf(in IBinder token, boolean immediate); void finishSelf(in IBinder token, boolean immediate);
void startDozing(in IBinder token, int screenState, int screenBrightness); void startDozing(in IBinder token, int screenState, int screenBrightness);
void stopDozing(in IBinder token); void stopDozing(in IBinder token);

View File

@@ -218,6 +218,7 @@ public final class DreamManagerService extends SystemService {
}, pw, "", 200); }, pw, "", 200);
} }
/** Whether a real dream is occurring. */
private boolean isDreamingInternal() { private boolean isDreamingInternal() {
synchronized (mLock) { synchronized (mLock) {
return mCurrentDreamToken != null && !mCurrentDreamIsPreview return mCurrentDreamToken != null && !mCurrentDreamIsPreview
@@ -225,6 +226,13 @@ public final class DreamManagerService extends SystemService {
} }
} }
/** Whether a real dream, or a dream preview is occurring. */
private boolean isDreamingOrInPreviewInternal() {
synchronized (mLock) {
return mCurrentDreamToken != null && !mCurrentDreamIsWaking;
}
}
protected void requestStartDreamFromShell() { protected void requestStartDreamFromShell() {
requestDreamInternal(); requestDreamInternal();
} }
@@ -694,6 +702,19 @@ public final class DreamManagerService extends SystemService {
} }
} }
@Override // Binder call
public boolean isDreamingOrInPreview() {
checkPermission(android.Manifest.permission.READ_DREAM_STATE);
final long ident = Binder.clearCallingIdentity();
try {
return isDreamingOrInPreviewInternal();
} finally {
Binder.restoreCallingIdentity(ident);
}
}
@Override // Binder call @Override // Binder call
public void dream() { public void dream() {
checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); checkPermission(android.Manifest.permission.WRITE_DREAM_STATE);