diff options
| -rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 29 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/ImageWallpaper.java | 57 |
2 files changed, 26 insertions, 60 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 6d5705d..500bb2c 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -84,7 +84,7 @@ public abstract class WallpaperService extends Service { * tag. */ public static final String SERVICE_META_DATA = "android.service.wallpaper"; - + static final String TAG = "WallpaperService"; static final boolean DEBUG = false; @@ -100,7 +100,6 @@ public abstract class WallpaperService extends Service { private static final int MSG_WINDOW_MOVED = 10035; private static final int MSG_TOUCH_EVENT = 10040; - private Looper mCallbackLooper; private final ArrayList<Engine> mActiveEngines = new ArrayList<Engine>(); @@ -961,13 +960,7 @@ public abstract class WallpaperService extends Service { IWallpaperEngineWrapper(WallpaperService context, IWallpaperConnection conn, IBinder windowToken, int windowType, boolean isPreview, int reqWidth, int reqHeight) { - if (DEBUG && mCallbackLooper != null) { - mCallbackLooper.setMessageLogging(new LogPrinter(Log.VERBOSE, TAG)); - } - mCaller = new HandlerCaller(context, - mCallbackLooper != null - ? mCallbackLooper : context.getMainLooper(), - this); + mCaller = new HandlerCaller(context, context.getMainLooper(), this); mConnection = conn; mWindowToken = windowToken; mWindowType = windowType; @@ -1105,13 +1098,14 @@ public abstract class WallpaperService extends Service { mTarget = context; } + @Override public void attach(IWallpaperConnection conn, IBinder windowToken, int windowType, boolean isPreview, int reqWidth, int reqHeight) { new IWallpaperEngineWrapper(mTarget, conn, windowToken, windowType, isPreview, reqWidth, reqHeight); } } - + @Override public void onCreate() { super.onCreate(); @@ -1134,20 +1128,7 @@ public abstract class WallpaperService extends Service { public final IBinder onBind(Intent intent) { return new IWallpaperServiceWrapper(this); } - - /** - * This allows subclasses to change the thread that most callbacks - * occur on. Currently hidden because it is mostly needed for the - * image wallpaper (which runs in the system process and doesn't want - * to get stuck running on that seriously in use main thread). Not - * exposed right now because the semantics of this are not totally - * well defined and some callbacks can still happen on the main thread). - * @hide - */ - public void setCallbackLooper(Looper looper) { - mCallbackLooper = looper; - } - + /** * Must be implemented to return a new instance of the wallpaper's engine. * Note that multiple instances may be active at the same time, such as diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java index 9da883a..a1c5650 100644 --- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java @@ -31,7 +31,6 @@ import android.os.SystemProperties; import android.renderscript.Matrix4f; import android.service.wallpaper.WallpaperService; import android.util.Log; -import android.view.Display; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.WindowManager; @@ -41,7 +40,6 @@ import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLSurface; -import javax.microedition.khronos.opengles.GL; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -93,6 +91,7 @@ public class ImageWallpaper extends WallpaperService { return "1".equals(SystemProperties.get(PROPERTY_KERNEL_QEMU, "0")); } + @Override public Engine onCreateEngine() { mEngine = new DrawableEngine(); return mEngine; @@ -102,8 +101,6 @@ public class ImageWallpaper extends WallpaperService { static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098; static final int EGL_OPENGL_ES2_BIT = 4; - private final Object mLock = new Object[0]; - // TODO: Not currently used, keeping around until we know we don't need it @SuppressWarnings({"UnusedDeclaration"}) private WallpaperObserver mReceiver; @@ -125,7 +122,6 @@ public class ImageWallpaper extends WallpaperService { private EGLConfig mEglConfig; private EGLContext mEglContext; private EGLSurface mEglSurface; - private GL mGL; private static final String sSimpleVS = "attribute vec4 position;\n" + @@ -150,17 +146,16 @@ public class ImageWallpaper extends WallpaperService { private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3; class WallpaperObserver extends BroadcastReceiver { + @Override public void onReceive(Context context, Intent intent) { if (DEBUG) { Log.d(TAG, "onReceive"); } - synchronized (mLock) { - mLastSurfaceWidth = mLastSurfaceHeight = -1; - mBackground = null; - mRedrawNeeded = true; - drawFrameLocked(); - } + mLastSurfaceWidth = mLastSurfaceHeight = -1; + mBackground = null; + mRedrawNeeded = true; + drawFrame(); } } @@ -234,14 +229,12 @@ public class ImageWallpaper extends WallpaperService { Log.d(TAG, "onVisibilityChanged: mVisible, visible=" + mVisible + ", " + visible); } - synchronized (mLock) { - if (mVisible != visible) { - if (DEBUG) { - Log.d(TAG, "Visibility changed to visible=" + visible); - } - mVisible = visible; - drawFrameLocked(); + if (mVisible != visible) { + if (DEBUG) { + Log.d(TAG, "Visibility changed to visible=" + visible); } + mVisible = visible; + drawFrame(); } } @@ -260,17 +253,15 @@ public class ImageWallpaper extends WallpaperService { + ", xPixels=" + xPixels + ", yPixels=" + yPixels); } - synchronized (mLock) { - if (mXOffset != xOffset || mYOffset != yOffset) { - if (DEBUG) { - Log.d(TAG, "Offsets changed to (" + xOffset + "," + yOffset + ")."); - } - mXOffset = xOffset; - mYOffset = yOffset; - mOffsetsChanged = true; + if (mXOffset != xOffset || mYOffset != yOffset) { + if (DEBUG) { + Log.d(TAG, "Offsets changed to (" + xOffset + "," + yOffset + ")."); } - drawFrameLocked(); + mXOffset = xOffset; + mYOffset = yOffset; + mOffsetsChanged = true; } + drawFrame(); } @Override @@ -281,9 +272,7 @@ public class ImageWallpaper extends WallpaperService { super.onSurfaceChanged(holder, format, width, height); - synchronized (mLock) { - drawFrameLocked(); - } + drawFrame(); } @Override @@ -305,12 +294,10 @@ public class ImageWallpaper extends WallpaperService { } super.onSurfaceRedrawNeeded(holder); - synchronized (mLock) { - drawFrameLocked(); - } + drawFrame(); } - void drawFrameLocked() { + void drawFrame() { SurfaceHolder sh = getSurfaceHolder(); final Rect frame = sh.getSurfaceFrame(); final int dw = frame.width(); @@ -657,8 +644,6 @@ public class ImageWallpaper extends WallpaperService { throw new RuntimeException("eglMakeCurrent failed " + GLUtils.getEGLErrorString(mEgl.eglGetError())); } - - mGL = mEglContext.getGL(); return true; } |
