Skip to content

Commit 7ef38ea

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue #7275122: Wall paper jank when switching users" into jb-mr1-dev
2 parents 26bf1a7 + bce0cbb commit 7ef38ea

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
@@ -98,6 +98,13 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
9898
static final String WALLPAPER = "wallpaper";
9999
static final String WALLPAPER_INFO = "wallpaper_info.xml";
100100

101+
/**
102+
* Name of the component used to display bitmap wallpapers from either the gallery or
103+
* built-in wallpapers.
104+
*/
105+
static final ComponentName IMAGE_WALLPAPER = new ComponentName("com.android.systemui",
106+
"com.android.systemui.ImageWallpaper");
107+
101108
/**
102109
* Observes the wallpaper for changes and notifies all IWallpaperServiceCallbacks
103110
* that the wallpaper has changed. The CREATE is triggered when there is no
@@ -138,7 +145,7 @@ public void onEvent(int event, String path) {
138145
if (event == CLOSE_WRITE) {
139146
mWallpaper.imageWallpaperPending = false;
140147
}
141-
bindWallpaperComponentLocked(mWallpaper.imageWallpaperComponent, true,
148+
bindWallpaperComponentLocked(IMAGE_WALLPAPER, true,
142149
false, mWallpaper, null);
143150
saveSettingsLocked(mWallpaper);
144151
}
@@ -183,13 +190,6 @@ static class WallpaperData {
183190
*/
184191
ComponentName nextWallpaperComponent;
185192

186-
/**
187-
* Name of the component used to display bitmap wallpapers from either the gallery or
188-
* built-in wallpapers.
189-
*/
190-
ComponentName imageWallpaperComponent = new ComponentName("com.android.systemui",
191-
"com.android.systemui.ImageWallpaper");
192-
193193
WallpaperConnection connection;
194194
long lastDiedTime;
195195
boolean wallpaperUpdating;
@@ -559,7 +559,7 @@ void clearWallpaperLocked(boolean defaultFailed, int userId, IRemoteCallback rep
559559
wallpaper.imageWallpaperPending = false;
560560
if (userId != mCurrentUserId) return;
561561
if (bindWallpaperComponentLocked(defaultFailed
562-
? wallpaper.imageWallpaperComponent
562+
? IMAGE_WALLPAPER
563563
: null, true, false, wallpaper, reply)) {
564564
return;
565565
}
@@ -792,7 +792,7 @@ boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
792792
}
793793
if (componentName == null) {
794794
// Fall back to static image wallpaper
795-
componentName = wallpaper.imageWallpaperComponent;
795+
componentName = IMAGE_WALLPAPER;
796796
//clearWallpaperComponentLocked();
797797
//return;
798798
if (DEBUG) Slog.v(TAG, "Using image wallpaper");
@@ -815,7 +815,7 @@ boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force,
815815
WallpaperInfo wi = null;
816816

817817
Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
818-
if (componentName != null && !componentName.equals(wallpaper.imageWallpaperComponent)) {
818+
if (componentName != null && !componentName.equals(IMAGE_WALLPAPER)) {
819819
// Make sure the selected service is actually a wallpaper service.
820820
List<ResolveInfo> ris =
821821
mIPackageManager.queryIntentServices(intent,
@@ -990,7 +990,7 @@ private void saveSettingsLocked(WallpaperData wallpaper) {
990990
out.attribute(null, "height", Integer.toString(wallpaper.height));
991991
out.attribute(null, "name", wallpaper.name);
992992
if (wallpaper.wallpaperComponent != null
993-
&& !wallpaper.wallpaperComponent.equals(wallpaper.imageWallpaperComponent)) {
993+
&& !wallpaper.wallpaperComponent.equals(IMAGE_WALLPAPER)) {
994994
out.attribute(null, "component",
995995
wallpaper.wallpaperComponent.flattenToShortString());
996996
}
@@ -1062,7 +1062,7 @@ private void loadSettingsLocked(int userId) {
10621062
if (wallpaper.nextWallpaperComponent == null
10631063
|| "android".equals(wallpaper.nextWallpaperComponent
10641064
.getPackageName())) {
1065-
wallpaper.nextWallpaperComponent = wallpaper.imageWallpaperComponent;
1065+
wallpaper.nextWallpaperComponent = IMAGE_WALLPAPER;
10661066
}
10671067

10681068
if (DEBUG) {
@@ -1124,7 +1124,7 @@ void settingsRestored() {
11241124
loadSettingsLocked(0);
11251125
wallpaper = mWallpaperMap.get(0);
11261126
if (wallpaper.nextWallpaperComponent != null
1127-
&& !wallpaper.nextWallpaperComponent.equals(wallpaper.imageWallpaperComponent)) {
1127+
&& !wallpaper.nextWallpaperComponent.equals(IMAGE_WALLPAPER)) {
11281128
if (!bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false,
11291129
wallpaper, null)) {
11301130
// No such live wallpaper or other failure; fall back to the default

0 commit comments

Comments
 (0)