blob: d97d335a1d5c1ae7f6f7cd66a834c8c09e7734f5 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package com.android.server;
18
19import static android.os.FileObserver.*;
20import static android.os.ParcelFileDescriptor.*;
Christopher Tate111bd4a2009-06-24 17:29:38 -070021
Dianne Hackborn8cc6a502009-08-05 21:29:42 -070022import android.app.IWallpaperManager;
23import android.app.IWallpaperManagerCallback;
Dianne Hackborndd9b82c2009-09-03 00:18:47 -070024import android.app.PendingIntent;
Dianne Hackborneb034652009-09-07 00:49:58 -070025import android.app.WallpaperInfo;
Christopher Tate45281862010-03-05 15:46:30 -080026import android.app.backup.BackupManager;
Amith Yamasani37ce3a82012-02-06 12:04:42 -080027import android.app.backup.WallpaperBackupHelper;
Amith Yamasani13593602012-03-22 16:16:17 -070028import android.content.BroadcastReceiver;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070029import android.content.ComponentName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.content.Context;
31import android.content.Intent;
Amith Yamasani13593602012-03-22 16:16:17 -070032import android.content.IntentFilter;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070033import android.content.ServiceConnection;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.content.pm.PackageManager;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070035import android.content.pm.ResolveInfo;
36import android.content.pm.ServiceInfo;
Joe Onorato9bb8fd72009-07-28 18:24:51 -070037import android.content.pm.PackageManager.NameNotFoundException;
38import android.content.res.Resources;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039import android.os.Binder;
Dianne Hackborn284ac932009-08-28 10:34:25 -070040import android.os.Bundle;
Amith Yamasani13593602012-03-22 16:16:17 -070041import android.os.Environment;
Dianne Hackborn8bdf5932010-10-15 12:54:40 -070042import android.os.FileUtils;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070043import android.os.IBinder;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044import android.os.RemoteException;
45import android.os.FileObserver;
46import android.os.ParcelFileDescriptor;
47import android.os.RemoteCallbackList;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070048import android.os.ServiceManager;
Dianne Hackborn0cd48872009-08-13 18:51:59 -070049import android.os.SystemClock;
Amith Yamasani37ce3a82012-02-06 12:04:42 -080050import android.os.UserId;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070051import android.service.wallpaper.IWallpaperConnection;
52import android.service.wallpaper.IWallpaperEngine;
53import android.service.wallpaper.IWallpaperService;
54import android.service.wallpaper.WallpaperService;
Joe Onorato8a9b2202010-02-26 18:56:32 -080055import android.util.Slog;
Amith Yamasani37ce3a82012-02-06 12:04:42 -080056import android.util.SparseArray;
Joe Onorato9bb8fd72009-07-28 18:24:51 -070057import android.util.Xml;
Dianne Hackborn44bc17c2011-04-20 18:18:51 -070058import android.view.Display;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070059import android.view.IWindowManager;
60import android.view.WindowManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061
Dianne Hackborneb034652009-09-07 00:49:58 -070062import java.io.FileDescriptor;
Joe Onorato9bb8fd72009-07-28 18:24:51 -070063import java.io.IOException;
64import java.io.InputStream;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065import java.io.File;
66import java.io.FileNotFoundException;
Joe Onorato9bb8fd72009-07-28 18:24:51 -070067import java.io.FileInputStream;
68import java.io.FileOutputStream;
Dianne Hackborneb034652009-09-07 00:49:58 -070069import java.io.PrintWriter;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070070import java.util.List;
Joe Onorato9bb8fd72009-07-28 18:24:51 -070071
72import org.xmlpull.v1.XmlPullParser;
73import org.xmlpull.v1.XmlPullParserException;
74import org.xmlpull.v1.XmlSerializer;
75
Dianne Hackborn21f1bd12010-02-19 17:02:21 -080076import com.android.internal.content.PackageMonitor;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080077import com.android.internal.util.FastXmlSerializer;
Dianne Hackborn1afd1c92010-03-18 22:47:17 -070078import com.android.internal.util.JournaledFile;
Amith Yamasani37ce3a82012-02-06 12:04:42 -080079import com.android.server.am.ActivityManagerService;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080
Dianne Hackborn8cc6a502009-08-05 21:29:42 -070081class WallpaperManagerService extends IWallpaperManager.Stub {
Dianne Hackborn4c62fc02009-08-08 20:40:27 -070082 static final String TAG = "WallpaperService";
Dianne Hackborncbf15042009-08-18 18:29:09 -070083 static final boolean DEBUG = false;
Joe Onorato9bb8fd72009-07-28 18:24:51 -070084
Romain Guy407ec782011-08-24 17:06:58 -070085 final Object mLock = new Object[0];
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086
Dianne Hackborn0cd48872009-08-13 18:51:59 -070087 /**
88 * Minimum time between crashes of a wallpaper service for us to consider
89 * restarting it vs. just reverting to the static wallpaper.
90 */
91 static final long MIN_WALLPAPER_CRASH_TIME = 10000;
92
Amith Yamasani37ce3a82012-02-06 12:04:42 -080093 static final File WALLPAPER_BASE_DIR = new File("/data/system/users");
Dianne Hackborn0cd48872009-08-13 18:51:59 -070094 static final String WALLPAPER = "wallpaper";
Amith Yamasani37ce3a82012-02-06 12:04:42 -080095 static final String WALLPAPER_INFO = "wallpaper_info.xml";
Joe Onorato9bb8fd72009-07-28 18:24:51 -070096
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 /**
98 * Observes the wallpaper for changes and notifies all IWallpaperServiceCallbacks
99 * that the wallpaper has changed. The CREATE is triggered when there is no
100 * wallpaper set and is created for the first time. The CLOSE_WRITE is triggered
101 * everytime the wallpaper is changed.
102 */
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800103 private class WallpaperObserver extends FileObserver {
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700104
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800105 final WallpaperData mWallpaper;
106 final File mWallpaperDir;
107 final File mWallpaperFile;
108
109 public WallpaperObserver(WallpaperData wallpaper) {
110 super(getWallpaperDir(wallpaper.userId).getAbsolutePath(),
111 CLOSE_WRITE | DELETE | DELETE_SELF);
112 mWallpaperDir = getWallpaperDir(wallpaper.userId);
113 mWallpaper = wallpaper;
114 mWallpaperFile = new File(mWallpaperDir, WALLPAPER);
115 }
116
117 @Override
118 public void onEvent(int event, String path) {
119 if (path == null) {
120 return;
121 }
122 synchronized (mLock) {
123 // changing the wallpaper means we'll need to back up the new one
124 long origId = Binder.clearCallingIdentity();
125 BackupManager bm = new BackupManager(mContext);
126 bm.dataChanged();
127 Binder.restoreCallingIdentity(origId);
128
129 File changedFile = new File(mWallpaperDir, path);
130 if (mWallpaperFile.equals(changedFile)) {
131 notifyCallbacksLocked(mWallpaper);
132 if (mWallpaper.wallpaperComponent == null || event != CLOSE_WRITE
133 || mWallpaper.imageWallpaperPending) {
134 if (event == CLOSE_WRITE) {
135 mWallpaper.imageWallpaperPending = false;
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700136 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800137 bindWallpaperComponentLocked(mWallpaper.imageWallpaperComponent, true,
138 false, mWallpaper);
139 saveSettingsLocked(mWallpaper);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800140 }
141 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800142 }
143 }
144 }
145
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700146 final Context mContext;
147 final IWindowManager mIWindowManager;
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800148 final MyPackageMonitor mMonitor;
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800149 WallpaperData mLastWallpaper;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800151 SparseArray<WallpaperData> mWallpaperMap = new SparseArray<WallpaperData>();
Dianne Hackborn07213e62011-08-24 20:05:39 -0700152
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800153 int mCurrentUserId;
Dianne Hackborn07213e62011-08-24 20:05:39 -0700154
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800155 static class WallpaperData {
156
157 int userId;
158
159 File wallpaperFile;
160
161 /**
162 * Client is currently writing a new image wallpaper.
163 */
164 boolean imageWallpaperPending;
165
166 /**
167 * Resource name if using a picture from the wallpaper gallery
168 */
169 String name = "";
170
171 /**
172 * The component name of the currently set live wallpaper.
173 */
174 ComponentName wallpaperComponent;
175
176 /**
177 * The component name of the wallpaper that should be set next.
178 */
179 ComponentName nextWallpaperComponent;
180
181 /**
182 * Name of the component used to display bitmap wallpapers from either the gallery or
183 * built-in wallpapers.
184 */
185 ComponentName imageWallpaperComponent = new ComponentName("com.android.systemui",
186 "com.android.systemui.ImageWallpaper");
187
188 WallpaperConnection connection;
189 long lastDiedTime;
190 boolean wallpaperUpdating;
191 WallpaperObserver wallpaperObserver;
192
193 /**
194 * List of callbacks registered they should each be notified when the wallpaper is changed.
195 */
196 private RemoteCallbackList<IWallpaperManagerCallback> callbacks
197 = new RemoteCallbackList<IWallpaperManagerCallback>();
198
199 int width = -1;
200 int height = -1;
201
202 WallpaperData(int userId) {
203 this.userId = userId;
204 wallpaperFile = new File(getWallpaperDir(userId), WALLPAPER);
205 }
206 }
207
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700208 class WallpaperConnection extends IWallpaperConnection.Stub
209 implements ServiceConnection {
Dianne Hackborneb034652009-09-07 00:49:58 -0700210 final WallpaperInfo mInfo;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700211 final Binder mToken = new Binder();
212 IWallpaperService mService;
213 IWallpaperEngine mEngine;
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800214 WallpaperData mWallpaper;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800216 public WallpaperConnection(WallpaperInfo info, WallpaperData wallpaper) {
Dianne Hackborneb034652009-09-07 00:49:58 -0700217 mInfo = info;
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800218 mWallpaper = wallpaper;
Dianne Hackborneb034652009-09-07 00:49:58 -0700219 }
220
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700221 public void onServiceConnected(ComponentName name, IBinder service) {
222 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800223 if (mWallpaper.connection == this) {
224 mWallpaper.lastDiedTime = SystemClock.uptimeMillis();
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700225 mService = IWallpaperService.Stub.asInterface(service);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800226 attachServiceLocked(this, mWallpaper);
Dianne Hackborneb034652009-09-07 00:49:58 -0700227 // XXX should probably do saveSettingsLocked() later
228 // when we have an engine, but I'm not sure about
229 // locking there and anyway we always need to be able to
230 // recover if there is something wrong.
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800231 saveSettingsLocked(mWallpaper);
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700232 }
233 }
234 }
235
236 public void onServiceDisconnected(ComponentName name) {
237 synchronized (mLock) {
238 mService = null;
239 mEngine = null;
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800240 if (mWallpaper.connection == this) {
241 Slog.w(TAG, "Wallpaper service gone: " + mWallpaper.wallpaperComponent);
242 if (!mWallpaper.wallpaperUpdating
243 && (mWallpaper.lastDiedTime + MIN_WALLPAPER_CRASH_TIME)
244 > SystemClock.uptimeMillis()
245 && mWallpaper.userId == mCurrentUserId) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800246 Slog.w(TAG, "Reverting to built-in wallpaper!");
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800247 clearWallpaperLocked(true, mWallpaper.userId);
Dianne Hackborn0cd48872009-08-13 18:51:59 -0700248 }
249 }
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700250 }
251 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800252
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700253 public void attachEngine(IWallpaperEngine engine) {
254 mEngine = engine;
255 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800256
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700257 public ParcelFileDescriptor setWallpaper(String name) {
258 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800259 if (mWallpaper.connection == this) {
260 return updateWallpaperBitmapLocked(name, mWallpaper);
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700261 }
262 return null;
263 }
264 }
265 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800266
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800267 class MyPackageMonitor extends PackageMonitor {
268 @Override
269 public void onPackageUpdateFinished(String packageName, int uid) {
270 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800271 for (int i = 0; i < mWallpaperMap.size(); i++) {
272 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
273 if (wallpaper.wallpaperComponent != null
274 && wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
275 wallpaper.wallpaperUpdating = false;
276 ComponentName comp = wallpaper.wallpaperComponent;
277 clearWallpaperComponentLocked(wallpaper);
278 // Do this only for the current user's wallpaper
279 if (wallpaper.userId == mCurrentUserId
280 && !bindWallpaperComponentLocked(comp, false, false, wallpaper)) {
281 Slog.w(TAG, "Wallpaper no longer available; reverting to default");
282 clearWallpaperLocked(false, wallpaper.userId);
283 }
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700284 }
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800285 }
286 }
287 }
288
289 @Override
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700290 public void onPackageModified(String packageName) {
291 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800292 for (int i = 0; i < mWallpaperMap.size(); i++) {
293 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
294 if (wallpaper.wallpaperComponent == null
295 || !wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
296 continue;
297 }
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700298 doPackagesChangedLocked(true, wallpaper);
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700299 }
300 }
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700301 }
302
303 @Override
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800304 public void onPackageUpdateStarted(String packageName, int uid) {
305 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800306 for (int i = 0; i < mWallpaperMap.size(); i++) {
307 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
308 if (wallpaper.wallpaperComponent != null
309 && wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
310 wallpaper.wallpaperUpdating = true;
311 }
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800312 }
313 }
314 }
315
316 @Override
317 public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) {
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700318 synchronized (mLock) {
319 boolean changed = false;
320 for (int i = 0; i < mWallpaperMap.size(); i++) {
321 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
322 boolean res = doPackagesChangedLocked(doit, wallpaper);
323 changed |= res;
324 }
325 return changed;
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800326 }
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800327 }
328
329 @Override
330 public void onSomePackagesChanged() {
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700331 synchronized (mLock) {
332 for (int i = 0; i < mWallpaperMap.size(); i++) {
333 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
334 doPackagesChangedLocked(true, wallpaper);
335 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800336 }
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800337 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800338
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700339 boolean doPackagesChangedLocked(boolean doit, WallpaperData wallpaper) {
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800340 boolean changed = false;
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700341 if (wallpaper.wallpaperComponent != null) {
342 int change = isPackageDisappearing(wallpaper.wallpaperComponent
343 .getPackageName());
344 if (change == PACKAGE_PERMANENT_CHANGE
345 || change == PACKAGE_TEMPORARY_CHANGE) {
346 changed = true;
347 if (doit) {
348 Slog.w(TAG, "Wallpaper uninstalled, removing: "
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800349 + wallpaper.wallpaperComponent);
350 clearWallpaperLocked(false, wallpaper.userId);
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800351 }
352 }
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700353 }
354 if (wallpaper.nextWallpaperComponent != null) {
355 int change = isPackageDisappearing(wallpaper.nextWallpaperComponent
356 .getPackageName());
357 if (change == PACKAGE_PERMANENT_CHANGE
358 || change == PACKAGE_TEMPORARY_CHANGE) {
359 wallpaper.nextWallpaperComponent = null;
360 }
361 }
362 if (wallpaper.wallpaperComponent != null
363 && isPackageModified(wallpaper.wallpaperComponent.getPackageName())) {
364 try {
365 mContext.getPackageManager().getServiceInfo(
366 wallpaper.wallpaperComponent, 0);
367 } catch (NameNotFoundException e) {
368 Slog.w(TAG, "Wallpaper component gone, removing: "
369 + wallpaper.wallpaperComponent);
370 clearWallpaperLocked(false, wallpaper.userId);
371 }
372 }
373 if (wallpaper.nextWallpaperComponent != null
374 && isPackageModified(wallpaper.nextWallpaperComponent.getPackageName())) {
375 try {
376 mContext.getPackageManager().getServiceInfo(
377 wallpaper.nextWallpaperComponent, 0);
378 } catch (NameNotFoundException e) {
379 wallpaper.nextWallpaperComponent = null;
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800380 }
381 }
382 return changed;
383 }
384 }
385
Dianne Hackborn8cc6a502009-08-05 21:29:42 -0700386 public WallpaperManagerService(Context context) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800387 if (DEBUG) Slog.v(TAG, "WallpaperService startup");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800388 mContext = context;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700389 mIWindowManager = IWindowManager.Stub.asInterface(
390 ServiceManager.getService(Context.WINDOW_SERVICE));
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800391 mMonitor = new MyPackageMonitor();
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700392 mMonitor.register(context, null, true);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800393 WALLPAPER_BASE_DIR.mkdirs();
394 loadSettingsLocked(0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800395 }
396
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800397 private static File getWallpaperDir(int userId) {
398 return new File(WALLPAPER_BASE_DIR + "/" + userId);
399 }
400
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800401 @Override
402 protected void finalize() throws Throwable {
403 super.finalize();
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800404 for (int i = 0; i < mWallpaperMap.size(); i++) {
405 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
406 wallpaper.wallpaperObserver.stopWatching();
407 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800408 }
Amith Yamasani13593602012-03-22 16:16:17 -0700409
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700410 public void systemReady() {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800411 if (DEBUG) Slog.v(TAG, "systemReady");
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800412 WallpaperData wallpaper = mWallpaperMap.get(0);
413 switchWallpaper(wallpaper);
414 wallpaper.wallpaperObserver = new WallpaperObserver(wallpaper);
415 wallpaper.wallpaperObserver.startWatching();
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800416
Amith Yamasani13593602012-03-22 16:16:17 -0700417 IntentFilter userFilter = new IntentFilter();
418 userFilter.addAction(Intent.ACTION_USER_SWITCHED);
419 userFilter.addAction(Intent.ACTION_USER_REMOVED);
420 mContext.registerReceiver(new BroadcastReceiver() {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800421 @Override
Amith Yamasani13593602012-03-22 16:16:17 -0700422 public void onReceive(Context context, Intent intent) {
423 String action = intent.getAction();
424 if (Intent.ACTION_USER_SWITCHED.equals(action)) {
425 switchUser(intent.getIntExtra(Intent.EXTRA_USERID, 0));
426 } else if (Intent.ACTION_USER_REMOVED.equals(action)) {
427 removeUser(intent.getIntExtra(Intent.EXTRA_USERID, 0));
428 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800429 }
Amith Yamasani13593602012-03-22 16:16:17 -0700430 }, userFilter);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800431 }
432
433 String getName() {
434 return mWallpaperMap.get(0).name;
435 }
436
Amith Yamasani13593602012-03-22 16:16:17 -0700437 void removeUser(int userId) {
438 synchronized (mLock) {
439 WallpaperData wallpaper = mWallpaperMap.get(userId);
440 if (wallpaper != null) {
441 wallpaper.wallpaperObserver.stopWatching();
442 mWallpaperMap.remove(userId);
443 }
444 File wallpaperFile = new File(getWallpaperDir(userId), WALLPAPER);
445 wallpaperFile.delete();
446 File wallpaperInfoFile = new File(getWallpaperDir(userId), WALLPAPER_INFO);
447 wallpaperInfoFile.delete();
448 }
449 }
450
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800451 void switchUser(int userId) {
452 synchronized (mLock) {
453 mCurrentUserId = userId;
454 WallpaperData wallpaper = mWallpaperMap.get(userId);
455 if (wallpaper == null) {
456 wallpaper = new WallpaperData(userId);
457 mWallpaperMap.put(userId, wallpaper);
458 loadSettingsLocked(userId);
459 wallpaper.wallpaperObserver = new WallpaperObserver(wallpaper);
460 wallpaper.wallpaperObserver.startWatching();
461 }
462 switchWallpaper(wallpaper);
463 }
464 }
465
466 void switchWallpaper(WallpaperData wallpaper) {
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700467 synchronized (mLock) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700468 RuntimeException e = null;
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700469 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800470 ComponentName cname = wallpaper.wallpaperComponent != null ?
471 wallpaper.wallpaperComponent : wallpaper.nextWallpaperComponent;
472 if (bindWallpaperComponentLocked(cname, true, false, wallpaper)) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700473 return;
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700474 }
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700475 } catch (RuntimeException e1) {
476 e = e1;
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700477 }
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700478 Slog.w(TAG, "Failure starting previous wallpaper", e);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800479 clearWallpaperLocked(false, wallpaper.userId);
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800480 }
481 }
482
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800483 public void clearWallpaper() {
484 if (DEBUG) Slog.v(TAG, "clearWallpaper");
485 synchronized (mLock) {
486 clearWallpaperLocked(false, UserId.getCallingUserId());
487 }
488 }
489
490 void clearWallpaperLocked(boolean defaultFailed, int userId) {
491 WallpaperData wallpaper = mWallpaperMap.get(userId);
492 File f = new File(getWallpaperDir(userId), WALLPAPER);
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800493 if (f.exists()) {
494 f.delete();
495 }
496 final long ident = Binder.clearCallingIdentity();
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700497 RuntimeException e = null;
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800498 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800499 wallpaper.imageWallpaperPending = false;
500 if (userId != mCurrentUserId) return;
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700501 if (bindWallpaperComponentLocked(defaultFailed
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800502 ? wallpaper.imageWallpaperComponent
503 : null, true, false, wallpaper)) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700504 return;
505 }
506 } catch (IllegalArgumentException e1) {
507 e = e1;
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800508 } finally {
509 Binder.restoreCallingIdentity(ident);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800510 }
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700511
512 // This can happen if the default wallpaper component doesn't
513 // exist. This should be a system configuration problem, but
514 // let's not let it crash the system and just live with no
515 // wallpaper.
516 Slog.e(TAG, "Default wallpaper component not found!", e);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800517 clearWallpaperComponentLocked(wallpaper);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800518 }
519
520 public void setDimensionHints(int width, int height) throws RemoteException {
521 checkPermission(android.Manifest.permission.SET_WALLPAPER_HINTS);
522
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800523 int userId = UserId.getCallingUserId();
524 WallpaperData wallpaper = mWallpaperMap.get(userId);
525 if (wallpaper == null) {
526 throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);
527 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800528 if (width <= 0 || height <= 0) {
529 throw new IllegalArgumentException("width and height must be > 0");
530 }
531
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700532 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800533 if (width != wallpaper.width || height != wallpaper.height) {
534 wallpaper.width = width;
535 wallpaper.height = height;
536 saveSettingsLocked(wallpaper);
537 if (mCurrentUserId != userId) return; // Don't change the properties now
538 if (wallpaper.connection != null) {
539 if (wallpaper.connection.mEngine != null) {
Dianne Hackborn284ac932009-08-28 10:34:25 -0700540 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800541 wallpaper.connection.mEngine.setDesiredSize(
Dianne Hackborn284ac932009-08-28 10:34:25 -0700542 width, height);
543 } catch (RemoteException e) {
544 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800545 notifyCallbacksLocked(wallpaper);
Dianne Hackborn284ac932009-08-28 10:34:25 -0700546 }
547 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700548 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 }
550 }
551
552 public int getWidthHint() throws RemoteException {
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700553 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800554 WallpaperData wallpaper = mWallpaperMap.get(UserId.getCallingUserId());
555 return wallpaper.width;
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700556 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800557 }
558
559 public int getHeightHint() throws RemoteException {
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700560 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800561 WallpaperData wallpaper = mWallpaperMap.get(UserId.getCallingUserId());
562 return wallpaper.height;
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700563 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 }
565
Dianne Hackborn284ac932009-08-28 10:34:25 -0700566 public ParcelFileDescriptor getWallpaper(IWallpaperManagerCallback cb,
567 Bundle outParams) {
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700568 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800569 // This returns the current user's wallpaper, if called by a system service. Else it
570 // returns the wallpaper for the calling user.
571 int callingUid = Binder.getCallingUid();
572 int wallpaperUserId = 0;
573 if (callingUid == android.os.Process.SYSTEM_UID) {
574 wallpaperUserId = mCurrentUserId;
575 } else {
576 wallpaperUserId = UserId.getUserId(callingUid);
577 }
578 WallpaperData wallpaper = mWallpaperMap.get(wallpaperUserId);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700579 try {
Dianne Hackborn284ac932009-08-28 10:34:25 -0700580 if (outParams != null) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800581 outParams.putInt("width", wallpaper.width);
582 outParams.putInt("height", wallpaper.height);
Dianne Hackborn284ac932009-08-28 10:34:25 -0700583 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800584 wallpaper.callbacks.register(cb);
585 File f = new File(getWallpaperDir(wallpaperUserId), WALLPAPER);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700586 if (!f.exists()) {
587 return null;
588 }
589 return ParcelFileDescriptor.open(f, MODE_READ_ONLY);
590 } catch (FileNotFoundException e) {
591 /* Shouldn't happen as we check to see if the file exists */
Joe Onorato8a9b2202010-02-26 18:56:32 -0800592 Slog.w(TAG, "Error getting wallpaper", e);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800593 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700594 return null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800595 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800596 }
597
Dianne Hackborneb034652009-09-07 00:49:58 -0700598 public WallpaperInfo getWallpaperInfo() {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800599 int userId = UserId.getCallingUserId();
Dianne Hackborneb034652009-09-07 00:49:58 -0700600 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800601 WallpaperData wallpaper = mWallpaperMap.get(userId);
602 if (wallpaper.connection != null) {
603 return wallpaper.connection.mInfo;
Dianne Hackborneb034652009-09-07 00:49:58 -0700604 }
605 return null;
606 }
607 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800608
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700609 public ParcelFileDescriptor setWallpaper(String name) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800610 if (DEBUG) Slog.v(TAG, "setWallpaper");
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800611 int userId = UserId.getCallingUserId();
612 WallpaperData wallpaper = mWallpaperMap.get(userId);
613 if (wallpaper == null) {
614 throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);
615 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800616 checkPermission(android.Manifest.permission.SET_WALLPAPER);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700617 synchronized (mLock) {
Dianne Hackborn0cd48872009-08-13 18:51:59 -0700618 final long ident = Binder.clearCallingIdentity();
619 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800620 ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name, wallpaper);
Dianne Hackborn0cd48872009-08-13 18:51:59 -0700621 if (pfd != null) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800622 wallpaper.imageWallpaperPending = true;
Dianne Hackborn0cd48872009-08-13 18:51:59 -0700623 }
624 return pfd;
625 } finally {
626 Binder.restoreCallingIdentity(ident);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700627 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800628 }
629 }
630
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800631 ParcelFileDescriptor updateWallpaperBitmapLocked(String name, WallpaperData wallpaper) {
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700632 if (name == null) name = "";
633 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800634 File dir = getWallpaperDir(wallpaper.userId);
635 if (!dir.exists()) {
636 dir.mkdir();
Dianne Hackbornebac48c2011-11-29 18:01:50 -0800637 FileUtils.setPermissions(
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800638 dir.getPath(),
Dianne Hackbornebac48c2011-11-29 18:01:50 -0800639 FileUtils.S_IRWXU|FileUtils.S_IRWXG|FileUtils.S_IXOTH,
640 -1, -1);
641 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800642 ParcelFileDescriptor fd = ParcelFileDescriptor.open(new File(dir, WALLPAPER),
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700643 MODE_CREATE|MODE_READ_WRITE);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800644 wallpaper.name = name;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700645 return fd;
646 } catch (FileNotFoundException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800647 Slog.w(TAG, "Error setting wallpaper", e);
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700648 }
649 return null;
650 }
651
652 public void setWallpaperComponent(ComponentName name) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800653 if (DEBUG) Slog.v(TAG, "setWallpaperComponent name=" + name);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800654 int userId = UserId.getCallingUserId();
655 WallpaperData wallpaper = mWallpaperMap.get(userId);
656 if (wallpaper == null) {
657 throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);
658 }
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700659 checkPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT);
660 synchronized (mLock) {
661 final long ident = Binder.clearCallingIdentity();
662 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800663 wallpaper.imageWallpaperPending = false;
664 bindWallpaperComponentLocked(name, false, true, wallpaper);
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700665 } finally {
666 Binder.restoreCallingIdentity(ident);
667 }
668 }
669 }
670
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800671 boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
672 boolean fromUser, WallpaperData wallpaper) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800673 if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName);
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700674 // Has the component changed?
Dianne Hackborn9ea31632011-08-05 14:43:50 -0700675 if (!force) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800676 if (wallpaper.connection != null) {
677 if (wallpaper.wallpaperComponent == null) {
Dianne Hackborn9ea31632011-08-05 14:43:50 -0700678 if (componentName == null) {
679 if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: still using default");
680 // Still using default wallpaper.
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700681 return true;
Dianne Hackborn9ea31632011-08-05 14:43:50 -0700682 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800683 } else if (wallpaper.wallpaperComponent.equals(componentName)) {
Dianne Hackborn9ea31632011-08-05 14:43:50 -0700684 // Changing to same wallpaper.
685 if (DEBUG) Slog.v(TAG, "same wallpaper");
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700686 return true;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700687 }
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700688 }
689 }
690
691 try {
Mike Clerona428b2c2009-11-15 22:53:08 -0800692 if (componentName == null) {
Mike Cleron322b6ee2009-11-12 07:45:47 -0800693 String defaultComponent =
694 mContext.getString(com.android.internal.R.string.default_wallpaper_component);
Mike Clerona428b2c2009-11-15 22:53:08 -0800695 if (defaultComponent != null) {
Mike Cleron322b6ee2009-11-12 07:45:47 -0800696 // See if there is a default wallpaper component specified
Mike Clerona428b2c2009-11-15 22:53:08 -0800697 componentName = ComponentName.unflattenFromString(defaultComponent);
Joe Onorato8a9b2202010-02-26 18:56:32 -0800698 if (DEBUG) Slog.v(TAG, "Use default component wallpaper:" + componentName);
Mike Cleron322b6ee2009-11-12 07:45:47 -0800699 }
Mike Clerona428b2c2009-11-15 22:53:08 -0800700 if (componentName == null) {
Mike Cleron322b6ee2009-11-12 07:45:47 -0800701 // Fall back to static image wallpaper
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800702 componentName = wallpaper.imageWallpaperComponent;
Mike Cleron322b6ee2009-11-12 07:45:47 -0800703 //clearWallpaperComponentLocked();
704 //return;
Joe Onorato8a9b2202010-02-26 18:56:32 -0800705 if (DEBUG) Slog.v(TAG, "Using image wallpaper");
Mike Cleron322b6ee2009-11-12 07:45:47 -0800706 }
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700707 }
Mike Clerona428b2c2009-11-15 22:53:08 -0800708 ServiceInfo si = mContext.getPackageManager().getServiceInfo(componentName,
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700709 PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS);
710 if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700711 String msg = "Selected service does not require "
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700712 + android.Manifest.permission.BIND_WALLPAPER
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700713 + ": " + componentName;
714 if (fromUser) {
715 throw new SecurityException(msg);
716 }
717 Slog.w(TAG, msg);
718 return false;
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700719 }
720
Dianne Hackborneb034652009-09-07 00:49:58 -0700721 WallpaperInfo wi = null;
722
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700723 Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800724 if (componentName != null && !componentName.equals(wallpaper.imageWallpaperComponent)) {
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700725 // Make sure the selected service is actually a wallpaper service.
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700726 List<ResolveInfo> ris = mContext.getPackageManager()
Dianne Hackborneb034652009-09-07 00:49:58 -0700727 .queryIntentServices(intent, PackageManager.GET_META_DATA);
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700728 for (int i=0; i<ris.size(); i++) {
729 ServiceInfo rsi = ris.get(i).serviceInfo;
730 if (rsi.name.equals(si.name) &&
731 rsi.packageName.equals(si.packageName)) {
Dianne Hackborneb034652009-09-07 00:49:58 -0700732 try {
733 wi = new WallpaperInfo(mContext, ris.get(i));
734 } catch (XmlPullParserException e) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700735 if (fromUser) {
736 throw new IllegalArgumentException(e);
737 }
738 Slog.w(TAG, e);
739 return false;
Dianne Hackborneb034652009-09-07 00:49:58 -0700740 } catch (IOException e) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700741 if (fromUser) {
742 throw new IllegalArgumentException(e);
743 }
744 Slog.w(TAG, e);
745 return false;
Dianne Hackborneb034652009-09-07 00:49:58 -0700746 }
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700747 break;
748 }
749 }
Dianne Hackborneb034652009-09-07 00:49:58 -0700750 if (wi == null) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700751 String msg = "Selected service is not a wallpaper: "
752 + componentName;
753 if (fromUser) {
754 throw new SecurityException(msg);
755 }
756 Slog.w(TAG, msg);
757 return false;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700758 }
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700759 }
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700760
761 // Bind the service!
Joe Onorato8a9b2202010-02-26 18:56:32 -0800762 if (DEBUG) Slog.v(TAG, "Binding to:" + componentName);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800763 WallpaperConnection newConn = new WallpaperConnection(wi, wallpaper);
Mike Clerona428b2c2009-11-15 22:53:08 -0800764 intent.setComponent(componentName);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800765 int serviceUserId = wallpaper.userId;
766 // Because the image wallpaper is running in the system ui
767 if (componentName.equals(wallpaper.imageWallpaperComponent)) {
768 serviceUserId = 0;
769 }
Dianne Hackborndd9b82c2009-09-03 00:18:47 -0700770 intent.putExtra(Intent.EXTRA_CLIENT_LABEL,
771 com.android.internal.R.string.wallpaper_binding_label);
772 intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity(
Dianne Hackborneb034652009-09-07 00:49:58 -0700773 mContext, 0,
774 Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER),
775 mContext.getText(com.android.internal.R.string.chooser_wallpaper)),
776 0));
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800777 if (!mContext.bindService(intent, newConn, Context.BIND_AUTO_CREATE, serviceUserId)) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700778 String msg = "Unable to bind service: "
779 + componentName;
780 if (fromUser) {
781 throw new IllegalArgumentException(msg);
782 }
783 Slog.w(TAG, msg);
784 return false;
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700785 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800786 if (wallpaper.userId == mCurrentUserId && mLastWallpaper != null) {
787 detachWallpaperLocked(mLastWallpaper);
788 }
789 wallpaper.wallpaperComponent = componentName;
790 wallpaper.connection = newConn;
791 wallpaper.lastDiedTime = SystemClock.uptimeMillis();
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700792 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800793 if (wallpaper.userId == mCurrentUserId) {
794 if (DEBUG)
795 Slog.v(TAG, "Adding window token: " + newConn.mToken);
796 mIWindowManager.addWindowToken(newConn.mToken,
797 WindowManager.LayoutParams.TYPE_WALLPAPER);
798 mLastWallpaper = wallpaper;
799 }
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700800 } catch (RemoteException e) {
801 }
Dianne Hackbornf21adf62009-08-13 10:20:21 -0700802 } catch (PackageManager.NameNotFoundException e) {
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700803 String msg = "Unknown component " + componentName;
804 if (fromUser) {
805 throw new IllegalArgumentException(msg);
806 }
807 Slog.w(TAG, msg);
808 return false;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700809 }
Dianne Hackborn80b902f2011-09-15 15:15:27 -0700810 return true;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700811 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800812
813 void detachWallpaperLocked(WallpaperData wallpaper) {
814 if (wallpaper.connection != null) {
815 if (wallpaper.connection.mEngine != null) {
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700816 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800817 wallpaper.connection.mEngine.destroy();
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700818 } catch (RemoteException e) {
819 }
820 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800821 mContext.unbindService(wallpaper.connection);
Dianne Hackborne9e9bca2009-08-18 15:08:22 -0700822 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800823 if (DEBUG)
824 Slog.v(TAG, "Removing window token: " + wallpaper.connection.mToken);
825 mIWindowManager.removeWindowToken(wallpaper.connection.mToken);
Dianne Hackborne9e9bca2009-08-18 15:08:22 -0700826 } catch (RemoteException e) {
827 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800828 wallpaper.connection.mService = null;
829 wallpaper.connection.mEngine = null;
830 wallpaper.connection = null;
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700831 }
832 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800833
834 void clearWallpaperComponentLocked(WallpaperData wallpaper) {
835 wallpaper.wallpaperComponent = null;
836 detachWallpaperLocked(wallpaper);
837 }
838
839 void attachServiceLocked(WallpaperConnection conn, WallpaperData wallpaper) {
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700840 try {
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700841 conn.mService.attach(conn, conn.mToken,
842 WindowManager.LayoutParams.TYPE_WALLPAPER, false,
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800843 wallpaper.width, wallpaper.height);
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700844 } catch (RemoteException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800845 Slog.w(TAG, "Failed attaching wallpaper; clearing", e);
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800846 if (!wallpaper.wallpaperUpdating) {
847 bindWallpaperComponentLocked(null, false, false, wallpaper);
Dianne Hackborn21f1bd12010-02-19 17:02:21 -0800848 }
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700849 }
850 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800851
852 private void notifyCallbacksLocked(WallpaperData wallpaper) {
853 final int n = wallpaper.callbacks.beginBroadcast();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800854 for (int i = 0; i < n; i++) {
855 try {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800856 wallpaper.callbacks.getBroadcastItem(i).onWallpaperChanged();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800857 } catch (RemoteException e) {
858
859 // The RemoteCallbackList will take care of removing
860 // the dead object for us.
861 }
862 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800863 wallpaper.callbacks.finishBroadcast();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800864 final Intent intent = new Intent(Intent.ACTION_WALLPAPER_CHANGED);
865 mContext.sendBroadcast(intent);
866 }
867
868 private void checkPermission(String permission) {
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700869 if (PackageManager.PERMISSION_GRANTED!= mContext.checkCallingOrSelfPermission(permission)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800870 throw new SecurityException("Access denied to process: " + Binder.getCallingPid()
871 + ", must have permission " + permission);
872 }
873 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700874
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800875 private static JournaledFile makeJournaledFile(int userId) {
Amith Yamasani13593602012-03-22 16:16:17 -0700876 final String base = getWallpaperDir(userId) + "/" + WALLPAPER_INFO;
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700877 return new JournaledFile(new File(base), new File(base + ".tmp"));
878 }
879
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800880 private void saveSettingsLocked(WallpaperData wallpaper) {
881 JournaledFile journal = makeJournaledFile(wallpaper.userId);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700882 FileOutputStream stream = null;
883 try {
884 stream = new FileOutputStream(journal.chooseForWrite(), false);
885 XmlSerializer out = new FastXmlSerializer();
886 out.setOutput(stream, "utf-8");
887 out.startDocument(null, true);
888
889 out.startTag(null, "wp");
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800890 out.attribute(null, "width", Integer.toString(wallpaper.width));
891 out.attribute(null, "height", Integer.toString(wallpaper.height));
892 out.attribute(null, "name", wallpaper.name);
893 if (wallpaper.wallpaperComponent != null
894 && !wallpaper.wallpaperComponent.equals(wallpaper.imageWallpaperComponent)) {
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700895 out.attribute(null, "component",
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800896 wallpaper.wallpaperComponent.flattenToShortString());
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700897 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700898 out.endTag(null, "wp");
899
900 out.endDocument();
901 stream.close();
902 journal.commit();
903 } catch (IOException e) {
904 try {
905 if (stream != null) {
906 stream.close();
907 }
908 } catch (IOException ex) {
909 // Ignore
910 }
911 journal.rollback();
912 }
913 }
914
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800915 private void migrateFromOld() {
916 File oldWallpaper = new File(WallpaperBackupHelper.WALLPAPER_IMAGE_KEY);
917 File oldInfo = new File(WallpaperBackupHelper.WALLPAPER_INFO_KEY);
918 if (oldWallpaper.exists()) {
919 File newWallpaper = new File(getWallpaperDir(0), WALLPAPER);
920 oldWallpaper.renameTo(newWallpaper);
921 }
922 if (oldInfo.exists()) {
923 File newInfo = new File(getWallpaperDir(0), WALLPAPER_INFO);
924 oldInfo.renameTo(newInfo);
925 }
926 }
927
928 private void loadSettingsLocked(int userId) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800929 if (DEBUG) Slog.v(TAG, "loadSettingsLocked");
Mike Clerona428b2c2009-11-15 22:53:08 -0800930
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800931 JournaledFile journal = makeJournaledFile(userId);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700932 FileInputStream stream = null;
933 File file = journal.chooseForRead();
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800934 if (!file.exists()) {
935 // This should only happen one time, when upgrading from a legacy system
936 migrateFromOld();
937 }
938 WallpaperData wallpaper = mWallpaperMap.get(userId);
939 if (wallpaper == null) {
940 wallpaper = new WallpaperData(userId);
941 mWallpaperMap.put(userId, wallpaper);
942 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700943 boolean success = false;
944 try {
945 stream = new FileInputStream(file);
946 XmlPullParser parser = Xml.newPullParser();
947 parser.setInput(stream, null);
948
949 int type;
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700950 do {
951 type = parser.next();
952 if (type == XmlPullParser.START_TAG) {
953 String tag = parser.getName();
954 if ("wp".equals(tag)) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800955 wallpaper.width = Integer.parseInt(parser.getAttributeValue(null, "width"));
956 wallpaper.height = Integer.parseInt(parser
957 .getAttributeValue(null, "height"));
958 wallpaper.name = parser.getAttributeValue(null, "name");
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700959 String comp = parser.getAttributeValue(null, "component");
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800960 wallpaper.nextWallpaperComponent = comp != null
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700961 ? ComponentName.unflattenFromString(comp)
962 : null;
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800963 if (wallpaper.nextWallpaperComponent == null
964 || "android".equals(wallpaper.nextWallpaperComponent
965 .getPackageName())) {
966 wallpaper.nextWallpaperComponent = wallpaper.imageWallpaperComponent;
Dianne Hackborn9ea31632011-08-05 14:43:50 -0700967 }
Mike Clerona428b2c2009-11-15 22:53:08 -0800968
969 if (DEBUG) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -0800970 Slog.v(TAG, "mWidth:" + wallpaper.width);
971 Slog.v(TAG, "mHeight:" + wallpaper.height);
972 Slog.v(TAG, "mName:" + wallpaper.name);
973 Slog.v(TAG, "mNextWallpaperComponent:"
974 + wallpaper.nextWallpaperComponent);
Mike Clerona428b2c2009-11-15 22:53:08 -0800975 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700976 }
977 }
978 } while (type != XmlPullParser.END_DOCUMENT);
979 success = true;
980 } catch (NullPointerException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800981 Slog.w(TAG, "failed parsing " + file + " " + e);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700982 } catch (NumberFormatException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800983 Slog.w(TAG, "failed parsing " + file + " " + e);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700984 } catch (XmlPullParserException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800985 Slog.w(TAG, "failed parsing " + file + " " + e);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700986 } catch (IOException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800987 Slog.w(TAG, "failed parsing " + file + " " + e);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700988 } catch (IndexOutOfBoundsException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800989 Slog.w(TAG, "failed parsing " + file + " " + e);
Joe Onorato9bb8fd72009-07-28 18:24:51 -0700990 }
991 try {
992 if (stream != null) {
993 stream.close();
994 }
995 } catch (IOException e) {
996 // Ignore
997 }
998
999 if (!success) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001000 wallpaper.width = -1;
1001 wallpaper.height = -1;
1002 wallpaper.name = "";
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001003 }
Dianne Hackborn44bc17c2011-04-20 18:18:51 -07001004
1005 // We always want to have some reasonable width hint.
1006 WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
1007 Display d = wm.getDefaultDisplay();
1008 int baseSize = d.getMaximumSizeDimension();
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001009 if (wallpaper.width < baseSize) {
1010 wallpaper.width = baseSize;
Dianne Hackborn44bc17c2011-04-20 18:18:51 -07001011 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001012 if (wallpaper.height < baseSize) {
1013 wallpaper.height = baseSize;
Dianne Hackborn44bc17c2011-04-20 18:18:51 -07001014 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001015 }
1016
Brad Fitzpatrick194b19a2010-09-14 11:30:29 -07001017 // Called by SystemBackupAgent after files are restored to disk.
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001018 void settingsRestored() {
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001019 // TODO: If necessary, make it work for secondary users as well. This currently assumes
1020 // restores only to the primary user
Joe Onorato8a9b2202010-02-26 18:56:32 -08001021 if (DEBUG) Slog.v(TAG, "settingsRestored");
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001022 WallpaperData wallpaper = null;
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001023 boolean success = false;
1024 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001025 loadSettingsLocked(0);
1026 wallpaper = mWallpaperMap.get(0);
1027 if (wallpaper.nextWallpaperComponent != null
1028 && !wallpaper.nextWallpaperComponent.equals(wallpaper.imageWallpaperComponent)) {
1029 if (!bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false,
1030 wallpaper)) {
Christopher Tatee3ab4d02009-12-16 14:03:31 -08001031 // No such live wallpaper or other failure; fall back to the default
1032 // live wallpaper (since the profile being restored indicated that the
1033 // user had selected a live rather than static one).
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001034 bindWallpaperComponentLocked(null, false, false, wallpaper);
Christopher Tatee3ab4d02009-12-16 14:03:31 -08001035 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001036 success = true;
1037 } else {
Mike Clerona428b2c2009-11-15 22:53:08 -08001038 // If there's a wallpaper name, we use that. If that can't be loaded, then we
1039 // use the default.
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001040 if ("".equals(wallpaper.name)) {
Joe Onorato8a9b2202010-02-26 18:56:32 -08001041 if (DEBUG) Slog.v(TAG, "settingsRestored: name is empty");
Mike Clerona428b2c2009-11-15 22:53:08 -08001042 success = true;
1043 } else {
Joe Onorato8a9b2202010-02-26 18:56:32 -08001044 if (DEBUG) Slog.v(TAG, "settingsRestored: attempting to restore named resource");
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001045 success = restoreNamedResourceLocked(wallpaper);
Mike Clerona428b2c2009-11-15 22:53:08 -08001046 }
Joe Onorato8a9b2202010-02-26 18:56:32 -08001047 if (DEBUG) Slog.v(TAG, "settingsRestored: success=" + success);
Mike Clerona428b2c2009-11-15 22:53:08 -08001048 if (success) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001049 bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false,
1050 wallpaper);
Mike Clerona428b2c2009-11-15 22:53:08 -08001051 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001052 }
1053 }
1054
1055 if (!success) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001056 Slog.e(TAG, "Failed to restore wallpaper: '" + wallpaper.name + "'");
1057 wallpaper.name = "";
1058 getWallpaperDir(0).delete();
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001059 }
Brad Fitzpatrick194b19a2010-09-14 11:30:29 -07001060
1061 synchronized (mLock) {
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001062 saveSettingsLocked(wallpaper);
Brad Fitzpatrick194b19a2010-09-14 11:30:29 -07001063 }
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001064 }
1065
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001066 boolean restoreNamedResourceLocked(WallpaperData wallpaper) {
1067 if (wallpaper.name.length() > 4 && "res:".equals(wallpaper.name.substring(0, 4))) {
1068 String resName = wallpaper.name.substring(4);
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001069
1070 String pkg = null;
1071 int colon = resName.indexOf(':');
1072 if (colon > 0) {
1073 pkg = resName.substring(0, colon);
1074 }
1075
1076 String ident = null;
1077 int slash = resName.lastIndexOf('/');
1078 if (slash > 0) {
1079 ident = resName.substring(slash+1);
1080 }
1081
1082 String type = null;
1083 if (colon > 0 && slash > 0 && (slash-colon) > 1) {
1084 type = resName.substring(colon+1, slash);
1085 }
1086
1087 if (pkg != null && ident != null && type != null) {
1088 int resId = -1;
1089 InputStream res = null;
1090 FileOutputStream fos = null;
1091 try {
1092 Context c = mContext.createPackageContext(pkg, Context.CONTEXT_RESTRICTED);
1093 Resources r = c.getResources();
1094 resId = r.getIdentifier(resName, null, null);
1095 if (resId == 0) {
Joe Onorato8a9b2202010-02-26 18:56:32 -08001096 Slog.e(TAG, "couldn't resolve identifier pkg=" + pkg + " type=" + type
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001097 + " ident=" + ident);
1098 return false;
1099 }
1100
1101 res = r.openRawResource(resId);
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001102 if (wallpaper.wallpaperFile.exists()) {
1103 wallpaper.wallpaperFile.delete();
Dianne Hackborn1afd1c92010-03-18 22:47:17 -07001104 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001105 fos = new FileOutputStream(wallpaper.wallpaperFile);
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001106
1107 byte[] buffer = new byte[32768];
1108 int amt;
1109 while ((amt=res.read(buffer)) > 0) {
1110 fos.write(buffer, 0, amt);
1111 }
1112 // mWallpaperObserver will notice the close and send the change broadcast
1113
Joe Onorato8a9b2202010-02-26 18:56:32 -08001114 Slog.v(TAG, "Restored wallpaper: " + resName);
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001115 return true;
1116 } catch (NameNotFoundException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -08001117 Slog.e(TAG, "Package name " + pkg + " not found");
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001118 } catch (Resources.NotFoundException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -08001119 Slog.e(TAG, "Resource not found: " + resId);
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001120 } catch (IOException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -08001121 Slog.e(TAG, "IOException while restoring wallpaper ", e);
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001122 } finally {
1123 if (res != null) {
1124 try {
1125 res.close();
1126 } catch (IOException ex) {}
1127 }
1128 if (fos != null) {
Dianne Hackborn8bdf5932010-10-15 12:54:40 -07001129 FileUtils.sync(fos);
Joe Onorato9bb8fd72009-07-28 18:24:51 -07001130 try {
1131 fos.close();
1132 } catch (IOException ex) {}
1133 }
1134 }
1135 }
1136 }
1137 return false;
1138 }
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001139
Dianne Hackborneb034652009-09-07 00:49:58 -07001140 @Override
1141 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
1142 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
1143 != PackageManager.PERMISSION_GRANTED) {
1144
1145 pw.println("Permission Denial: can't dump wallpaper service from from pid="
1146 + Binder.getCallingPid()
1147 + ", uid=" + Binder.getCallingUid());
1148 return;
1149 }
1150
1151 synchronized (mLock) {
1152 pw.println("Current Wallpaper Service state:");
Amith Yamasani37ce3a82012-02-06 12:04:42 -08001153 for (int i = 0; i < mWallpaperMap.size(); i++) {
1154 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
1155 pw.println(" User " + wallpaper.userId + ":");
1156 pw.print(" mWidth=");
1157 pw.print(wallpaper.width);
1158 pw.print(" mHeight=");
1159 pw.println(wallpaper.height);
1160 pw.print(" mName=");
1161 pw.println(wallpaper.name);
1162 pw.print(" mWallpaperComponent=");
1163 pw.println(wallpaper.wallpaperComponent);
1164 if (wallpaper.connection != null) {
1165 WallpaperConnection conn = wallpaper.connection;
1166 pw.print(" Wallpaper connection ");
1167 pw.print(conn);
1168 pw.println(":");
1169 if (conn.mInfo != null) {
1170 pw.print(" mInfo.component=");
1171 pw.println(conn.mInfo.getComponent());
1172 }
1173 pw.print(" mToken=");
1174 pw.println(conn.mToken);
1175 pw.print(" mService=");
1176 pw.println(conn.mService);
1177 pw.print(" mEngine=");
1178 pw.println(conn.mEngine);
1179 pw.print(" mLastDiedTime=");
1180 pw.println(wallpaper.lastDiedTime - SystemClock.uptimeMillis());
1181 }
Dianne Hackborneb034652009-09-07 00:49:58 -07001182 }
1183 }
1184 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001185}