diff options
author | John Spurlock <jspurlock@google.com> | 2012-07-31 08:28:12 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2012-08-03 08:51:17 -0400 |
commit | bc632a28e4fba4a659baf39b9fd3d06d10cfda97 (patch) | |
tree | 7673f90d9f6a3aa9c47ea5c3a926ffa155e60f0c /core/java/android/service/dreams | |
parent | 187019c51fb1f8f79d4d5919facbc8d569ff844e (diff) | |
download | frameworks_base-bc632a28e4fba4a659baf39b9fd3d06d10cfda97.zip frameworks_base-bc632a28e4fba4a659baf39b9fd3d06d10cfda97.tar.gz frameworks_base-bc632a28e4fba4a659baf39b9fd3d06d10cfda97.tar.bz2 |
Re-enable dreams: frameworks/base
Enable feature in config. Expose Dream in public api for unbundled apps.
Unhide package. Add isDreaming() method to service.
Re-arrange the Dream api a bit. (use onStart as hook for subclasses).
Coordinate properly with power manager.
Replace old dock mode (don't fire old intent).
Change-Id: I1318d20cc1613e5d862f2913f2fcdc9719302cf7
Bug: 6921930
Diffstat (limited to 'core/java/android/service/dreams')
-rw-r--r-- | core/java/android/service/dreams/Dream.java | 53 | ||||
-rw-r--r-- | core/java/android/service/dreams/DreamManagerService.java | 20 | ||||
-rw-r--r-- | core/java/android/service/dreams/IDreamManager.aidl | 1 |
3 files changed, 42 insertions, 32 deletions
diff --git a/core/java/android/service/dreams/Dream.java b/core/java/android/service/dreams/Dream.java index 83464c9..9a903e4 100644 --- a/core/java/android/service/dreams/Dream.java +++ b/core/java/android/service/dreams/Dream.java @@ -1,26 +1,31 @@ /** - * + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package android.service.dreams; -import com.android.internal.policy.PolicyManager; - import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.app.Service; -import android.content.Context; import android.content.Intent; -import android.content.pm.ActivityInfo; import android.graphics.drawable.ColorDrawable; -import android.os.Binder; import android.os.Handler; import android.os.IBinder; -import android.os.Looper; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Slog; import android.view.ActionMode; -import android.view.IWindowManager; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; @@ -28,14 +33,14 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.Window; +import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import android.view.accessibility.AccessibilityEvent; -import android.view.WindowManager; -import android.view.WindowManagerImpl; + +import com.android.internal.policy.PolicyManager; /** - * @hide - * + * Extend this class to implement a custom screensaver. */ public class Dream extends Service implements Window.Callback { private final static boolean DEBUG = true; @@ -61,7 +66,7 @@ public class Dream extends Service implements Window.Callback { final Handler mHandler = new Handler(); boolean mFinished = false; - + // begin Window.Callback methods @Override public boolean dispatchKeyEvent(KeyEvent event) { @@ -210,19 +215,14 @@ public class Dream extends Service implements Window.Callback { mSandman = IDreamManager.Stub.asInterface(ServiceManager.getService("dreams")); } - + /** - * Called when this Dream is started. Place your initialization here. - * - * Subclasses must call through to the superclass implementation. - * - * XXX(dsandler) Might want to make this final and have a different method for clients to override + * Called when this Dream is started. */ - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - return super.onStartCommand(intent, flags, startId); + public void onStart() { + // hook for subclasses } - + /** * Inflate a layout resource and set it to be the content view for this Dream. * Behaves similarly to {@link android.app.Activity#setContentView(int)}. @@ -351,9 +351,12 @@ public class Dream extends Service implements Window.Callback { @Override public void run() { if (DEBUG) Slog.v(TAG, "Dream window added on thread " + Thread.currentThread().getId()); - + getWindowManager().addView(mWindow.getDecorView(), mWindow.getAttributes()); - }}); + + // start it up + onStart(); + }}); } /** diff --git a/core/java/android/service/dreams/DreamManagerService.java b/core/java/android/service/dreams/DreamManagerService.java index 4a14ced..d6b38a1 100644 --- a/core/java/android/service/dreams/DreamManagerService.java +++ b/core/java/android/service/dreams/DreamManagerService.java @@ -114,11 +114,19 @@ public class DreamManagerService if (DEBUG) Slog.v(TAG, "awaken()"); synchronized (mLock) { if (mCurrentDream != null) { + if (DEBUG) Slog.v(TAG, "disconnecting: " + mCurrentDreamComponent + " service: " + mCurrentDream); mContext.unbindService(this); + mCurrentDream = null; + mCurrentDreamToken = null; } } } + // IDreamManager method + public boolean isDreaming() { + return mCurrentDream != null; + } + public void bindDreamComponentL(ComponentName componentName, boolean test) { if (DEBUG) Slog.v(TAG, "bindDreamComponent: componentName=" + componentName + " pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); @@ -129,11 +137,7 @@ public class DreamManagerService Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS ) .putExtra("android.dreams.TEST", test); - - if (!mContext.bindService(intent, this, Context.BIND_AUTO_CREATE)) { - Slog.w(TAG, "unable to bind service: " + componentName); - return; - } + mCurrentDreamComponent = componentName; mCurrentDreamToken = new Binder(); try { @@ -145,6 +149,9 @@ public class DreamManagerService Slog.w(TAG, "Unable to add window token. Proceed at your own risk."); } + if (!mContext.bindService(intent, this, Context.BIND_AUTO_CREATE)) { + Slog.w(TAG, "unable to bind service: " + componentName); + } } @Override @@ -163,8 +170,7 @@ public class DreamManagerService @Override public void onServiceDisconnected(ComponentName name) { if (DEBUG) Slog.v(TAG, "disconnected: " + name + " service: " + mCurrentDream); - mCurrentDream = null; - mCurrentDreamToken = null; + // Only happens in exceptional circumstances } @Override diff --git a/core/java/android/service/dreams/IDreamManager.aidl b/core/java/android/service/dreams/IDreamManager.aidl index 7225013..b64dd8f 100644 --- a/core/java/android/service/dreams/IDreamManager.aidl +++ b/core/java/android/service/dreams/IDreamManager.aidl @@ -27,4 +27,5 @@ interface IDreamManager { void setDreamComponent(in ComponentName componentName); ComponentName getDreamComponent(); void testDream(in ComponentName componentName); + boolean isDreaming(); }
\ No newline at end of file |