From 7580493b014a2c7ea883cd291255798dc72ebbff Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 20 Oct 2009 20:15:20 -0700 Subject: [PATCH] Implement feature #2117336: Create event communication APIs for live wallpaper Note: currently only implements an async version (no result), and not yet actually tested. Change-Id: Id47ed045a4b0eb309ea8c58daf41a0e03eff1d3a --- api/current.xml | 23 ++++ core/java/android/app/WallpaperManager.java | 25 +++++ .../service/wallpaper/WallpaperService.java | 70 ++++++++++++ core/java/android/view/IWindow.aidl | 7 +- core/java/android/view/IWindowSession.aidl | 6 + core/java/android/view/ViewRoot.java | 10 ++ .../android/internal/view/BaseIWindow.java | 11 ++ .../android/server/WindowManagerService.java | 106 +++++++++++++----- .../com/android/layoutlib/bridge/Bridge.java | 19 ++++ 9 files changed, 249 insertions(+), 28 deletions(-) diff --git a/api/current.xml b/api/current.xml index 614804708a48a..8f83e399bd650 100644 --- a/api/current.xml +++ b/api/current.xml @@ -24659,6 +24659,29 @@ visibility="public" > + + + + + + + + + + + + + + 0) { + curTokenIndex--; + WindowToken token = mWallpaperTokens.get(curTokenIndex); + int curWallpaperIndex = token.windows.size(); + while (curWallpaperIndex > 0) { + curWallpaperIndex--; + WindowState wallpaper = token.windows.get(curWallpaperIndex); + try { + wallpaper.mClient.dispatchWallpaperCommand(action, + x, y, z, extras, sync); + // We only want to be synchronous with one wallpaper. + sync = false; + } catch (RemoteException e) { + } + } + } + + if (doWait) { + // XXX Need to wait for result. + } + } + + return null; + } + public int relayoutWindow(Session session, IWindow client, WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, boolean insetsPending, @@ -6565,6 +6601,24 @@ public class WindowManagerService extends IWindowManager.Stub WindowManagerService.this.wallpaperOffsetsComplete(window); } + public Bundle sendWallpaperCommand(IBinder window, String action, int x, int y, + int z, Bundle extras, boolean sync) { + synchronized(mWindowMap) { + long ident = Binder.clearCallingIdentity(); + try { + return sendWindowWallpaperCommandLocked( + windowForClientLocked(this, window), + action, x, y, z, extras, sync); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + } + + public void wallpaperCommandComplete(IBinder window, Bundle result) { + WindowManagerService.this.wallpaperCommandComplete(window, result); + } + void windowAddedLocked() { if (mSurfaceSession == null) { if (localLOGV) Log.v( diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java index d28a15149ec9b..f0223e83522a0 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java @@ -36,6 +36,7 @@ import android.graphics.Rect; import android.graphics.Region; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; @@ -1068,6 +1069,18 @@ public final class Bridge implements ILayoutBridge { // pass for now. } + @SuppressWarnings("unused") + public Bundle sendWallpaperCommand(IBinder window, String action, int x, int y, + int z, Bundle extras, boolean sync) { + // pass for now. + return null; + } + + @SuppressWarnings("unused") + public void wallpaperCommandComplete(IBinder window, Bundle result) { + // pass for now. + } + @SuppressWarnings("unused") public void closeSystemDialogs(String reason) { // pass for now. @@ -1131,6 +1144,12 @@ public final class Bridge implements ILayoutBridge { // pass for now. } + @SuppressWarnings("unused") + public void dispatchWallpaperCommand(String action, int x, int y, + int z, Bundle extras, boolean sync) { + // pass for now. + } + @SuppressWarnings("unused") public void closeSystemDialogs(String reason) { // pass for now.