Skip to content

Commit bce0cbb

Browse files
author
Dianne Hackborn
committed
Fix issue #7275122: Wall paper jank when switching users
Change-Id: I2677c7641a01b4afe89db29cb5fc1af876f9d078
1 parent 8a22919 commit bce0cbb

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

core/java/android/service/wallpaper/WallpaperService.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNee
574574
final boolean flagsChanged = mCurWindowFlags != mWindowFlags ||
575575
mCurWindowPrivateFlags != mWindowPrivateFlags;
576576
if (forceRelayout || creating || surfaceCreating || formatChanged || sizeChanged
577-
|| typeChanged || flagsChanged || redrawNeeded) {
577+
|| typeChanged || flagsChanged || redrawNeeded
578+
|| !mIWallpaperEngine.mShownReported) {
578579

579580
if (DEBUG) Log.v(TAG, "Changes: creating=" + creating
580581
+ " format=" + formatChanged + " size=" + sizeChanged);
@@ -739,6 +740,7 @@ void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNee
739740
if (redrawNeeded) {
740741
mSession.finishDrawing(mWindow);
741742
}
743+
mIWallpaperEngine.reportShown();
742744
}
743745
} catch (RemoteException ex) {
744746
}
@@ -950,6 +952,7 @@ class IWallpaperEngineWrapper extends IWallpaperEngine.Stub
950952
final IBinder mWindowToken;
951953
final int mWindowType;
952954
final boolean mIsPreview;
955+
boolean mShownReported;
953956
int mReqWidth;
954957
int mReqHeight;
955958

@@ -1002,6 +1005,18 @@ public void dispatchWallpaperCommand(String action, int x, int y,
10021005
}
10031006
}
10041007

1008+
public void reportShown() {
1009+
if (!mShownReported) {
1010+
mShownReported = true;
1011+
try {
1012+
mConnection.engineShown(this);
1013+
} catch (RemoteException e) {
1014+
Log.w(TAG, "Wallpaper host disappeared", e);
1015+
return;
1016+
}
1017+
}
1018+
}
1019+
10051020
public void destroy() {
10061021
Message msg = mCaller.obtainMessage(DO_DETACH);
10071022
mCaller.sendMessage(msg);
@@ -1020,12 +1035,6 @@ public void executeMessage(Message message) {
10201035
mEngine = engine;
10211036
mActiveEngines.add(engine);
10221037
engine.attach(this);
1023-
try {
1024-
mConnection.engineShown(this);
1025-
} catch (RemoteException e) {
1026-
Log.w(TAG, "Wallpaper host disappeared", e);
1027-
return;
1028-
}
10291038
return;
10301039
}
10311040
case DO_DETACH: {

services/java/com/android/server/WallpaperManagerService.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
9696
static final String WALLPAPER = "wallpaper";
9797
static final String WALLPAPER_INFO = "wallpaper_info.xml";
9898

99+
/**
100+
* Name of the component used to display bitmap wallpapers from either the gallery or
101+
* built-in wallpapers.
102+
*/
103+
static final ComponentName IMAGE_WALLPAPER = new ComponentName("com.android.systemui",
104+
"com.android.systemui.ImageWallpaper");
105+
99106
/**
100107
* Observes the wallpaper for changes and notifies all IWallpaperServiceCallbacks
101108
* that the wallpaper has changed. The CREATE is triggered when there is no
@@ -136,7 +143,7 @@ public void onEvent(int event, String path) {
136143
if (event == CLOSE_WRITE) {
137144
mWallpaper.imageWallpaperPending = false;
138145
}
139-
bindWallpaperComponentLocked(mWallpaper.imageWallpaperComponent, true,
146+
bindWallpaperComponentLocked(IMAGE_WALLPAPER, true,
140147
false, mWallpaper, null);
141148
saveSettingsLocked(mWallpaper);
142149
}
@@ -181,13 +188,6 @@ static class WallpaperData {
181188
*/
182189
ComponentName nextWallpaperComponent;
183190

184-
/**
185-
* Name of the component used to display bitmap wallpapers from either the gallery or
186-
* built-in wallpapers.
187-
*/
188-
ComponentName imageWallpaperComponent = new ComponentName("com.android.systemui",
189-
"com.android.systemui.ImageWallpaper");
190-
191191
WallpaperConnection connection;
192192
long lastDiedTime;
193193
boolean wallpaperUpdating;
@@ -554,7 +554,7 @@ void clearWallpaperLocked(boolean defaultFailed, int userId, IRemoteCallback rep
554554
wallpaper.imageWallpaperPending = false;
555555
if (userId != mCurrentUserId) return;
556556
if (bindWallpaperComponentLocked(defaultFailed
557-
? wallpaper.imageWallpaperComponent
557+
? IMAGE_WALLPAPER
558558
: null, true, false, wallpaper, reply)) {
559559
return;
560560
}
@@ -775,7 +775,7 @@ boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
775775
}
776776
if (componentName == null) {
777777
// Fall back to static image wallpaper
778-
componentName = wallpaper.imageWallpaperComponent;
778+
componentName = IMAGE_WALLPAPER;
779779
//clearWallpaperComponentLocked();
780780
//return;
781781
if (DEBUG) Slog.v(TAG, "Using image wallpaper");
@@ -798,7 +798,7 @@ boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
798798
WallpaperInfo wi = null;
799799

800800
Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
801-
if (componentName != null && !componentName.equals(wallpaper.imageWallpaperComponent)) {
801+
if (componentName != null && !componentName.equals(IMAGE_WALLPAPER)) {
802802
// Make sure the selected service is actually a wallpaper service.
803803
List<ResolveInfo> ris =
804804
mIPackageManager.queryIntentServices(intent,
@@ -973,7 +973,7 @@ private void saveSettingsLocked(WallpaperData wallpaper) {
973973
out.attribute(null, "height", Integer.toString(wallpaper.height));
974974
out.attribute(null, "name", wallpaper.name);
975975
if (wallpaper.wallpaperComponent != null
976-
&& !wallpaper.wallpaperComponent.equals(wallpaper.imageWallpaperComponent)) {
976+
&& !wallpaper.wallpaperComponent.equals(IMAGE_WALLPAPER)) {
977977
out.attribute(null, "component",
978978
wallpaper.wallpaperComponent.flattenToShortString());
979979
}
@@ -1045,7 +1045,7 @@ private void loadSettingsLocked(int userId) {
10451045
if (wallpaper.nextWallpaperComponent == null
10461046
|| "android".equals(wallpaper.nextWallpaperComponent
10471047
.getPackageName())) {
1048-
wallpaper.nextWallpaperComponent = wallpaper.imageWallpaperComponent;
1048+
wallpaper.nextWallpaperComponent = IMAGE_WALLPAPER;
10491049
}
10501050

10511051
if (DEBUG) {
@@ -1107,7 +1107,7 @@ void settingsRestored() {
11071107
loadSettingsLocked(0);
11081108
wallpaper = mWallpaperMap.get(0);
11091109
if (wallpaper.nextWallpaperComponent != null
1110-
&& !wallpaper.nextWallpaperComponent.equals(wallpaper.imageWallpaperComponent)) {
1110+
&& !wallpaper.nextWallpaperComponent.equals(IMAGE_WALLPAPER)) {
11111111
if (!bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false,
11121112
wallpaper, null)) {
11131113
// No such live wallpaper or other failure; fall back to the default

0 commit comments

Comments
 (0)