diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-08-13 10:20:21 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-08-13 17:14:39 -0700 |
commit | f21adf6fc19bc9c6908c6f1aaae203389f104bfa (patch) | |
tree | cb8ef5ad4095de96582b50f51a47bf483abda3be /services | |
parent | 455e3af1f82629d274447cd5d08d3c8dc1c58967 (diff) | |
download | frameworks_base-f21adf6fc19bc9c6908c6f1aaae203389f104bfa.zip frameworks_base-f21adf6fc19bc9c6908c6f1aaae203389f104bfa.tar.gz frameworks_base-f21adf6fc19bc9c6908c6f1aaae203389f104bfa.tar.bz2 |
Always have a wallpaper service running.
Diffstat (limited to 'services')
3 files changed, 85 insertions, 36 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 8919ccc..ad8e892 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -196,6 +196,7 @@ class ServerThread extends Thread { InputMethodManagerService imm = null; AppWidgetService appWidget = null; NotificationManagerService notification = null; + WallpaperManagerService wallpaper = null; if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) { try { @@ -302,7 +303,8 @@ class ServerThread extends Thread { try { Log.i(TAG, "Starting Wallpaper Service"); - ServiceManager.addService(Context.WALLPAPER_SERVICE, new WallpaperManagerService(context)); + wallpaper = new WallpaperManagerService(context); + ServiceManager.addService(Context.WALLPAPER_SERVICE, wallpaper); } catch (Throwable e) { Log.e(TAG, "Failure starting Wallpaper Service", e); } @@ -381,6 +383,7 @@ class ServerThread extends Thread { } catch (RemoteException e) { } + if (wallpaper != null) wallpaper.systemReady(); battery.systemReady(); Watchdog.getInstance().start(); diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java index 06565c7..9fe4eee 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/WallpaperManagerService.java @@ -59,6 +59,7 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlSerializer; +import com.android.internal.service.wallpaper.ImageWallpaper; import com.android.internal.util.FastXmlSerializer; class WallpaperManagerService extends IWallpaperManager.Stub { @@ -172,12 +173,29 @@ class WallpaperManagerService extends IWallpaperManager.Stub { mWallpaperObserver.stopWatching(); } + public void systemReady() { + synchronized (mLock) { + try { + bindWallpaperComponentLocked(mWallpaperComponent); + } catch (RuntimeException e) { + Log.w(TAG, "Failure starting previous wallpaper", e); + try { + bindWallpaperComponentLocked(null); + } catch (RuntimeException e2) { + Log.w(TAG, "Failure starting default wallpaper", e2); + clearWallpaperComponentLocked(); + } + } + } + } + public void clearWallpaper() { synchronized (mLock) { File f = WALLPAPER_FILE; if (f.exists()) { f.delete(); } + bindWallpaperComponentLocked(null); } } @@ -231,7 +249,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { synchronized (mLock) { ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name); if (pfd != null) { - clearWallpaperComponentLocked(); + bindWallpaperComponentLocked(null); saveSettingsLocked(); } return pfd; @@ -256,16 +274,45 @@ class WallpaperManagerService extends IWallpaperManager.Stub { synchronized (mLock) { final long ident = Binder.clearCallingIdentity(); try { - ServiceInfo si = mContext.getPackageManager().getServiceInfo(name, - PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS); - if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) { - throw new SecurityException("Selected service does not require " - + android.Manifest.permission.BIND_WALLPAPER - + ": " + name); + bindWallpaperComponentLocked(name); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + } + + void bindWallpaperComponentLocked(ComponentName name) { + // Has the component changed? + if (mWallpaperConnection != null) { + if (mWallpaperComponent == null) { + if (name == null) { + // Still using default wallpaper. + return; } - + } else if (mWallpaperComponent.equals(name)) { + // Changing to same wallpaper. + return; + } + } + + try { + ComponentName realName = name; + if (realName == null) { + // The default component is our static image wallpaper. + realName = new ComponentName("android", + ImageWallpaper.class.getName()); + } + ServiceInfo si = mContext.getPackageManager().getServiceInfo(realName, + PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS); + if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) { + throw new SecurityException("Selected service does not require " + + android.Manifest.permission.BIND_WALLPAPER + + ": " + realName); + } + + Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE); + if (name != null) { // Make sure the selected service is actually a wallpaper service. - Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE); List<ResolveInfo> ris = mContext.getPackageManager() .queryIntentServices(intent, 0); for (int i=0; i<ris.size(); i++) { @@ -278,33 +325,31 @@ class WallpaperManagerService extends IWallpaperManager.Stub { } if (ris != null) { throw new SecurityException("Selected service is not a wallpaper: " - + name); - } - - // Bind the service! - WallpaperConnection newConn = new WallpaperConnection(); - intent.setComponent(name); - if (!mContext.bindService(intent, newConn, - Context.BIND_AUTO_CREATE)) { - throw new IllegalArgumentException("Unable to bind service: " - + name); - } - - clearWallpaperComponentLocked(); - mWallpaperComponent = null; - mWallpaperConnection = newConn; - try { - if (DEBUG) Log.v(TAG, "Adding window token: " + newConn.mToken); - mIWindowManager.addWindowToken(newConn.mToken, - WindowManager.LayoutParams.TYPE_WALLPAPER); - } catch (RemoteException e) { + + realName); } - - } catch (PackageManager.NameNotFoundException e) { - throw new IllegalArgumentException("Unknown component " + name); - } finally { - Binder.restoreCallingIdentity(ident); } + + // Bind the service! + WallpaperConnection newConn = new WallpaperConnection(); + intent.setComponent(realName); + if (!mContext.bindService(intent, newConn, + Context.BIND_AUTO_CREATE)) { + throw new IllegalArgumentException("Unable to bind service: " + + name); + } + + clearWallpaperComponentLocked(); + mWallpaperComponent = name; + mWallpaperConnection = newConn; + try { + if (DEBUG) Log.v(TAG, "Adding window token: " + newConn.mToken); + mIWindowManager.addWindowToken(newConn.mToken, + WindowManager.LayoutParams.TYPE_WALLPAPER); + } catch (RemoteException e) { + } + + } catch (PackageManager.NameNotFoundException e) { + throw new IllegalArgumentException("Unknown component " + name); } } @@ -327,7 +372,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { conn.mService.attach(conn, conn.mToken, mWidth, mHeight); } catch (RemoteException e) { Log.w(TAG, "Failed attaching wallpaper; clearing", e); - clearWallpaperComponentLocked(); + bindWallpaperComponentLocked(null); } } diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index b0f049e..89b8ced 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -9489,6 +9489,7 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" mFocusedApp="); pw.println(mFocusedApp); pw.print(" mInputMethodTarget="); pw.println(mInputMethodTarget); pw.print(" mInputMethodWindow="); pw.println(mInputMethodWindow); + pw.print(" mWallpaperTarget="); pw.println(mWallpaperTarget); pw.print(" mInTouchMode="); pw.println(mInTouchMode); pw.print(" mSystemBooted="); pw.print(mSystemBooted); pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled); |