Lines Matching refs:wallpaper
17 package com.android.server.wallpaper;
61 import android.service.wallpaper.IWallpaperConnection;
62 import android.service.wallpaper.IWallpaperEngine;
63 import android.service.wallpaper.IWallpaperService;
64 import android.service.wallpaper.WallpaperService;
100 * Minimum time between crashes of a wallpaper service for us to consider
101 * restarting it vs. just reverting to the static wallpaper.
105 static final String WALLPAPER = "wallpaper";
109 * Observes the wallpaper for changes and notifies all IWallpaperServiceCallbacks
110 * that the wallpaper has changed. The CREATE is triggered when there is no
111 * wallpaper set and is created for the first time. The CLOSE_WRITE is triggered
112 * everytime the wallpaper is changed.
121 public WallpaperObserver(WallpaperData wallpaper) {
122 super(getWallpaperDir(wallpaper.userId).getAbsolutePath(),
124 mWallpaperDir = getWallpaperDir(wallpaper.userId);
125 mWallpaper = wallpaper;
126 mWallpaperFile = new File(mWallpaperDir, WALLPAPER);
139 // changing the wallpaper means we'll need to back up the new one
186 * Client is currently writing a new image wallpaper.
191 * Resource name if using a picture from the wallpaper gallery
196 * The component name of the currently set live wallpaper.
201 * The component name of the wallpaper that should be set next.
211 * List of callbacks registered they should each be notified when the wallpaper is changed.
223 wallpaperFile = new File(getWallpaperDir(userId), WALLPAPER);
239 public WallpaperConnection(WallpaperInfo info, WallpaperData wallpaper) {
241 mWallpaper = wallpaper;
265 Slog.w(TAG, "Wallpaper service gone: " + mWallpaper.wallpaperComponent);
272 // wallpaper if its service was shut down twice
277 Slog.w(TAG, "Reverting to built-in wallpaper!");
299 Slog.w(TAG, "Failed to set wallpaper dimensions", e);
307 Slog.w(TAG, "Failed to set wallpaper padding", e);
347 WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId);
348 if (wallpaper != null) {
349 if (wallpaper.wallpaperComponent != null
350 && wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
351 wallpaper.wallpaperUpdating = false;
352 ComponentName comp = wallpaper.wallpaperComponent;
353 clearWallpaperComponentLocked(wallpaper);
355 wallpaper, null)) {
356 Slog.w(TAG, "Wallpaper no longer available; reverting to default");
357 clearWallpaperLocked(false, wallpaper.userId, null);
370 WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId);
371 if (wallpaper != null) {
372 if (wallpaper.wallpaperComponent == null
373 || !wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
376 doPackagesChangedLocked(true, wallpaper);
387 WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId);
388 if (wallpaper != null) {
389 if (wallpaper.wallpaperComponent != null
390 && wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
391 wallpaper.wallpaperUpdating = true;
404 WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId);
405 if (wallpaper != null) {
406 boolean res = doPackagesChangedLocked(doit, wallpaper);
419 WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId);
420 if (wallpaper != null) {
421 doPackagesChangedLocked(true, wallpaper);
426 wallpaper) {
428 if (wallpaper.wallpaperComponent != null) {
429 int change = isPackageDisappearing(wallpaper.wallpaperComponent
435 Slog.w(TAG, "Wallpaper uninstalled, removing: "
436 + wallpaper.wallpaperComponent);
437 clearWallpaperLocked(false, wallpaper.userId, null);
441 if (wallpaper.nextWallpaperComponent != null) {
442 int change = isPackageDisappearing(wallpaper.nextWallpaperComponent
446 wallpaper.nextWallpaperComponent = null;
449 if (wallpaper.wallpaperComponent != null
450 && isPackageModified(wallpaper.wallpaperComponent.getPackageName())) {
453 wallpaper.wallpaperComponent, 0);
455 Slog.w(TAG, "Wallpaper component gone, removing: "
456 + wallpaper.wallpaperComponent);
457 clearWallpaperLocked(false, wallpaper.userId, null);
460 if (wallpaper.nextWallpaperComponent != null
461 && isPackageModified(wallpaper.nextWallpaperComponent.getPackageName())) {
464 wallpaper.nextWallpaperComponent, 0);
466 wallpaper.nextWallpaperComponent = null;
495 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
496 wallpaper.wallpaperObserver.stopWatching();
502 WallpaperData wallpaper = mWallpaperMap.get(UserHandle.USER_OWNER);
503 switchWallpaper(wallpaper, null);
504 wallpaper.wallpaperObserver = new WallpaperObserver(wallpaper);
505 wallpaper.wallpaperObserver.startWatching();
559 WallpaperData wallpaper = mWallpaperMap.get(userId);
560 if (wallpaper != null) {
561 if (wallpaper.wallpaperObserver != null) {
562 wallpaper.wallpaperObserver.stopWatching();
563 wallpaper.wallpaperObserver = null;
574 File wallpaperFile = new File(getWallpaperDir(userId), WALLPAPER);
584 WallpaperData wallpaper = mWallpaperMap.get(userId);
585 if (wallpaper == null) {
586 wallpaper = new WallpaperData(userId);
587 mWallpaperMap.put(userId, wallpaper);
590 // Not started watching yet, in case wallpaper data was loaded for other reasons.
591 if (wallpaper.wallpaperObserver == null) {
592 wallpaper.wallpaperObserver = new WallpaperObserver(wallpaper);
593 wallpaper.wallpaperObserver.startWatching();
595 switchWallpaper(wallpaper, reply);
599 void switchWallpaper(WallpaperData wallpaper, IRemoteCallback reply) {
603 ComponentName cname = wallpaper.wallpaperComponent != null ?
604 wallpaper.wallpaperComponent : wallpaper.nextWallpaperComponent;
605 if (bindWallpaperComponentLocked(cname, true, false, wallpaper, reply)) {
611 Slog.w(TAG, "Failure starting previous wallpaper", e);
612 clearWallpaperLocked(false, wallpaper.userId, reply);
624 WallpaperData wallpaper = mWallpaperMap.get(userId);
625 File f = new File(getWallpaperDir(userId), WALLPAPER);
633 wallpaper.imageWallpaperPending = false;
637 : null, true, false, wallpaper, reply)) {
644 // This can happen if the default wallpaper component doesn't
647 // wallpaper.
648 Slog.e(TAG, "Default wallpaper component not found!", e);
649 clearWallpaperComponentLocked(wallpaper);
673 // User hasn't started yet, so load her settings to peek at the wallpaper
697 WallpaperData wallpaper = mWallpaperMap.get(userId);
698 if (wallpaper == null) {
699 throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);
709 if (width != wallpaper.width || height != wallpaper.height) {
710 wallpaper.width = width;
711 wallpaper.height = height;
712 saveSettingsLocked(wallpaper);
714 if (wallpaper.connection != null) {
715 if (wallpaper.connection.mEngine != null) {
717 wallpaper.connection.mEngine.setDesiredSize(
721 notifyCallbacksLocked(wallpaper);
722 } else if (wallpaper.connection.mService != null) {
726 wallpaper.connection.mDimensionsChanged = true;
735 WallpaperData wallpaper = mWallpaperMap.get(UserHandle.getCallingUserId());
736 return wallpaper.width;
742 WallpaperData wallpaper = mWallpaperMap.get(UserHandle.getCallingUserId());
743 return wallpaper.height;
751 WallpaperData wallpaper = mWallpaperMap.get(userId);
752 if (wallpaper == null) {
753 throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);
759 if (!padding.equals(wallpaper.padding)) {
760 wallpaper.padding.set(padding);
761 saveSettingsLocked(wallpaper);
763 if (wallpaper.connection != null) {
764 if (wallpaper.connection.mEngine != null) {
766 wallpaper.connection.mEngine.setDisplayPadding(padding);
769 notifyCallbacksLocked(wallpaper);
770 } else if (wallpaper.connection.mService != null) {
774 wallpaper.connection.mPaddingChanged = true;
784 // This returns the current user's wallpaper, if called by a system service. Else it
785 // returns the wallpaper for the calling user.
793 WallpaperData wallpaper = mWallpaperMap.get(wallpaperUserId);
796 outParams.putInt("width", wallpaper.width);
797 outParams.putInt("height", wallpaper.height);
799 wallpaper.callbacks.register(cb);
800 File f = new File(getWallpaperDir(wallpaperUserId), WALLPAPER);
807 wallpaper", e);
816 WallpaperData wallpaper = mWallpaperMap.get(userId);
817 if (wallpaper.connection != null) {
818 return wallpaper.connection.mInfo;
829 WallpaperData wallpaper = mWallpaperMap.get(userId);
830 if (wallpaper == null) {
831 throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);
835 ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name, wallpaper);
837 wallpaper.imageWallpaperPending = true;
846 ParcelFileDescriptor updateWallpaperBitmapLocked(String name, WallpaperData wallpaper) {
849 File dir = getWallpaperDir(wallpaper.userId);
857 File file = new File(dir, WALLPAPER);
863 wallpaper.name = name;
866 Slog.w(TAG, "Error setting wallpaper", e);
876 WallpaperData wallpaper = mWallpaperMap.get(userId);
877 if (wallpaper == null) {
878 throw new IllegalStateException("Wallpaper not yet initialized for user " + userId);
882 wallpaper.imageWallpaperPending = false;
883 bindWallpaperComponentLocked(name, false, true, wallpaper, null);
891 boolean fromUser, WallpaperData wallpaper, IRemoteCallback reply) {
895 if (wallpaper.connection != null) {
896 if (wallpaper.wallpaperComponent == null) {
899 // Still using default wallpaper.
902 } else if (wallpaper.wallpaperComponent.equals(componentName)) {
903 // Changing to same wallpaper.
904 if (DEBUG) Slog.v(TAG, "same wallpaper");
914 // Fall back to static image wallpaper
918 if (DEBUG) Slog.v(TAG, "Using image wallpaper");
921 int serviceUserId = wallpaper.userId;
925 // The wallpaper component we're trying to use doesn't exist
926 Slog.w(TAG, "Attempted wallpaper " + componentName + " is unavailable");
944 // Make sure the selected service is actually a wallpaper service.
972 String msg = "Selected service is not a wallpaper: "
984 WallpaperConnection newConn = new WallpaperConnection(wi, wallpaper);
1004 if (wallpaper.userId == mCurrentUserId && mLastWallpaper != null) {
1007 wallpaper.wallpaperComponent = componentName;
1008 wallpaper.connection = newConn;
1011 if (wallpaper.userId == mCurrentUserId) {
1016 mLastWallpaper = wallpaper;
1031 void detachWallpaperLocked(WallpaperData wallpaper) {
1032 if (wallpaper.connection != null) {
1033 if (wallpaper.connection.mReply != null) {
1035 wallpaper.connection.mReply.sendResult(null);
1038 wallpaper.connection.mReply = null;
1040 if (wallpaper.connection.mEngine != null) {
1042 wallpaper.connection.mEngine.destroy();
1046 mContext.unbindService(wallpaper.connection);
1049 Slog.v(TAG, "Removing window token: " + wallpaper.connection.mToken);
1050 mIWindowManager.removeWindowToken(wallpaper.connection.mToken);
1053 wallpaper.connection.mService = null;
1054 wallpaper.connection.mEngine = null;
1055 wallpaper.connection = null;
1059 void clearWallpaperComponentLocked(WallpaperData wallpaper) {
1060 wallpaper.wallpaperComponent = null;
1061 detachWallpaperLocked(wallpaper);
1064 void attachServiceLocked(WallpaperConnection conn, WallpaperData wallpaper) {
1068 wallpaper.width, wallpaper.height, wallpaper.padding);
1070 Slog.w(TAG, "Failed attaching wallpaper; clearing", e);
1071 if (!wallpaper.wallpaperUpdating) {
1072 bindWallpaperComponentLocked(null, false, false, wallpaper, null);
1077 private void notifyCallbacksLocked(WallpaperData wallpaper) {
1078 final int n = wallpaper.callbacks.beginBroadcast();
1081 wallpaper.callbacks.getBroadcastItem(i).onWallpaperChanged();
1088 wallpaper.callbacks.finishBroadcast();
1105 private void saveSettingsLocked(WallpaperData wallpaper) {
1106 JournaledFile journal = makeJournaledFile(wallpaper.userId);
1115 out.attribute(null, "width", Integer.toString(wallpaper.width));
1116 out.attribute(null, "height", Integer.toString(wallpaper.height));
1117 if (wallpaper.padding.left != 0) {
1118 out.attribute(null, "paddingLeft", Integer.toString(wallpaper.padding.left));
1120 if (wallpaper.padding.top != 0) {
1121 out.attribute(null, "paddingTop", Integer.toString(wallpaper.padding.top));
1123 if (wallpaper.padding.right != 0) {
1124 out.attribute(null, "paddingRight", Integer.toString(wallpaper.padding.right));
1126 if (wallpaper.padding.bottom != 0) {
1127 out.attribute(null, "paddingBottom", Integer.toString(wallpaper.padding.bottom));
1129 out.attribute(null, "name", wallpaper.name);
1130 if (wallpaper.wallpaperComponent != null
1131 && !wallpaper.wallpaperComponent.equals(mImageWallpaper)) {
1133 wallpaper.wallpaperComponent.flattenToShortString());
1156 File newWallpaper = new File(getWallpaperDir(0), WALLPAPER);
1183 WallpaperData wallpaper = mWallpaperMap.get(userId);
1184 if (wallpaper == null) {
1185 wallpaper = new WallpaperData(userId);
1186 mWallpaperMap.put(userId, wallpaper);
1200 wallpaper.width = Integer.parseInt(parser.getAttributeValue(null, "width"));
1201 wallpaper.height = Integer.parseInt(parser
1203 wallpaper.padding.left = getAttributeInt(parser, "paddingLeft", 0);
1204 wallpaper.padding.top = getAttributeInt(parser, "paddingTop", 0);
1205 wallpaper.padding.right = getAttributeInt(parser, "paddingRight", 0);
1206 wallpaper.padding.bottom = getAttributeInt(parser, "paddingBottom", 0);
1207 wallpaper.name = parser.getAttributeValue(null, "name");
1209 wallpaper.nextWallpaperComponent = comp != null
1212 if (wallpaper.nextWallpaperComponent == null
1213 || "android".equals(wallpaper.nextWallpaperComponent
1215 wallpaper.nextWallpaperComponent = mImageWallpaper;
1219 Slog.v(TAG, "mWidth:" + wallpaper.width);
1220 Slog.v(TAG, "mHeight:" + wallpaper.height);
1221 Slog.v(TAG, "mName:" + wallpaper.name);
1223 + wallpaper.nextWallpaperComponent);
1230 Slog.w(TAG, "no current wallpaper -- first boot?");
1251 wallpaper.width = -1;
1252 wallpaper.height = -1;
1253 wallpaper.padding.set(0, 0, 0, 0);
1254 wallpaper.name = "";
1259 if (wallpaper.width < baseSize) {
1260 wallpaper.width = baseSize;
1262 if (wallpaper.height < baseSize) {
1263 wallpaper.height = baseSize;
1282 WallpaperData wallpaper = null;
1286 wallpaper = mWallpaperMap.get(0);
1287 if (wallpaper.nextWallpaperComponent != null
1288 && !wallpaper.nextWallpaperComponent.equals(mImageWallpaper)) {
1289 if (!bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false,
1290 wallpaper, null)) {
1291 // No such live wallpaper or other failure; fall back to the default
1292 // live wallpaper (since the profile being restored indicated that the
1294 bindWallpaperComponentLocked(null, false, false, wallpaper, null);
1298 // If there's a wallpaper name, we use that. If that can't be loaded, then we
1300 if ("".equals(wallpaper.name)) {
1305 success = restoreNamedResourceLocked(wallpaper);
1309 bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false,
1310 wallpaper, null);
1316 Slog.e(TAG, "Failed to restore wallpaper: '" + wallpaper.name + "'");
1317 wallpaper.name = "";
1322 saveSettingsLocked(wallpaper);
1326 boolean restoreNamedResourceLocked(WallpaperData wallpaper) {
1327 if (wallpaper.name.length() > 4 && "res:".equals(wallpaper.name.substring(0, 4))) {
1328 String resName = wallpaper.name.substring(4);
1362 if (wallpaper.wallpaperFile.exists()) {
1363 wallpaper.wallpaperFile.delete();
1365 fos = new FileOutputStream(wallpaper.wallpaperFile);
1374 Slog.v(TAG, "Restored wallpaper: " + resName);
1381 Slog.e(TAG, "IOException while restoring wallpaper ", e);
1405 pw.println("Permission Denial: can't dump wallpaper service from from pid="
1412 pw.println("Current Wallpaper Service state:");
1414 WallpaperData wallpaper = mWallpaperMap.valueAt(i);
1415 pw.println(" User " + wallpaper.userId + ":");
1417 pw.print(wallpaper.width);
1419 pw.println(wallpaper.height);
1420 pw.print(" mPadding="); pw.println(wallpaper.padding);
1421 pw.print(" mName="); pw.println(wallpaper.name);
1422 pw.print(" mWallpaperComponent="); pw.println(wallpaper.wallpaperComponent);
1423 if (wallpaper.connection != null) {
1424 WallpaperConnection conn = wallpaper.connection;
1425 pw.print(" Wallpaper connection ");
1439 pw.println(wallpaper.lastDiedTime - SystemClock.uptimeMillis());