am 27d6e65b: Merge change I322b6ee7 into eclair

Merge commit '27d6e65b71f515deafbd93d5aa98732898c34ddf' into eclair-plus-aosp

* commit '27d6e65b71f515deafbd93d5aa98732898c34ddf':
  Add support for making a LiveWallpaper the default 
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 822a59a..0b6f97e 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -214,4 +214,8 @@
          it will be removed when the lower-level touch driver generates better
          data. -->
     <bool name="config_filterTouchEvents">false</bool>
+    
+    <!-- Component name of the default wallpaper. This will be ImageWallpaper if not 
+         specified -->
+    <string name="default_wallpaper_component">@null</string>
 </resources>
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index 4b6049f..5b8e11c 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -164,7 +164,7 @@
                     if ((mLastDiedTime+MIN_WALLPAPER_CRASH_TIME)
                             < SystemClock.uptimeMillis()) {
                         Log.w(TAG, "Reverting to built-in wallpaper!");
-                        bindWallpaperComponentLocked(null);
+                        bindWallpaperComponentLocked(null, false);
                     }
                 }
             }
@@ -203,11 +203,11 @@
     public void systemReady() {
         synchronized (mLock) {
             try {
-                bindWallpaperComponentLocked(mWallpaperComponent);
+                bindWallpaperComponentLocked(mWallpaperComponent, false);
             } catch (RuntimeException e) {
                 Log.w(TAG, "Failure starting previous wallpaper", e);
                 try {
-                    bindWallpaperComponentLocked(null);
+                    bindWallpaperComponentLocked(null, false);
                 } catch (RuntimeException e2) {
                     Log.w(TAG, "Failure starting default wallpaper", e2);
                     clearWallpaperComponentLocked();
@@ -224,7 +224,7 @@
             }
             final long ident = Binder.clearCallingIdentity();
             try {
-                bindWallpaperComponentLocked(null);
+                bindWallpaperComponentLocked(null, false);
             } finally {
                 Binder.restoreCallingIdentity(ident);
             }
@@ -307,7 +307,8 @@
             try {
                 ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name);
                 if (pfd != null) {
-                    bindWallpaperComponentLocked(null);
+                    // Bind the wallpaper to an ImageWallpaper
+                    bindWallpaperComponentLocked(null, true);
                     saveSettingsLocked();
                 }
                 return pfd;
@@ -335,48 +336,57 @@
         synchronized (mLock) {
             final long ident = Binder.clearCallingIdentity();
             try {
-                bindWallpaperComponentLocked(name);
+                bindWallpaperComponentLocked(name, false);
             } finally {
                 Binder.restoreCallingIdentity(ident);
             }
         }
     }
     
-    void bindWallpaperComponentLocked(ComponentName name) {
+    void bindWallpaperComponentLocked(ComponentName componentName, boolean isBitmap) {
         // Has the component changed?
         if (mWallpaperConnection != null) {
             if (mWallpaperComponent == null) {
-                if (name == null) {
+                if (componentName == null) {
                     // Still using default wallpaper.
                     return;
                 }
-            } else if (mWallpaperComponent.equals(name)) {
+            } else if (mWallpaperComponent.equals(componentName)) {
                 // 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());
-                //clearWallpaperComponentLocked();
-                //return;
+            ComponentName realComponentName = componentName;
+            if (realComponentName == null) {
+                String defaultComponent = 
+                    mContext.getString(com.android.internal.R.string.default_wallpaper_component);
+                if (defaultComponent != null && !isBitmap) {
+                    // See if there is a default wallpaper component specified
+                    // Only look for this if the wallpaper is not being set to a bitmap
+                    realComponentName = ComponentName.unflattenFromString(defaultComponent);
+                }
+                if (realComponentName == null) {
+                    // Fall back to static image wallpaper
+                    realComponentName = new ComponentName("android", 
+                            ImageWallpaper.class.getName());
+                    //clearWallpaperComponentLocked();
+                    //return;
+                }
             }
-            ServiceInfo si = mContext.getPackageManager().getServiceInfo(realName,
+            ServiceInfo si = mContext.getPackageManager().getServiceInfo(realComponentName,
                     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);
+                        + ": " + realComponentName);
             }
             
             WallpaperInfo wi = null;
             
             Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
-            if (name != null) {
+            if (componentName != null) {
                 // Make sure the selected service is actually a wallpaper service.
                 List<ResolveInfo> ris = mContext.getPackageManager()
                         .queryIntentServices(intent, PackageManager.GET_META_DATA);
@@ -396,13 +406,13 @@
                 }
                 if (wi == null) {
                     throw new SecurityException("Selected service is not a wallpaper: "
-                            + realName);
+                            + realComponentName);
                 }
             }
             
             // Bind the service!
             WallpaperConnection newConn = new WallpaperConnection(wi);
-            intent.setComponent(realName);
+            intent.setComponent(realComponentName);
             intent.putExtra(Intent.EXTRA_CLIENT_LABEL,
                     com.android.internal.R.string.wallpaper_binding_label);
             intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity(
@@ -413,11 +423,11 @@
             if (!mContext.bindService(intent, newConn,
                     Context.BIND_AUTO_CREATE)) {
                 throw new IllegalArgumentException("Unable to bind service: "
-                        + name);
+                        + componentName);
             }
             
             clearWallpaperComponentLocked();
-            mWallpaperComponent = name;
+            mWallpaperComponent = componentName;
             mWallpaperConnection = newConn;
             mLastDiedTime = SystemClock.uptimeMillis();
             try {
@@ -428,7 +438,7 @@
             }
             
         } catch (PackageManager.NameNotFoundException e) {
-            throw new IllegalArgumentException("Unknown component " + name);
+            throw new IllegalArgumentException("Unknown component " + componentName);
         }
     }
     
@@ -459,7 +469,7 @@
                     mWidth, mHeight);
         } catch (RemoteException e) {
             Log.w(TAG, "Failed attaching wallpaper; clearing", e);
-            bindWallpaperComponentLocked(null);
+            bindWallpaperComponentLocked(null, false);
         }
     }