Loading core/java/android/app/WallpaperManager.java +28 −13 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; Loading Loading @@ -58,6 +60,21 @@ public class WallpaperManager { private IWallpaperManager mService; private Bitmap mWallpaper; private static final int MSG_CLEAR_WALLPAPER = 1; private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_CLEAR_WALLPAPER: synchronized (this) { mWallpaper = null; } break; } } }; Globals() { IBinder b = ServiceManager.getService(Context.WALLPAPER_SERVICE); mService = IWallpaperManager.Stub.asInterface(b); Loading @@ -69,9 +86,7 @@ public class WallpaperManager { * to null so if the user requests the wallpaper again then we'll * fetch it. */ synchronized (this) { mWallpaper = null; } mHandler.sendEmptyMessage(MSG_CLEAR_WALLPAPER); } public Bitmap peekWallpaperBitmap(Context context) { Loading Loading @@ -170,17 +185,17 @@ public class WallpaperManager { private static Object mSync = new Object(); private static Globals sGlobals; static Globals getGlobals() { static void initGlobals(Looper looper) { synchronized (mSync) { if (sGlobals == null) { sGlobals = new Globals(); } return sGlobals; } } /*package*/ WallpaperManager(Context context, Handler handler) { mContext = context; initGlobals(context.getMainLooper()); } /** Loading @@ -193,7 +208,7 @@ public class WallpaperManager { /** @hide */ public IWallpaperManager getIWallpaperManager() { return getGlobals().mService; return sGlobals.mService; } /** Loading @@ -218,7 +233,7 @@ public class WallpaperManager { * null pointer if these is none. */ public Drawable peekDrawable() { Bitmap bm = getGlobals().peekWallpaperBitmap(mContext); Bitmap bm = sGlobals.peekWallpaperBitmap(mContext); return bm != null ? new BitmapDrawable(mContext.getResources(), bm) : null; } Loading @@ -237,7 +252,7 @@ public class WallpaperManager { try { Resources resources = mContext.getResources(); /* Set the wallpaper to the default values */ ParcelFileDescriptor fd = getGlobals().mService.setWallpaper( ParcelFileDescriptor fd = sGlobals.mService.setWallpaper( "res:" + resources.getResourceName(resid)); if (fd != null) { FileOutputStream fos = null; Loading Loading @@ -266,7 +281,7 @@ public class WallpaperManager { */ public void setBitmap(Bitmap bitmap) throws IOException { try { ParcelFileDescriptor fd = getGlobals().mService.setWallpaper(null); ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null); if (fd == null) { return; } Loading Loading @@ -297,7 +312,7 @@ public class WallpaperManager { */ public void setStream(InputStream data) throws IOException { try { ParcelFileDescriptor fd = getGlobals().mService.setWallpaper(null); ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null); if (fd == null) { return; } Loading Loading @@ -339,7 +354,7 @@ public class WallpaperManager { */ public int getDesiredMinimumWidth() { try { return getGlobals().mService.getWidthHint(); return sGlobals.mService.getWidthHint(); } catch (RemoteException e) { // Shouldn't happen! return 0; Loading @@ -362,7 +377,7 @@ public class WallpaperManager { */ public int getDesiredMinimumHeight() { try { return getGlobals().mService.getHeightHint(); return sGlobals.mService.getHeightHint(); } catch (RemoteException e) { // Shouldn't happen! return 0; Loading @@ -379,7 +394,7 @@ public class WallpaperManager { */ public void suggestDesiredDimensions(int minimumWidth, int minimumHeight) { try { getGlobals().mService.setDimensionHints(minimumWidth, minimumHeight); sGlobals.mService.setDimensionHints(minimumWidth, minimumHeight); } catch (RemoteException e) { } } Loading Loading
core/java/android/app/WallpaperManager.java +28 −13 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; Loading Loading @@ -58,6 +60,21 @@ public class WallpaperManager { private IWallpaperManager mService; private Bitmap mWallpaper; private static final int MSG_CLEAR_WALLPAPER = 1; private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_CLEAR_WALLPAPER: synchronized (this) { mWallpaper = null; } break; } } }; Globals() { IBinder b = ServiceManager.getService(Context.WALLPAPER_SERVICE); mService = IWallpaperManager.Stub.asInterface(b); Loading @@ -69,9 +86,7 @@ public class WallpaperManager { * to null so if the user requests the wallpaper again then we'll * fetch it. */ synchronized (this) { mWallpaper = null; } mHandler.sendEmptyMessage(MSG_CLEAR_WALLPAPER); } public Bitmap peekWallpaperBitmap(Context context) { Loading Loading @@ -170,17 +185,17 @@ public class WallpaperManager { private static Object mSync = new Object(); private static Globals sGlobals; static Globals getGlobals() { static void initGlobals(Looper looper) { synchronized (mSync) { if (sGlobals == null) { sGlobals = new Globals(); } return sGlobals; } } /*package*/ WallpaperManager(Context context, Handler handler) { mContext = context; initGlobals(context.getMainLooper()); } /** Loading @@ -193,7 +208,7 @@ public class WallpaperManager { /** @hide */ public IWallpaperManager getIWallpaperManager() { return getGlobals().mService; return sGlobals.mService; } /** Loading @@ -218,7 +233,7 @@ public class WallpaperManager { * null pointer if these is none. */ public Drawable peekDrawable() { Bitmap bm = getGlobals().peekWallpaperBitmap(mContext); Bitmap bm = sGlobals.peekWallpaperBitmap(mContext); return bm != null ? new BitmapDrawable(mContext.getResources(), bm) : null; } Loading @@ -237,7 +252,7 @@ public class WallpaperManager { try { Resources resources = mContext.getResources(); /* Set the wallpaper to the default values */ ParcelFileDescriptor fd = getGlobals().mService.setWallpaper( ParcelFileDescriptor fd = sGlobals.mService.setWallpaper( "res:" + resources.getResourceName(resid)); if (fd != null) { FileOutputStream fos = null; Loading Loading @@ -266,7 +281,7 @@ public class WallpaperManager { */ public void setBitmap(Bitmap bitmap) throws IOException { try { ParcelFileDescriptor fd = getGlobals().mService.setWallpaper(null); ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null); if (fd == null) { return; } Loading Loading @@ -297,7 +312,7 @@ public class WallpaperManager { */ public void setStream(InputStream data) throws IOException { try { ParcelFileDescriptor fd = getGlobals().mService.setWallpaper(null); ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null); if (fd == null) { return; } Loading Loading @@ -339,7 +354,7 @@ public class WallpaperManager { */ public int getDesiredMinimumWidth() { try { return getGlobals().mService.getWidthHint(); return sGlobals.mService.getWidthHint(); } catch (RemoteException e) { // Shouldn't happen! return 0; Loading @@ -362,7 +377,7 @@ public class WallpaperManager { */ public int getDesiredMinimumHeight() { try { return getGlobals().mService.getHeightHint(); return sGlobals.mService.getHeightHint(); } catch (RemoteException e) { // Shouldn't happen! return 0; Loading @@ -379,7 +394,7 @@ public class WallpaperManager { */ public void suggestDesiredDimensions(int minimumWidth, int minimumHeight) { try { getGlobals().mService.setDimensionHints(minimumWidth, minimumHeight); sGlobals.mService.setDimensionHints(minimumWidth, minimumHeight); } catch (RemoteException e) { } } Loading