Merge change 21207 into eclair

* changes:
  Always have a wallpaper service running.
This commit is contained in:
Android (Google) Code Review
2009-08-13 17:59:39 -07:00
5 changed files with 86 additions and 39 deletions

View File

@@ -1164,9 +1164,6 @@
<service android:name="com.android.internal.service.wallpaper.ImageWallpaper" <service android:name="com.android.internal.service.wallpaper.ImageWallpaper"
android:permission="android.permission.BIND_WALLPAPER"> android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
</service> </service>
<receiver android:name="com.android.server.BootReceiver" > <receiver android:name="com.android.server.BootReceiver" >

View File

@@ -112,6 +112,7 @@
<item name="windowFullscreen">false</item> <item name="windowFullscreen">false</item>
<item name="windowIsFloating">false</item> <item name="windowIsFloating">false</item>
<item name="windowContentOverlay">@android:drawable/title_bar_shadow</item> <item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>
<item name="windowShowWallpaper">false</item>
<item name="windowTitleStyle">@android:style/WindowTitle</item> <item name="windowTitleStyle">@android:style/WindowTitle</item>
<item name="windowTitleSize">25dip</item> <item name="windowTitleSize">25dip</item>
<item name="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item> <item name="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item>

View File

@@ -196,6 +196,7 @@ class ServerThread extends Thread {
InputMethodManagerService imm = null; InputMethodManagerService imm = null;
AppWidgetService appWidget = null; AppWidgetService appWidget = null;
NotificationManagerService notification = null; NotificationManagerService notification = null;
WallpaperManagerService wallpaper = null;
if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) { if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
try { try {
@@ -302,7 +303,8 @@ class ServerThread extends Thread {
try { try {
Log.i(TAG, "Starting Wallpaper Service"); 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) { } catch (Throwable e) {
Log.e(TAG, "Failure starting Wallpaper Service", e); Log.e(TAG, "Failure starting Wallpaper Service", e);
} }
@@ -381,6 +383,7 @@ class ServerThread extends Thread {
} catch (RemoteException e) { } catch (RemoteException e) {
} }
if (wallpaper != null) wallpaper.systemReady();
battery.systemReady(); battery.systemReady();
Watchdog.getInstance().start(); Watchdog.getInstance().start();

View File

@@ -59,6 +59,7 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer;
import com.android.internal.service.wallpaper.ImageWallpaper;
import com.android.internal.util.FastXmlSerializer; import com.android.internal.util.FastXmlSerializer;
class WallpaperManagerService extends IWallpaperManager.Stub { class WallpaperManagerService extends IWallpaperManager.Stub {
@@ -172,12 +173,29 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
mWallpaperObserver.stopWatching(); 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() { public void clearWallpaper() {
synchronized (mLock) { synchronized (mLock) {
File f = WALLPAPER_FILE; File f = WALLPAPER_FILE;
if (f.exists()) { if (f.exists()) {
f.delete(); f.delete();
} }
bindWallpaperComponentLocked(null);
} }
} }
@@ -231,7 +249,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
synchronized (mLock) { synchronized (mLock) {
ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name); ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name);
if (pfd != null) { if (pfd != null) {
clearWallpaperComponentLocked(); bindWallpaperComponentLocked(null);
saveSettingsLocked(); saveSettingsLocked();
} }
return pfd; return pfd;
@@ -256,16 +274,45 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
synchronized (mLock) { synchronized (mLock) {
final long ident = Binder.clearCallingIdentity(); final long ident = Binder.clearCallingIdentity();
try { try {
ServiceInfo si = mContext.getPackageManager().getServiceInfo(name, bindWallpaperComponentLocked(name);
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS); } finally {
if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) { Binder.restoreCallingIdentity(ident);
throw new SecurityException("Selected service does not require " }
+ android.Manifest.permission.BIND_WALLPAPER }
+ ": " + name); }
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. // Make sure the selected service is actually a wallpaper service.
Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
List<ResolveInfo> ris = mContext.getPackageManager() List<ResolveInfo> ris = mContext.getPackageManager()
.queryIntentServices(intent, 0); .queryIntentServices(intent, 0);
for (int i=0; i<ris.size(); i++) { for (int i=0; i<ris.size(); i++) {
@@ -278,33 +325,31 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
} }
if (ris != null) { if (ris != null) {
throw new SecurityException("Selected service is not a wallpaper: " throw new SecurityException("Selected service is not a wallpaper: "
+ name); + realName);
} }
// 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) {
}
} 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); conn.mService.attach(conn, conn.mToken, mWidth, mHeight);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.w(TAG, "Failed attaching wallpaper; clearing", e); Log.w(TAG, "Failed attaching wallpaper; clearing", e);
clearWallpaperComponentLocked(); bindWallpaperComponentLocked(null);
} }
} }

View File

@@ -9489,6 +9489,7 @@ public class WindowManagerService extends IWindowManager.Stub
pw.print(" mFocusedApp="); pw.println(mFocusedApp); pw.print(" mFocusedApp="); pw.println(mFocusedApp);
pw.print(" mInputMethodTarget="); pw.println(mInputMethodTarget); pw.print(" mInputMethodTarget="); pw.println(mInputMethodTarget);
pw.print(" mInputMethodWindow="); pw.println(mInputMethodWindow); pw.print(" mInputMethodWindow="); pw.println(mInputMethodWindow);
pw.print(" mWallpaperTarget="); pw.println(mWallpaperTarget);
pw.print(" mInTouchMode="); pw.println(mInTouchMode); pw.print(" mInTouchMode="); pw.println(mInTouchMode);
pw.print(" mSystemBooted="); pw.print(mSystemBooted); pw.print(" mSystemBooted="); pw.print(mSystemBooted);
pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled); pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled);