| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server; |
| 18 | |
| 19 | import static android.os.FileObserver.*; |
| 20 | import static android.os.ParcelFileDescriptor.*; |
| Christopher Tate | 111bd4a | 2009-06-24 17:29:38 -0700 | [diff] [blame] | 21 | |
| Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 22 | import android.app.IWallpaperManager; |
| 23 | import android.app.IWallpaperManagerCallback; |
| Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 24 | import android.app.PendingIntent; |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 25 | import android.app.WallpaperInfo; |
| Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 26 | import android.app.backup.BackupManager; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 27 | import android.content.ComponentName; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.content.Context; |
| 29 | import android.content.Intent; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 30 | import android.content.ServiceConnection; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.content.pm.PackageManager; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 32 | import android.content.pm.ResolveInfo; |
| 33 | import android.content.pm.ServiceInfo; |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 34 | import android.content.pm.PackageManager.NameNotFoundException; |
| 35 | import android.content.res.Resources; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | import android.os.Binder; |
| Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 37 | import android.os.Bundle; |
| Dianne Hackborn | 8bdf593 | 2010-10-15 12:54:40 -0700 | [diff] [blame] | 38 | import android.os.FileUtils; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 39 | import android.os.IBinder; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | import android.os.RemoteException; |
| 41 | import android.os.FileObserver; |
| 42 | import android.os.ParcelFileDescriptor; |
| 43 | import android.os.RemoteCallbackList; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 44 | import android.os.ServiceManager; |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 45 | import android.os.SystemClock; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 46 | import android.service.wallpaper.IWallpaperConnection; |
| 47 | import android.service.wallpaper.IWallpaperEngine; |
| 48 | import android.service.wallpaper.IWallpaperService; |
| 49 | import android.service.wallpaper.WallpaperService; |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 50 | import android.util.Slog; |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 51 | import android.util.Xml; |
| Dianne Hackborn | 44bc17c | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 52 | import android.view.Display; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 53 | import android.view.IWindowManager; |
| 54 | import android.view.WindowManager; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 56 | import java.io.FileDescriptor; |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 57 | import java.io.IOException; |
| 58 | import java.io.InputStream; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | import java.io.File; |
| 60 | import java.io.FileNotFoundException; |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 61 | import java.io.FileInputStream; |
| 62 | import java.io.FileOutputStream; |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 63 | import java.io.PrintWriter; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 64 | import java.util.List; |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 65 | |
| 66 | import org.xmlpull.v1.XmlPullParser; |
| 67 | import org.xmlpull.v1.XmlPullParserException; |
| 68 | import org.xmlpull.v1.XmlSerializer; |
| 69 | |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 70 | import com.android.internal.content.PackageMonitor; |
| Dianne Hackborn | 2269d157 | 2010-02-24 19:54:22 -0800 | [diff] [blame] | 71 | import com.android.internal.util.FastXmlSerializer; |
| Dianne Hackborn | 1afd1c9 | 2010-03-18 22:47:17 -0700 | [diff] [blame] | 72 | import com.android.internal.util.JournaledFile; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | |
| Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 74 | class WallpaperManagerService extends IWallpaperManager.Stub { |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 75 | static final String TAG = "WallpaperService"; |
| Dianne Hackborn | cbf1504 | 2009-08-18 18:29:09 -0700 | [diff] [blame] | 76 | static final boolean DEBUG = false; |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 77 | |
| Romain Guy | 407ec78 | 2011-08-24 17:06:58 -0700 | [diff] [blame] | 78 | final Object mLock = new Object[0]; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 80 | /** |
| 81 | * Minimum time between crashes of a wallpaper service for us to consider |
| 82 | * restarting it vs. just reverting to the static wallpaper. |
| 83 | */ |
| 84 | static final long MIN_WALLPAPER_CRASH_TIME = 10000; |
| 85 | |
| 86 | static final File WALLPAPER_DIR = new File( |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | "/data/data/com.android.settings/files"); |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 88 | static final String WALLPAPER = "wallpaper"; |
| 89 | static final File WALLPAPER_FILE = new File(WALLPAPER_DIR, WALLPAPER); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | /** |
| 92 | * List of callbacks registered they should each be notified |
| 93 | * when the wallpaper is changed. |
| 94 | */ |
| Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 95 | private final RemoteCallbackList<IWallpaperManagerCallback> mCallbacks |
| 96 | = new RemoteCallbackList<IWallpaperManagerCallback>(); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 97 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | /** |
| 99 | * Observes the wallpaper for changes and notifies all IWallpaperServiceCallbacks |
| 100 | * that the wallpaper has changed. The CREATE is triggered when there is no |
| 101 | * wallpaper set and is created for the first time. The CLOSE_WRITE is triggered |
| 102 | * everytime the wallpaper is changed. |
| 103 | */ |
| 104 | private final FileObserver mWallpaperObserver = new FileObserver( |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 105 | WALLPAPER_DIR.getAbsolutePath(), CREATE | CLOSE_WRITE | DELETE | DELETE_SELF) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | @Override |
| 107 | public void onEvent(int event, String path) { |
| Joe Onorato | e712ee3 | 2009-07-29 16:23:58 -0700 | [diff] [blame] | 108 | if (path == null) { |
| 109 | return; |
| 110 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 111 | synchronized (mLock) { |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 112 | // changing the wallpaper means we'll need to back up the new one |
| 113 | long origId = Binder.clearCallingIdentity(); |
| 114 | BackupManager bm = new BackupManager(mContext); |
| 115 | bm.dataChanged(); |
| 116 | Binder.restoreCallingIdentity(origId); |
| 117 | |
| 118 | File changedFile = new File(WALLPAPER_DIR, path); |
| 119 | if (WALLPAPER_FILE.equals(changedFile)) { |
| 120 | notifyCallbacksLocked(); |
| Dianne Hackborn | 07213e6 | 2011-08-24 20:05:39 -0700 | [diff] [blame] | 121 | if (mWallpaperComponent == null || mImageWallpaperPending) { |
| 122 | mImageWallpaperPending = false; |
| 123 | bindWallpaperComponentLocked(mImageWallpaperComponent, true); |
| 124 | saveSettingsLocked(); |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 125 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 126 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | }; |
| 130 | |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 131 | final Context mContext; |
| 132 | final IWindowManager mIWindowManager; |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 133 | final MyPackageMonitor mMonitor; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 134 | |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 135 | int mWidth = -1; |
| 136 | int mHeight = -1; |
| Dianne Hackborn | 07213e6 | 2011-08-24 20:05:39 -0700 | [diff] [blame] | 137 | |
| 138 | /** |
| 139 | * Client is currently writing a new image wallpaper. |
| 140 | */ |
| 141 | boolean mImageWallpaperPending; |
| 142 | |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 143 | /** |
| 144 | * Resource name if using a picture from the wallpaper gallery |
| 145 | */ |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 146 | String mName = ""; |
| Mike Cleron | d6c0b84 | 2009-11-13 16:37:27 -0800 | [diff] [blame] | 147 | |
| 148 | /** |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 149 | * The component name of the currently set live wallpaper. |
| Mike Cleron | d6c0b84 | 2009-11-13 16:37:27 -0800 | [diff] [blame] | 150 | */ |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 151 | ComponentName mWallpaperComponent; |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 152 | |
| 153 | /** |
| 154 | * The component name of the wallpaper that should be set next. |
| 155 | */ |
| 156 | ComponentName mNextWallpaperComponent; |
| 157 | |
| 158 | /** |
| 159 | * Name of the component used to display bitmap wallpapers from either the gallery or |
| 160 | * built-in wallpapers. |
| 161 | */ |
| Dianne Hackborn | ba39839 | 2011-08-01 16:11:57 -0700 | [diff] [blame] | 162 | ComponentName mImageWallpaperComponent = new ComponentName("com.android.systemui", |
| 163 | "com.android.systemui.ImageWallpaper"); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 164 | |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 165 | WallpaperConnection mWallpaperConnection; |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 166 | long mLastDiedTime; |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 167 | boolean mWallpaperUpdating; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 168 | |
| 169 | class WallpaperConnection extends IWallpaperConnection.Stub |
| 170 | implements ServiceConnection { |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 171 | final WallpaperInfo mInfo; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 172 | final Binder mToken = new Binder(); |
| 173 | IWallpaperService mService; |
| 174 | IWallpaperEngine mEngine; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 176 | public WallpaperConnection(WallpaperInfo info) { |
| 177 | mInfo = info; |
| 178 | } |
| 179 | |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 180 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 181 | synchronized (mLock) { |
| 182 | if (mWallpaperConnection == this) { |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 183 | mLastDiedTime = SystemClock.uptimeMillis(); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 184 | mService = IWallpaperService.Stub.asInterface(service); |
| 185 | attachServiceLocked(this); |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 186 | // XXX should probably do saveSettingsLocked() later |
| 187 | // when we have an engine, but I'm not sure about |
| 188 | // locking there and anyway we always need to be able to |
| 189 | // recover if there is something wrong. |
| 190 | saveSettingsLocked(); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | public void onServiceDisconnected(ComponentName name) { |
| 196 | synchronized (mLock) { |
| 197 | mService = null; |
| 198 | mEngine = null; |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 199 | if (mWallpaperConnection == this) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 200 | Slog.w(TAG, "Wallpaper service gone: " + mWallpaperComponent); |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 201 | if (!mWallpaperUpdating && (mLastDiedTime+MIN_WALLPAPER_CRASH_TIME) |
| 202 | > SystemClock.uptimeMillis()) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 203 | Slog.w(TAG, "Reverting to built-in wallpaper!"); |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 204 | bindWallpaperComponentLocked(null, true); |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 205 | } |
| 206 | } |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | |
| 210 | public void attachEngine(IWallpaperEngine engine) { |
| 211 | mEngine = engine; |
| 212 | } |
| 213 | |
| 214 | public ParcelFileDescriptor setWallpaper(String name) { |
| 215 | synchronized (mLock) { |
| 216 | if (mWallpaperConnection == this) { |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 217 | return updateWallpaperBitmapLocked(name); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 218 | } |
| 219 | return null; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 224 | class MyPackageMonitor extends PackageMonitor { |
| 225 | @Override |
| 226 | public void onPackageUpdateFinished(String packageName, int uid) { |
| 227 | synchronized (mLock) { |
| 228 | if (mWallpaperComponent != null && |
| 229 | mWallpaperComponent.getPackageName().equals(packageName)) { |
| 230 | mWallpaperUpdating = false; |
| 231 | ComponentName comp = mWallpaperComponent; |
| 232 | clearWallpaperComponentLocked(); |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 233 | bindWallpaperComponentLocked(comp, false); |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public void onPackageUpdateStarted(String packageName, int uid) { |
| 240 | synchronized (mLock) { |
| 241 | if (mWallpaperComponent != null && |
| 242 | mWallpaperComponent.getPackageName().equals(packageName)) { |
| 243 | mWallpaperUpdating = true; |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | @Override |
| 249 | public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) { |
| 250 | return doPackagesChanged(doit); |
| 251 | } |
| 252 | |
| 253 | @Override |
| 254 | public void onSomePackagesChanged() { |
| 255 | doPackagesChanged(true); |
| 256 | } |
| 257 | |
| 258 | boolean doPackagesChanged(boolean doit) { |
| 259 | boolean changed = false; |
| 260 | synchronized (mLock) { |
| 261 | if (mWallpaperComponent != null) { |
| 262 | int change = isPackageDisappearing(mWallpaperComponent.getPackageName()); |
| 263 | if (change == PACKAGE_PERMANENT_CHANGE |
| 264 | || change == PACKAGE_TEMPORARY_CHANGE) { |
| 265 | changed = true; |
| 266 | if (doit) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 267 | Slog.w(TAG, "Wallpaper uninstalled, removing: " + mWallpaperComponent); |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 268 | clearWallpaperLocked(); |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | if (mNextWallpaperComponent != null) { |
| 273 | int change = isPackageDisappearing(mNextWallpaperComponent.getPackageName()); |
| 274 | if (change == PACKAGE_PERMANENT_CHANGE |
| 275 | || change == PACKAGE_TEMPORARY_CHANGE) { |
| 276 | mNextWallpaperComponent = null; |
| 277 | } |
| 278 | } |
| 279 | if (mWallpaperComponent != null |
| 280 | && isPackageModified(mWallpaperComponent.getPackageName())) { |
| 281 | try { |
| 282 | mContext.getPackageManager().getServiceInfo( |
| 283 | mWallpaperComponent, 0); |
| 284 | } catch (NameNotFoundException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 285 | Slog.w(TAG, "Wallpaper component gone, removing: " + mWallpaperComponent); |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 286 | clearWallpaperLocked(); |
| 287 | } |
| 288 | } |
| 289 | if (mNextWallpaperComponent != null |
| 290 | && isPackageModified(mNextWallpaperComponent.getPackageName())) { |
| 291 | try { |
| 292 | mContext.getPackageManager().getServiceInfo( |
| 293 | mNextWallpaperComponent, 0); |
| 294 | } catch (NameNotFoundException e) { |
| 295 | mNextWallpaperComponent = null; |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | return changed; |
| 300 | } |
| 301 | } |
| 302 | |
| Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 303 | public WallpaperManagerService(Context context) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 304 | if (DEBUG) Slog.v(TAG, "WallpaperService startup"); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 305 | mContext = context; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 306 | mIWindowManager = IWindowManager.Stub.asInterface( |
| 307 | ServiceManager.getService(Context.WINDOW_SERVICE)); |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 308 | mMonitor = new MyPackageMonitor(); |
| 309 | mMonitor.register(context, true); |
| Joe Onorato | e712ee3 | 2009-07-29 16:23:58 -0700 | [diff] [blame] | 310 | WALLPAPER_DIR.mkdirs(); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 311 | loadSettingsLocked(); |
| Joe Onorato | e712ee3 | 2009-07-29 16:23:58 -0700 | [diff] [blame] | 312 | mWallpaperObserver.startWatching(); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | @Override |
| 316 | protected void finalize() throws Throwable { |
| 317 | super.finalize(); |
| 318 | mWallpaperObserver.stopWatching(); |
| 319 | } |
| 320 | |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 321 | public void systemReady() { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 322 | if (DEBUG) Slog.v(TAG, "systemReady"); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 323 | synchronized (mLock) { |
| 324 | try { |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 325 | bindWallpaperComponentLocked(mNextWallpaperComponent, false); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 326 | } catch (RuntimeException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 327 | Slog.w(TAG, "Failure starting previous wallpaper", e); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 328 | try { |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 329 | bindWallpaperComponentLocked(null, false); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 330 | } catch (RuntimeException e2) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 331 | Slog.w(TAG, "Failure starting default wallpaper", e2); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 332 | clearWallpaperComponentLocked(); |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 338 | public void clearWallpaper() { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 339 | if (DEBUG) Slog.v(TAG, "clearWallpaper"); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 340 | synchronized (mLock) { |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 341 | clearWallpaperLocked(); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | public void clearWallpaperLocked() { |
| 346 | File f = WALLPAPER_FILE; |
| 347 | if (f.exists()) { |
| 348 | f.delete(); |
| 349 | } |
| 350 | final long ident = Binder.clearCallingIdentity(); |
| 351 | try { |
| Dianne Hackborn | 07213e6 | 2011-08-24 20:05:39 -0700 | [diff] [blame] | 352 | mImageWallpaperPending = false; |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 353 | bindWallpaperComponentLocked(null, false); |
| Dianne Hackborn | c9421ba | 2010-03-11 22:23:46 -0800 | [diff] [blame] | 354 | } catch (IllegalArgumentException e) { |
| 355 | // This can happen if the default wallpaper component doesn't |
| 356 | // exist. This should be a system configuration problem, but |
| 357 | // let's not let it crash the system and just live with no |
| 358 | // wallpaper. |
| 359 | Slog.e(TAG, "Default wallpaper component not found!", e); |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 360 | } finally { |
| 361 | Binder.restoreCallingIdentity(ident); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | |
| 365 | public void setDimensionHints(int width, int height) throws RemoteException { |
| 366 | checkPermission(android.Manifest.permission.SET_WALLPAPER_HINTS); |
| 367 | |
| 368 | if (width <= 0 || height <= 0) { |
| 369 | throw new IllegalArgumentException("width and height must be > 0"); |
| 370 | } |
| 371 | |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 372 | synchronized (mLock) { |
| 373 | if (width != mWidth || height != mHeight) { |
| 374 | mWidth = width; |
| 375 | mHeight = height; |
| 376 | saveSettingsLocked(); |
| Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 377 | if (mWallpaperConnection != null) { |
| 378 | if (mWallpaperConnection.mEngine != null) { |
| 379 | try { |
| 380 | mWallpaperConnection.mEngine.setDesiredSize( |
| 381 | width, height); |
| 382 | } catch (RemoteException e) { |
| 383 | } |
| 384 | notifyCallbacksLocked(); |
| 385 | } |
| 386 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 387 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | |
| 391 | public int getWidthHint() throws RemoteException { |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 392 | synchronized (mLock) { |
| 393 | return mWidth; |
| 394 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | public int getHeightHint() throws RemoteException { |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 398 | synchronized (mLock) { |
| 399 | return mHeight; |
| 400 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | } |
| 402 | |
| Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 403 | public ParcelFileDescriptor getWallpaper(IWallpaperManagerCallback cb, |
| 404 | Bundle outParams) { |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 405 | synchronized (mLock) { |
| 406 | try { |
| Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 407 | if (outParams != null) { |
| 408 | outParams.putInt("width", mWidth); |
| 409 | outParams.putInt("height", mHeight); |
| 410 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 411 | mCallbacks.register(cb); |
| 412 | File f = WALLPAPER_FILE; |
| 413 | if (!f.exists()) { |
| 414 | return null; |
| 415 | } |
| 416 | return ParcelFileDescriptor.open(f, MODE_READ_ONLY); |
| 417 | } catch (FileNotFoundException e) { |
| 418 | /* Shouldn't happen as we check to see if the file exists */ |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 419 | Slog.w(TAG, "Error getting wallpaper", e); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 420 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 421 | return null; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 422 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 423 | } |
| 424 | |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 425 | public WallpaperInfo getWallpaperInfo() { |
| 426 | synchronized (mLock) { |
| 427 | if (mWallpaperConnection != null) { |
| 428 | return mWallpaperConnection.mInfo; |
| 429 | } |
| 430 | return null; |
| 431 | } |
| 432 | } |
| 433 | |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 434 | public ParcelFileDescriptor setWallpaper(String name) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 435 | if (DEBUG) Slog.v(TAG, "setWallpaper"); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 436 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 437 | checkPermission(android.Manifest.permission.SET_WALLPAPER); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 438 | synchronized (mLock) { |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 439 | final long ident = Binder.clearCallingIdentity(); |
| 440 | try { |
| 441 | ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name); |
| 442 | if (pfd != null) { |
| Dianne Hackborn | 07213e6 | 2011-08-24 20:05:39 -0700 | [diff] [blame] | 443 | mImageWallpaperPending = true; |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 444 | } |
| 445 | return pfd; |
| 446 | } finally { |
| 447 | Binder.restoreCallingIdentity(ident); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 448 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 449 | } |
| 450 | } |
| 451 | |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 452 | ParcelFileDescriptor updateWallpaperBitmapLocked(String name) { |
| 453 | if (name == null) name = ""; |
| 454 | try { |
| 455 | ParcelFileDescriptor fd = ParcelFileDescriptor.open(WALLPAPER_FILE, |
| 456 | MODE_CREATE|MODE_READ_WRITE); |
| 457 | mName = name; |
| 458 | return fd; |
| 459 | } catch (FileNotFoundException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 460 | Slog.w(TAG, "Error setting wallpaper", e); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 461 | } |
| 462 | return null; |
| 463 | } |
| 464 | |
| 465 | public void setWallpaperComponent(ComponentName name) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 466 | if (DEBUG) Slog.v(TAG, "setWallpaperComponent name=" + name); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 467 | checkPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT); |
| 468 | synchronized (mLock) { |
| 469 | final long ident = Binder.clearCallingIdentity(); |
| 470 | try { |
| Dianne Hackborn | 07213e6 | 2011-08-24 20:05:39 -0700 | [diff] [blame] | 471 | mImageWallpaperPending = false; |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 472 | bindWallpaperComponentLocked(name, false); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 473 | } finally { |
| 474 | Binder.restoreCallingIdentity(ident); |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 479 | void bindWallpaperComponentLocked(ComponentName componentName, boolean force) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 480 | if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 481 | |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 482 | // Has the component changed? |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 483 | if (!force) { |
| 484 | if (mWallpaperConnection != null) { |
| 485 | if (mWallpaperComponent == null) { |
| 486 | if (componentName == null) { |
| 487 | if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: still using default"); |
| 488 | // Still using default wallpaper. |
| 489 | return; |
| 490 | } |
| 491 | } else if (mWallpaperComponent.equals(componentName)) { |
| 492 | // Changing to same wallpaper. |
| 493 | if (DEBUG) Slog.v(TAG, "same wallpaper"); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 494 | return; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 495 | } |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 496 | } |
| 497 | } |
| 498 | |
| 499 | try { |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 500 | if (componentName == null) { |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 501 | String defaultComponent = |
| 502 | mContext.getString(com.android.internal.R.string.default_wallpaper_component); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 503 | if (defaultComponent != null) { |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 504 | // See if there is a default wallpaper component specified |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 505 | componentName = ComponentName.unflattenFromString(defaultComponent); |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 506 | if (DEBUG) Slog.v(TAG, "Use default component wallpaper:" + componentName); |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 507 | } |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 508 | if (componentName == null) { |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 509 | // Fall back to static image wallpaper |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 510 | componentName = mImageWallpaperComponent; |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 511 | //clearWallpaperComponentLocked(); |
| 512 | //return; |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 513 | if (DEBUG) Slog.v(TAG, "Using image wallpaper"); |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 514 | } |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 515 | } |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 516 | ServiceInfo si = mContext.getPackageManager().getServiceInfo(componentName, |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 517 | PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS); |
| 518 | if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) { |
| 519 | throw new SecurityException("Selected service does not require " |
| 520 | + android.Manifest.permission.BIND_WALLPAPER |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 521 | + ": " + componentName); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 524 | WallpaperInfo wi = null; |
| 525 | |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 526 | Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 527 | if (componentName != null && !componentName.equals(mImageWallpaperComponent)) { |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 528 | // Make sure the selected service is actually a wallpaper service. |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 529 | List<ResolveInfo> ris = mContext.getPackageManager() |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 530 | .queryIntentServices(intent, PackageManager.GET_META_DATA); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 531 | for (int i=0; i<ris.size(); i++) { |
| 532 | ServiceInfo rsi = ris.get(i).serviceInfo; |
| 533 | if (rsi.name.equals(si.name) && |
| 534 | rsi.packageName.equals(si.packageName)) { |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 535 | try { |
| 536 | wi = new WallpaperInfo(mContext, ris.get(i)); |
| 537 | } catch (XmlPullParserException e) { |
| 538 | throw new IllegalArgumentException(e); |
| 539 | } catch (IOException e) { |
| 540 | throw new IllegalArgumentException(e); |
| 541 | } |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 542 | break; |
| 543 | } |
| 544 | } |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 545 | if (wi == null) { |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 546 | throw new SecurityException("Selected service is not a wallpaper: " |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 547 | + componentName); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 548 | } |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 549 | } |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 550 | |
| 551 | // Bind the service! |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 552 | if (DEBUG) Slog.v(TAG, "Binding to:" + componentName); |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 553 | WallpaperConnection newConn = new WallpaperConnection(wi); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 554 | intent.setComponent(componentName); |
| Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 555 | intent.putExtra(Intent.EXTRA_CLIENT_LABEL, |
| 556 | com.android.internal.R.string.wallpaper_binding_label); |
| 557 | intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity( |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 558 | mContext, 0, |
| 559 | Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER), |
| 560 | mContext.getText(com.android.internal.R.string.chooser_wallpaper)), |
| 561 | 0)); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 562 | if (!mContext.bindService(intent, newConn, |
| 563 | Context.BIND_AUTO_CREATE)) { |
| 564 | throw new IllegalArgumentException("Unable to bind service: " |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 565 | + componentName); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | clearWallpaperComponentLocked(); |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 569 | mWallpaperComponent = componentName; |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 570 | mWallpaperConnection = newConn; |
| Dianne Hackborn | 0cd4887 | 2009-08-13 18:51:59 -0700 | [diff] [blame] | 571 | mLastDiedTime = SystemClock.uptimeMillis(); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 572 | try { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 573 | if (DEBUG) Slog.v(TAG, "Adding window token: " + newConn.mToken); |
| Dianne Hackborn | f21adf6 | 2009-08-13 10:20:21 -0700 | [diff] [blame] | 574 | mIWindowManager.addWindowToken(newConn.mToken, |
| 575 | WindowManager.LayoutParams.TYPE_WALLPAPER); |
| 576 | } catch (RemoteException e) { |
| 577 | } |
| 578 | |
| 579 | } catch (PackageManager.NameNotFoundException e) { |
| Mike Cleron | 322b6ee | 2009-11-12 07:45:47 -0800 | [diff] [blame] | 580 | throw new IllegalArgumentException("Unknown component " + componentName); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 581 | } |
| 582 | } |
| 583 | |
| 584 | void clearWallpaperComponentLocked() { |
| 585 | mWallpaperComponent = null; |
| 586 | if (mWallpaperConnection != null) { |
| 587 | if (mWallpaperConnection.mEngine != null) { |
| 588 | try { |
| 589 | mWallpaperConnection.mEngine.destroy(); |
| 590 | } catch (RemoteException e) { |
| 591 | } |
| 592 | } |
| 593 | mContext.unbindService(mWallpaperConnection); |
| Dianne Hackborn | e9e9bca | 2009-08-18 15:08:22 -0700 | [diff] [blame] | 594 | try { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 595 | if (DEBUG) Slog.v(TAG, "Removing window token: " |
| Dianne Hackborn | e9e9bca | 2009-08-18 15:08:22 -0700 | [diff] [blame] | 596 | + mWallpaperConnection.mToken); |
| 597 | mIWindowManager.removeWindowToken(mWallpaperConnection.mToken); |
| 598 | } catch (RemoteException e) { |
| 599 | } |
| Vairavan Srinivasan | fdfc1b2 | 2010-12-23 14:05:44 -0800 | [diff] [blame] | 600 | mWallpaperConnection.mService = null; |
| 601 | mWallpaperConnection.mEngine = null; |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 602 | mWallpaperConnection = null; |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | void attachServiceLocked(WallpaperConnection conn) { |
| 607 | try { |
| Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 608 | conn.mService.attach(conn, conn.mToken, |
| 609 | WindowManager.LayoutParams.TYPE_WALLPAPER, false, |
| 610 | mWidth, mHeight); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 611 | } catch (RemoteException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 612 | Slog.w(TAG, "Failed attaching wallpaper; clearing", e); |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 613 | if (!mWallpaperUpdating) { |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 614 | bindWallpaperComponentLocked(null, false); |
| Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 615 | } |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 616 | } |
| 617 | } |
| 618 | |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 619 | private void notifyCallbacksLocked() { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 620 | final int n = mCallbacks.beginBroadcast(); |
| 621 | for (int i = 0; i < n; i++) { |
| 622 | try { |
| 623 | mCallbacks.getBroadcastItem(i).onWallpaperChanged(); |
| 624 | } catch (RemoteException e) { |
| 625 | |
| 626 | // The RemoteCallbackList will take care of removing |
| 627 | // the dead object for us. |
| 628 | } |
| 629 | } |
| 630 | mCallbacks.finishBroadcast(); |
| 631 | final Intent intent = new Intent(Intent.ACTION_WALLPAPER_CHANGED); |
| 632 | mContext.sendBroadcast(intent); |
| 633 | } |
| 634 | |
| 635 | private void checkPermission(String permission) { |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 636 | if (PackageManager.PERMISSION_GRANTED!= mContext.checkCallingOrSelfPermission(permission)) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 637 | throw new SecurityException("Access denied to process: " + Binder.getCallingPid() |
| 638 | + ", must have permission " + permission); |
| 639 | } |
| 640 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 641 | |
| 642 | private static JournaledFile makeJournaledFile() { |
| 643 | final String base = "/data/system/wallpaper_info.xml"; |
| 644 | return new JournaledFile(new File(base), new File(base + ".tmp")); |
| 645 | } |
| 646 | |
| 647 | private void saveSettingsLocked() { |
| 648 | JournaledFile journal = makeJournaledFile(); |
| 649 | FileOutputStream stream = null; |
| 650 | try { |
| 651 | stream = new FileOutputStream(journal.chooseForWrite(), false); |
| 652 | XmlSerializer out = new FastXmlSerializer(); |
| 653 | out.setOutput(stream, "utf-8"); |
| 654 | out.startDocument(null, true); |
| 655 | |
| 656 | out.startTag(null, "wp"); |
| 657 | out.attribute(null, "width", Integer.toString(mWidth)); |
| 658 | out.attribute(null, "height", Integer.toString(mHeight)); |
| 659 | out.attribute(null, "name", mName); |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 660 | if (mWallpaperComponent != null && |
| 661 | !mWallpaperComponent.equals(mImageWallpaperComponent)) { |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 662 | out.attribute(null, "component", |
| 663 | mWallpaperComponent.flattenToShortString()); |
| 664 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 665 | out.endTag(null, "wp"); |
| 666 | |
| 667 | out.endDocument(); |
| 668 | stream.close(); |
| 669 | journal.commit(); |
| 670 | } catch (IOException e) { |
| 671 | try { |
| 672 | if (stream != null) { |
| 673 | stream.close(); |
| 674 | } |
| 675 | } catch (IOException ex) { |
| 676 | // Ignore |
| 677 | } |
| 678 | journal.rollback(); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | private void loadSettingsLocked() { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 683 | if (DEBUG) Slog.v(TAG, "loadSettingsLocked"); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 684 | |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 685 | JournaledFile journal = makeJournaledFile(); |
| 686 | FileInputStream stream = null; |
| 687 | File file = journal.chooseForRead(); |
| 688 | boolean success = false; |
| 689 | try { |
| 690 | stream = new FileInputStream(file); |
| 691 | XmlPullParser parser = Xml.newPullParser(); |
| 692 | parser.setInput(stream, null); |
| 693 | |
| 694 | int type; |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 695 | do { |
| 696 | type = parser.next(); |
| 697 | if (type == XmlPullParser.START_TAG) { |
| 698 | String tag = parser.getName(); |
| 699 | if ("wp".equals(tag)) { |
| 700 | mWidth = Integer.parseInt(parser.getAttributeValue(null, "width")); |
| 701 | mHeight = Integer.parseInt(parser.getAttributeValue(null, "height")); |
| 702 | mName = parser.getAttributeValue(null, "name"); |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 703 | String comp = parser.getAttributeValue(null, "component"); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 704 | mNextWallpaperComponent = comp != null |
| Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 705 | ? ComponentName.unflattenFromString(comp) |
| 706 | : null; |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 707 | if (mNextWallpaperComponent == null || |
| 708 | "android".equals(mNextWallpaperComponent.getPackageName())) { |
| 709 | mNextWallpaperComponent = mImageWallpaperComponent; |
| 710 | } |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 711 | |
| 712 | if (DEBUG) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 713 | Slog.v(TAG, "mWidth:" + mWidth); |
| 714 | Slog.v(TAG, "mHeight:" + mHeight); |
| 715 | Slog.v(TAG, "mName:" + mName); |
| 716 | Slog.v(TAG, "mNextWallpaperComponent:" + mNextWallpaperComponent); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 717 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 718 | } |
| 719 | } |
| 720 | } while (type != XmlPullParser.END_DOCUMENT); |
| 721 | success = true; |
| 722 | } catch (NullPointerException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 723 | Slog.w(TAG, "failed parsing " + file + " " + e); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 724 | } catch (NumberFormatException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 725 | Slog.w(TAG, "failed parsing " + file + " " + e); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 726 | } catch (XmlPullParserException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 727 | Slog.w(TAG, "failed parsing " + file + " " + e); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 728 | } catch (IOException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 729 | Slog.w(TAG, "failed parsing " + file + " " + e); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 730 | } catch (IndexOutOfBoundsException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 731 | Slog.w(TAG, "failed parsing " + file + " " + e); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 732 | } |
| 733 | try { |
| 734 | if (stream != null) { |
| 735 | stream.close(); |
| 736 | } |
| 737 | } catch (IOException e) { |
| 738 | // Ignore |
| 739 | } |
| 740 | |
| 741 | if (!success) { |
| 742 | mWidth = -1; |
| 743 | mHeight = -1; |
| 744 | mName = ""; |
| 745 | } |
| Dianne Hackborn | 44bc17c | 2011-04-20 18:18:51 -0700 | [diff] [blame] | 746 | |
| 747 | // We always want to have some reasonable width hint. |
| 748 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
| 749 | Display d = wm.getDefaultDisplay(); |
| 750 | int baseSize = d.getMaximumSizeDimension(); |
| 751 | if (mWidth < baseSize) { |
| 752 | mWidth = baseSize; |
| 753 | } |
| 754 | if (mHeight < baseSize) { |
| 755 | mHeight = baseSize; |
| 756 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 757 | } |
| 758 | |
| Brad Fitzpatrick | 194b19a | 2010-09-14 11:30:29 -0700 | [diff] [blame] | 759 | // Called by SystemBackupAgent after files are restored to disk. |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 760 | void settingsRestored() { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 761 | if (DEBUG) Slog.v(TAG, "settingsRestored"); |
| Brad Fitzpatrick | 194b19a | 2010-09-14 11:30:29 -0700 | [diff] [blame] | 762 | |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 763 | boolean success = false; |
| 764 | synchronized (mLock) { |
| 765 | loadSettingsLocked(); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 766 | if (mNextWallpaperComponent != null && |
| 767 | !mNextWallpaperComponent.equals(mImageWallpaperComponent)) { |
| Christopher Tate | e3ab4d0 | 2009-12-16 14:03:31 -0800 | [diff] [blame] | 768 | try { |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 769 | bindWallpaperComponentLocked(mNextWallpaperComponent, false); |
| Christopher Tate | e3ab4d0 | 2009-12-16 14:03:31 -0800 | [diff] [blame] | 770 | } catch (IllegalArgumentException e) { |
| 771 | // No such live wallpaper or other failure; fall back to the default |
| 772 | // live wallpaper (since the profile being restored indicated that the |
| 773 | // user had selected a live rather than static one). |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 774 | bindWallpaperComponentLocked(null, false); |
| Christopher Tate | e3ab4d0 | 2009-12-16 14:03:31 -0800 | [diff] [blame] | 775 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 776 | success = true; |
| 777 | } else { |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 778 | // If there's a wallpaper name, we use that. If that can't be loaded, then we |
| 779 | // use the default. |
| 780 | if ("".equals(mName)) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 781 | if (DEBUG) Slog.v(TAG, "settingsRestored: name is empty"); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 782 | success = true; |
| 783 | } else { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 784 | if (DEBUG) Slog.v(TAG, "settingsRestored: attempting to restore named resource"); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 785 | success = restoreNamedResourceLocked(); |
| 786 | } |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 787 | if (DEBUG) Slog.v(TAG, "settingsRestored: success=" + success); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 788 | if (success) { |
| Dianne Hackborn | 9ea3163 | 2011-08-05 14:43:50 -0700 | [diff] [blame] | 789 | bindWallpaperComponentLocked(null, false); |
| Mike Cleron | a428b2c | 2009-11-15 22:53:08 -0800 | [diff] [blame] | 790 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 791 | } |
| 792 | } |
| 793 | |
| 794 | if (!success) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 795 | Slog.e(TAG, "Failed to restore wallpaper: '" + mName + "'"); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 796 | mName = ""; |
| 797 | WALLPAPER_FILE.delete(); |
| 798 | } |
| Brad Fitzpatrick | 194b19a | 2010-09-14 11:30:29 -0700 | [diff] [blame] | 799 | |
| 800 | synchronized (mLock) { |
| 801 | saveSettingsLocked(); |
| 802 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 803 | } |
| 804 | |
| 805 | boolean restoreNamedResourceLocked() { |
| 806 | if (mName.length() > 4 && "res:".equals(mName.substring(0, 4))) { |
| 807 | String resName = mName.substring(4); |
| 808 | |
| 809 | String pkg = null; |
| 810 | int colon = resName.indexOf(':'); |
| 811 | if (colon > 0) { |
| 812 | pkg = resName.substring(0, colon); |
| 813 | } |
| 814 | |
| 815 | String ident = null; |
| 816 | int slash = resName.lastIndexOf('/'); |
| 817 | if (slash > 0) { |
| 818 | ident = resName.substring(slash+1); |
| 819 | } |
| 820 | |
| 821 | String type = null; |
| 822 | if (colon > 0 && slash > 0 && (slash-colon) > 1) { |
| 823 | type = resName.substring(colon+1, slash); |
| 824 | } |
| 825 | |
| 826 | if (pkg != null && ident != null && type != null) { |
| 827 | int resId = -1; |
| 828 | InputStream res = null; |
| 829 | FileOutputStream fos = null; |
| 830 | try { |
| 831 | Context c = mContext.createPackageContext(pkg, Context.CONTEXT_RESTRICTED); |
| 832 | Resources r = c.getResources(); |
| 833 | resId = r.getIdentifier(resName, null, null); |
| 834 | if (resId == 0) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 835 | Slog.e(TAG, "couldn't resolve identifier pkg=" + pkg + " type=" + type |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 836 | + " ident=" + ident); |
| 837 | return false; |
| 838 | } |
| 839 | |
| 840 | res = r.openRawResource(resId); |
| Dianne Hackborn | 1afd1c9 | 2010-03-18 22:47:17 -0700 | [diff] [blame] | 841 | if (WALLPAPER_FILE.exists()) { |
| 842 | WALLPAPER_FILE.delete(); |
| 843 | } |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 844 | fos = new FileOutputStream(WALLPAPER_FILE); |
| 845 | |
| 846 | byte[] buffer = new byte[32768]; |
| 847 | int amt; |
| 848 | while ((amt=res.read(buffer)) > 0) { |
| 849 | fos.write(buffer, 0, amt); |
| 850 | } |
| 851 | // mWallpaperObserver will notice the close and send the change broadcast |
| 852 | |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 853 | Slog.v(TAG, "Restored wallpaper: " + resName); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 854 | return true; |
| 855 | } catch (NameNotFoundException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 856 | Slog.e(TAG, "Package name " + pkg + " not found"); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 857 | } catch (Resources.NotFoundException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 858 | Slog.e(TAG, "Resource not found: " + resId); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 859 | } catch (IOException e) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 860 | Slog.e(TAG, "IOException while restoring wallpaper ", e); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 861 | } finally { |
| 862 | if (res != null) { |
| 863 | try { |
| 864 | res.close(); |
| 865 | } catch (IOException ex) {} |
| 866 | } |
| 867 | if (fos != null) { |
| Dianne Hackborn | 8bdf593 | 2010-10-15 12:54:40 -0700 | [diff] [blame] | 868 | FileUtils.sync(fos); |
| Joe Onorato | 9bb8fd7 | 2009-07-28 18:24:51 -0700 | [diff] [blame] | 869 | try { |
| 870 | fos.close(); |
| 871 | } catch (IOException ex) {} |
| 872 | } |
| 873 | } |
| 874 | } |
| 875 | } |
| 876 | return false; |
| 877 | } |
| Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 878 | |
| 879 | @Override |
| 880 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 881 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 882 | != PackageManager.PERMISSION_GRANTED) { |
| 883 | |
| 884 | pw.println("Permission Denial: can't dump wallpaper service from from pid=" |
| 885 | + Binder.getCallingPid() |
| 886 | + ", uid=" + Binder.getCallingUid()); |
| 887 | return; |
| 888 | } |
| 889 | |
| 890 | synchronized (mLock) { |
| 891 | pw.println("Current Wallpaper Service state:"); |
| 892 | pw.print(" mWidth="); pw.print(mWidth); |
| 893 | pw.print(" mHeight="); pw.println(mHeight); |
| 894 | pw.print(" mName="); pw.println(mName); |
| 895 | pw.print(" mWallpaperComponent="); pw.println(mWallpaperComponent); |
| 896 | if (mWallpaperConnection != null) { |
| 897 | WallpaperConnection conn = mWallpaperConnection; |
| 898 | pw.print(" Wallpaper connection "); |
| 899 | pw.print(conn); pw.println(":"); |
| 900 | pw.print(" mInfo.component="); pw.println(conn.mInfo.getComponent()); |
| 901 | pw.print(" mToken="); pw.println(conn.mToken); |
| 902 | pw.print(" mService="); pw.println(conn.mService); |
| 903 | pw.print(" mEngine="); pw.println(conn.mEngine); |
| 904 | pw.print(" mLastDiedTime="); |
| 905 | pw.println(mLastDiedTime - SystemClock.uptimeMillis()); |
| 906 | } |
| 907 | } |
| 908 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 909 | } |