Loading api/current.xml +44 −0 Original line number Diff line number Diff line Loading @@ -9370,6 +9370,17 @@ visibility="public" > </field> <field name="windowShowWallpaper" type="int" transient="false" volatile="false" value="16843426" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="windowSoftInputMode" type="int" transient="false" Loading Loading @@ -15002,6 +15013,39 @@ visibility="public" > </field> <field name="Theme_Wallpaper" type="int" transient="false" volatile="false" value="16973937" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="Theme_Wallpaper_NoTitleBar" type="int" transient="false" volatile="false" value="16973938" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="Theme_Wallpaper_NoTitleBar_Fullscreen" type="int" transient="false" volatile="false" value="16973939" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="Widget" type="int" transient="false" core/java/android/service/wallpaper/WallpaperService.java +72 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.internal.view.BaseIWindow; import com.android.internal.view.BaseSurfaceHolder; import android.app.Service; import android.app.WallpaperManager; import android.content.Intent; import android.graphics.Rect; import android.os.Handler; Loading Loading @@ -55,12 +56,14 @@ public abstract class WallpaperService extends Service { private static final int DO_DETACH = 20; private static final int MSG_UPDATE_SURFACE = 10000; private static final int MSG_VISIBILITY_CHANGED = 10010; /** * The actual implementation of a wallpaper. A wallpaper service may * have multiple instances running (for example as a real wallpaper * and as a preview), each of which is represented by its own Engine * instance. * instance. You must implement {@link WallpaperService#onCreateEngine()} * to return your concrete Engine implementation. */ public class Engine { IWallpaperEngineWrapper mIWallpaperEngine; Loading Loading @@ -119,21 +122,79 @@ public abstract class WallpaperService extends Service { }; final BaseIWindow mWindow = new BaseIWindow() { public void dispatchAppVisibility(boolean visible) { Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED, visible ? 1 : 0); mCaller.sendMessage(msg); } }; public void onAttach(SurfaceHolder surfaceHolder) { /** * Provides access to the surface in which this wallpaper is drawn. */ public SurfaceHolder getSurfaceHolder() { return mSurfaceHolder; } /** * Convenience for {@link WallpaperManager#getDesiredMinimumWidth() * WallpaperManager.getDesiredMinimumWidth()}, returning the width * that the system would like this wallpaper to run in. */ public int getDesiredMinimumWidth() { return mIWallpaperEngine.mReqWidth; } /** * Convenience for {@link WallpaperManager#getDesiredMinimumHeight() * WallpaperManager.getDesiredMinimumHeight()}, returning the height * that the system would like this wallpaper to run in. */ public int getDesiredMinimumHeight() { return mIWallpaperEngine.mReqHeight; } /** * Called once to initialize the engine. After returning, the * engine's surface will be created by the framework. */ public void onCreate(SurfaceHolder surfaceHolder) { } /** * Called right before the engine is going away. After this the * surface will be destroyed and this Engine object is no longer * valid. */ public void onDestroy() { } public void onDetach() { /** * Called to inform you of the wallpaper becoming visible or * hidden. <em>It is very important that a wallpaper only use * CPU while it is visible.</em>. */ public void onVisibilityChanged(boolean visible) { } /** * Convenience for {@link SurfaceHolder.Callback#surfaceChanged * SurfaceHolder.Callback.surfaceChanged()}. */ public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { } /** * Convenience for {@link SurfaceHolder.Callback#surfaceCreated * SurfaceHolder.Callback.surfaceCreated()}. */ public void onSurfaceCreated(SurfaceHolder holder) { } /** * Convenience for {@link SurfaceHolder.Callback#surfaceDestroyed * SurfaceHolder.Callback.surfaceDestroyed()}. */ public void onSurfaceDestroyed(SurfaceHolder holder) { } Loading Loading @@ -249,14 +310,14 @@ public abstract class WallpaperService extends Service { mSession = ViewRoot.getWindowSession(getMainLooper()); mWindow.setSession(mSession); onAttach(mSurfaceHolder); onCreate(mSurfaceHolder); mInitializing = false; updateSurface(false); } void detach() { onDetach(); onDestroy(); if (mDestroyReportNeeded) { mDestroyReportNeeded = false; SurfaceHolder.Callback callbacks[]; Loading Loading @@ -330,6 +391,11 @@ public abstract class WallpaperService extends Service { case MSG_UPDATE_SURFACE: mEngine.updateSurface(false); break; case MSG_VISIBILITY_CHANGED: if (DEBUG) Log.v(TAG, "Visibility change in " + mEngine + ": " + message.arg1); mEngine.onVisibilityChanged(message.arg1 != 0); break; default : Log.w(TAG, "Unknown message type " + message.what); } Loading core/java/com/android/internal/service/wallpaper/ImageWallpaper.java +75 −14 Original line number Diff line number Diff line Loading @@ -19,7 +19,11 @@ package com.android.internal.service.wallpaper; import android.app.WallpaperManager; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.service.wallpaper.WallpaperService; import android.view.SurfaceHolder; Loading @@ -29,30 +33,58 @@ import android.view.SurfaceHolder; public class ImageWallpaper extends WallpaperService { public WallpaperManager mWallpaperManager; class MyEngine extends Engine { static final int MSG_DRAW = 1; class MyEngine extends Engine { final Paint mTextPaint = new Paint(); float mDensity; Drawable mBackground; long mAnimStartTime; boolean mAnimLarger; final Handler mHandler = new Handler() { @Override public void onAttach(SurfaceHolder surfaceHolder) { super.onAttach(surfaceHolder); public void handleMessage(Message msg) { switch (msg.what) { case MSG_DRAW: drawFrame(true); mHandler.sendEmptyMessage(MSG_DRAW); break; default: super.handleMessage(msg); } } }; @Override public void onCreate(SurfaceHolder surfaceHolder) { super.onCreate(surfaceHolder); mBackground = mWallpaperManager.getDrawable(); mTextPaint.setAntiAlias(true); mDensity = getResources().getDisplayMetrics().density; mTextPaint.setTextSize(30 * mDensity); mTextPaint.setShadowLayer(5*mDensity, 3*mDensity, 3*mDensity, 0xff000000); mTextPaint.setARGB(255, 255, 255, 255); mTextPaint.setTextAlign(Paint.Align.CENTER); } @Override public void onVisibilityChanged(boolean visible) { mHandler.removeMessages(MSG_DRAW); if (visible) { mHandler.sendEmptyMessage(MSG_DRAW); mAnimStartTime = SystemClock.uptimeMillis(); mAnimLarger = true; } else { drawFrame(false); } } @Override public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { super.onSurfaceChanged(holder, format, width, height); Canvas c = holder.lockCanvas(); mBackground.setBounds(0, 0, width, height); mBackground.draw(c); Paint paint = new Paint(); paint.setAntiAlias(true); final float density = getResources().getDisplayMetrics().density; paint.setTextSize(30 * density); paint.setShadowLayer(5*density, 3*density, 3*density, 0xff000000); paint.setARGB(255, 255, 255, 255); c.drawText("Am I live?", 10, 60*density, paint); holder.unlockCanvasAndPost(c); drawFrame(false); } @Override Loading @@ -65,6 +97,35 @@ public class ImageWallpaper extends WallpaperService { super.onSurfaceDestroyed(holder); } void drawFrame(boolean drawText) { SurfaceHolder sh = getSurfaceHolder(); Canvas c = sh.lockCanvas(); if (c != null) { final Rect frame = sh.getSurfaceFrame(); mBackground.setBounds(frame); mBackground.draw(c); if (drawText) { // Figure out animation. long now = SystemClock.uptimeMillis(); while (mAnimStartTime < (now-1000)) { mAnimStartTime += 1000; mAnimLarger = !mAnimLarger; } float size = (now-mAnimStartTime) / (float)1000; if (!mAnimLarger) size = 1-size; int alpha = (int)(255*(size*size)); mTextPaint.setARGB(alpha, 255, 255, 255); mTextPaint.setShadowLayer(5*mDensity, 3*mDensity, 3*mDensity, alpha<<24); mTextPaint.setTextSize(100 * mDensity * size); c.drawText("Am I live?", frame.left + (frame.right-frame.left)/2, frame.top + (frame.bottom-frame.top)/2, mTextPaint); } } sh.unlockCanvasAndPost(c); } } @Override Loading core/res/res/values/attrs.xml +4 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,9 @@ <attr name="windowIsFloating" format="boolean" /> <!-- Flag indicating whether this is a translucent window. --> <attr name="windowIsTranslucent" format="boolean" /> <!-- Flag indicating that this window's background should be the user's current wallpaper. --> <attr name="windowShowWallpaper" format="boolean" /> <!-- This Drawable is overlaid over the foreground of the Window's content area, usually to place a shadow below the title. --> <attr name="windowContentOverlay" format="reference" /> Loading Loading @@ -900,6 +903,7 @@ <attr name="windowFullscreen" /> <attr name="windowIsFloating" /> <attr name="windowIsTranslucent" /> <attr name="windowShowWallpaper" /> <attr name="windowAnimationStyle" /> <attr name="windowSoftInputMode" /> <attr name="windowDisablePreview" /> Loading core/res/res/values/public.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1167,9 +1167,13 @@ <public type="attr" name="accountType" /> <public type="attr" name="contentAuthority" /> <public type="attr" name="windowShowWallpaper" /> <public type="drawable" name="stat_sys_vp_phone_call" /> <public type="drawable" name="stat_sys_vp_phone_call_on_hold" /> <public type="style" name="Theme.Wallpaper" /> <public type="style" name="Theme.Wallpaper.NoTitleBar" /> <public type="style" name="Theme.Wallpaper.NoTitleBar.Fullscreen" /> </resources> Loading
api/current.xml +44 −0 Original line number Diff line number Diff line Loading @@ -9370,6 +9370,17 @@ visibility="public" > </field> <field name="windowShowWallpaper" type="int" transient="false" volatile="false" value="16843426" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="windowSoftInputMode" type="int" transient="false" Loading Loading @@ -15002,6 +15013,39 @@ visibility="public" > </field> <field name="Theme_Wallpaper" type="int" transient="false" volatile="false" value="16973937" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="Theme_Wallpaper_NoTitleBar" type="int" transient="false" volatile="false" value="16973938" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="Theme_Wallpaper_NoTitleBar_Fullscreen" type="int" transient="false" volatile="false" value="16973939" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="Widget" type="int" transient="false"
core/java/android/service/wallpaper/WallpaperService.java +72 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.internal.view.BaseIWindow; import com.android.internal.view.BaseSurfaceHolder; import android.app.Service; import android.app.WallpaperManager; import android.content.Intent; import android.graphics.Rect; import android.os.Handler; Loading Loading @@ -55,12 +56,14 @@ public abstract class WallpaperService extends Service { private static final int DO_DETACH = 20; private static final int MSG_UPDATE_SURFACE = 10000; private static final int MSG_VISIBILITY_CHANGED = 10010; /** * The actual implementation of a wallpaper. A wallpaper service may * have multiple instances running (for example as a real wallpaper * and as a preview), each of which is represented by its own Engine * instance. * instance. You must implement {@link WallpaperService#onCreateEngine()} * to return your concrete Engine implementation. */ public class Engine { IWallpaperEngineWrapper mIWallpaperEngine; Loading Loading @@ -119,21 +122,79 @@ public abstract class WallpaperService extends Service { }; final BaseIWindow mWindow = new BaseIWindow() { public void dispatchAppVisibility(boolean visible) { Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED, visible ? 1 : 0); mCaller.sendMessage(msg); } }; public void onAttach(SurfaceHolder surfaceHolder) { /** * Provides access to the surface in which this wallpaper is drawn. */ public SurfaceHolder getSurfaceHolder() { return mSurfaceHolder; } /** * Convenience for {@link WallpaperManager#getDesiredMinimumWidth() * WallpaperManager.getDesiredMinimumWidth()}, returning the width * that the system would like this wallpaper to run in. */ public int getDesiredMinimumWidth() { return mIWallpaperEngine.mReqWidth; } /** * Convenience for {@link WallpaperManager#getDesiredMinimumHeight() * WallpaperManager.getDesiredMinimumHeight()}, returning the height * that the system would like this wallpaper to run in. */ public int getDesiredMinimumHeight() { return mIWallpaperEngine.mReqHeight; } /** * Called once to initialize the engine. After returning, the * engine's surface will be created by the framework. */ public void onCreate(SurfaceHolder surfaceHolder) { } /** * Called right before the engine is going away. After this the * surface will be destroyed and this Engine object is no longer * valid. */ public void onDestroy() { } public void onDetach() { /** * Called to inform you of the wallpaper becoming visible or * hidden. <em>It is very important that a wallpaper only use * CPU while it is visible.</em>. */ public void onVisibilityChanged(boolean visible) { } /** * Convenience for {@link SurfaceHolder.Callback#surfaceChanged * SurfaceHolder.Callback.surfaceChanged()}. */ public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { } /** * Convenience for {@link SurfaceHolder.Callback#surfaceCreated * SurfaceHolder.Callback.surfaceCreated()}. */ public void onSurfaceCreated(SurfaceHolder holder) { } /** * Convenience for {@link SurfaceHolder.Callback#surfaceDestroyed * SurfaceHolder.Callback.surfaceDestroyed()}. */ public void onSurfaceDestroyed(SurfaceHolder holder) { } Loading Loading @@ -249,14 +310,14 @@ public abstract class WallpaperService extends Service { mSession = ViewRoot.getWindowSession(getMainLooper()); mWindow.setSession(mSession); onAttach(mSurfaceHolder); onCreate(mSurfaceHolder); mInitializing = false; updateSurface(false); } void detach() { onDetach(); onDestroy(); if (mDestroyReportNeeded) { mDestroyReportNeeded = false; SurfaceHolder.Callback callbacks[]; Loading Loading @@ -330,6 +391,11 @@ public abstract class WallpaperService extends Service { case MSG_UPDATE_SURFACE: mEngine.updateSurface(false); break; case MSG_VISIBILITY_CHANGED: if (DEBUG) Log.v(TAG, "Visibility change in " + mEngine + ": " + message.arg1); mEngine.onVisibilityChanged(message.arg1 != 0); break; default : Log.w(TAG, "Unknown message type " + message.what); } Loading
core/java/com/android/internal/service/wallpaper/ImageWallpaper.java +75 −14 Original line number Diff line number Diff line Loading @@ -19,7 +19,11 @@ package com.android.internal.service.wallpaper; import android.app.WallpaperManager; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.service.wallpaper.WallpaperService; import android.view.SurfaceHolder; Loading @@ -29,30 +33,58 @@ import android.view.SurfaceHolder; public class ImageWallpaper extends WallpaperService { public WallpaperManager mWallpaperManager; class MyEngine extends Engine { static final int MSG_DRAW = 1; class MyEngine extends Engine { final Paint mTextPaint = new Paint(); float mDensity; Drawable mBackground; long mAnimStartTime; boolean mAnimLarger; final Handler mHandler = new Handler() { @Override public void onAttach(SurfaceHolder surfaceHolder) { super.onAttach(surfaceHolder); public void handleMessage(Message msg) { switch (msg.what) { case MSG_DRAW: drawFrame(true); mHandler.sendEmptyMessage(MSG_DRAW); break; default: super.handleMessage(msg); } } }; @Override public void onCreate(SurfaceHolder surfaceHolder) { super.onCreate(surfaceHolder); mBackground = mWallpaperManager.getDrawable(); mTextPaint.setAntiAlias(true); mDensity = getResources().getDisplayMetrics().density; mTextPaint.setTextSize(30 * mDensity); mTextPaint.setShadowLayer(5*mDensity, 3*mDensity, 3*mDensity, 0xff000000); mTextPaint.setARGB(255, 255, 255, 255); mTextPaint.setTextAlign(Paint.Align.CENTER); } @Override public void onVisibilityChanged(boolean visible) { mHandler.removeMessages(MSG_DRAW); if (visible) { mHandler.sendEmptyMessage(MSG_DRAW); mAnimStartTime = SystemClock.uptimeMillis(); mAnimLarger = true; } else { drawFrame(false); } } @Override public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { super.onSurfaceChanged(holder, format, width, height); Canvas c = holder.lockCanvas(); mBackground.setBounds(0, 0, width, height); mBackground.draw(c); Paint paint = new Paint(); paint.setAntiAlias(true); final float density = getResources().getDisplayMetrics().density; paint.setTextSize(30 * density); paint.setShadowLayer(5*density, 3*density, 3*density, 0xff000000); paint.setARGB(255, 255, 255, 255); c.drawText("Am I live?", 10, 60*density, paint); holder.unlockCanvasAndPost(c); drawFrame(false); } @Override Loading @@ -65,6 +97,35 @@ public class ImageWallpaper extends WallpaperService { super.onSurfaceDestroyed(holder); } void drawFrame(boolean drawText) { SurfaceHolder sh = getSurfaceHolder(); Canvas c = sh.lockCanvas(); if (c != null) { final Rect frame = sh.getSurfaceFrame(); mBackground.setBounds(frame); mBackground.draw(c); if (drawText) { // Figure out animation. long now = SystemClock.uptimeMillis(); while (mAnimStartTime < (now-1000)) { mAnimStartTime += 1000; mAnimLarger = !mAnimLarger; } float size = (now-mAnimStartTime) / (float)1000; if (!mAnimLarger) size = 1-size; int alpha = (int)(255*(size*size)); mTextPaint.setARGB(alpha, 255, 255, 255); mTextPaint.setShadowLayer(5*mDensity, 3*mDensity, 3*mDensity, alpha<<24); mTextPaint.setTextSize(100 * mDensity * size); c.drawText("Am I live?", frame.left + (frame.right-frame.left)/2, frame.top + (frame.bottom-frame.top)/2, mTextPaint); } } sh.unlockCanvasAndPost(c); } } @Override Loading
core/res/res/values/attrs.xml +4 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,9 @@ <attr name="windowIsFloating" format="boolean" /> <!-- Flag indicating whether this is a translucent window. --> <attr name="windowIsTranslucent" format="boolean" /> <!-- Flag indicating that this window's background should be the user's current wallpaper. --> <attr name="windowShowWallpaper" format="boolean" /> <!-- This Drawable is overlaid over the foreground of the Window's content area, usually to place a shadow below the title. --> <attr name="windowContentOverlay" format="reference" /> Loading Loading @@ -900,6 +903,7 @@ <attr name="windowFullscreen" /> <attr name="windowIsFloating" /> <attr name="windowIsTranslucent" /> <attr name="windowShowWallpaper" /> <attr name="windowAnimationStyle" /> <attr name="windowSoftInputMode" /> <attr name="windowDisablePreview" /> Loading
core/res/res/values/public.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1167,9 +1167,13 @@ <public type="attr" name="accountType" /> <public type="attr" name="contentAuthority" /> <public type="attr" name="windowShowWallpaper" /> <public type="drawable" name="stat_sys_vp_phone_call" /> <public type="drawable" name="stat_sys_vp_phone_call_on_hold" /> <public type="style" name="Theme.Wallpaper" /> <public type="style" name="Theme.Wallpaper.NoTitleBar" /> <public type="style" name="Theme.Wallpaper.NoTitleBar.Fullscreen" /> </resources>