|
38 | 38 | import android.content.pm.ResolveInfo; |
39 | 39 | import android.content.pm.ServiceInfo; |
40 | 40 | import android.content.pm.PackageManager.NameNotFoundException; |
| 41 | +import android.content.pm.UserInfo; |
41 | 42 | import android.content.res.Resources; |
42 | 43 | import android.os.Binder; |
43 | 44 | import android.os.Bundle; |
|
53 | 54 | import android.os.ServiceManager; |
54 | 55 | import android.os.SystemClock; |
55 | 56 | import android.os.UserHandle; |
| 57 | +import android.os.UserManager; |
56 | 58 | import android.service.wallpaper.IWallpaperConnection; |
57 | 59 | import android.service.wallpaper.IWallpaperEngine; |
58 | 60 | import android.service.wallpaper.IWallpaperService; |
@@ -511,6 +513,9 @@ void switchUser(int userId, IRemoteCallback reply) { |
511 | 513 | wallpaper = new WallpaperData(userId); |
512 | 514 | mWallpaperMap.put(userId, wallpaper); |
513 | 515 | loadSettingsLocked(userId); |
| 516 | + } |
| 517 | + // Not started watching yet, in case wallpaper data was loaded for other reasons. |
| 518 | + if (wallpaper.wallpaperObserver == null) { |
514 | 519 | wallpaper.wallpaperObserver = new WallpaperObserver(wallpaper); |
515 | 520 | wallpaper.wallpaperObserver.startWatching(); |
516 | 521 | } |
@@ -580,9 +585,21 @@ void clearWallpaperLocked(boolean defaultFailed, int userId, IRemoteCallback rep |
580 | 585 |
|
581 | 586 | public boolean hasNamedWallpaper(String name) { |
582 | 587 | synchronized (mLock) { |
583 | | - for (int i=0; i<mWallpaperMap.size(); i++) { |
584 | | - WallpaperData wd = mWallpaperMap.valueAt(i); |
585 | | - if (name.equals(wd.name)) { |
| 588 | + List<UserInfo> users; |
| 589 | + long ident = Binder.clearCallingIdentity(); |
| 590 | + try { |
| 591 | + users = ((UserManager) mContext.getSystemService(Context.USER_SERVICE)).getUsers(); |
| 592 | + } finally { |
| 593 | + Binder.restoreCallingIdentity(ident); |
| 594 | + } |
| 595 | + for (UserInfo user: users) { |
| 596 | + WallpaperData wd = mWallpaperMap.get(user.id); |
| 597 | + if (wd == null) { |
| 598 | + // User hasn't started yet, so load her settings to peek at the wallpaper |
| 599 | + loadSettingsLocked(user.id); |
| 600 | + wd = mWallpaperMap.get(user.id); |
| 601 | + } |
| 602 | + if (wd != null && name.equals(wd.name)) { |
586 | 603 | return true; |
587 | 604 | } |
588 | 605 | } |
|
0 commit comments