Merge change 21207 into eclair
* changes: Always have a wallpaper service running.
This commit is contained in:
@@ -1164,9 +1164,6 @@
|
||||
|
||||
<service android:name="com.android.internal.service.wallpaper.ImageWallpaper"
|
||||
android:permission="android.permission.BIND_WALLPAPER">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.wallpaper.WallpaperService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<receiver android:name="com.android.server.BootReceiver" >
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
<item name="windowFullscreen">false</item>
|
||||
<item name="windowIsFloating">false</item>
|
||||
<item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>
|
||||
<item name="windowShowWallpaper">false</item>
|
||||
<item name="windowTitleStyle">@android:style/WindowTitle</item>
|
||||
<item name="windowTitleSize">25dip</item>
|
||||
<item name="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item>
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
+ 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);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed attaching wallpaper; clearing", e);
|
||||
clearWallpaperComponentLocked();
|
||||
bindWallpaperComponentLocked(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user