Merge "Fix black wallpaper after repeated crashes" into nyc-mr1-dev
This commit is contained in:
@@ -89,6 +89,7 @@ import com.android.internal.os.BackgroundThread;
|
|||||||
import com.android.internal.util.FastXmlSerializer;
|
import com.android.internal.util.FastXmlSerializer;
|
||||||
import com.android.internal.util.JournaledFile;
|
import com.android.internal.util.JournaledFile;
|
||||||
import com.android.server.EventLogTags;
|
import com.android.server.EventLogTags;
|
||||||
|
import com.android.server.FgThread;
|
||||||
import com.android.server.SystemService;
|
import com.android.server.SystemService;
|
||||||
|
|
||||||
import libcore.io.IoUtils;
|
import libcore.io.IoUtils;
|
||||||
@@ -589,6 +590,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
|
|
||||||
class WallpaperConnection extends IWallpaperConnection.Stub
|
class WallpaperConnection extends IWallpaperConnection.Stub
|
||||||
implements ServiceConnection {
|
implements ServiceConnection {
|
||||||
|
|
||||||
|
/** Time in milliseconds until we expect the wallpaper to reconnect (unless we're in the
|
||||||
|
* middle of an update). If exceeded, the wallpaper gets reset to the system default. */
|
||||||
|
private static final long WALLPAPER_RECONNECT_TIMEOUT_MS = 5000;
|
||||||
|
|
||||||
final WallpaperInfo mInfo;
|
final WallpaperInfo mInfo;
|
||||||
final Binder mToken = new Binder();
|
final Binder mToken = new Binder();
|
||||||
IWallpaperService mService;
|
IWallpaperService mService;
|
||||||
@@ -599,6 +605,18 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
boolean mDimensionsChanged = false;
|
boolean mDimensionsChanged = false;
|
||||||
boolean mPaddingChanged = false;
|
boolean mPaddingChanged = false;
|
||||||
|
|
||||||
|
private Runnable mResetRunnable = () -> {
|
||||||
|
synchronized (mLock) {
|
||||||
|
if (!mWallpaper.wallpaperUpdating
|
||||||
|
&& mWallpaper.userId == mCurrentUserId) {
|
||||||
|
Slog.w(TAG, "Wallpaper reconnect timed out, "
|
||||||
|
+ "reverting to built-in wallpaper!");
|
||||||
|
clearWallpaperLocked(true, FLAG_SYSTEM, mWallpaper.userId,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public WallpaperConnection(WallpaperInfo info, WallpaperData wallpaper) {
|
public WallpaperConnection(WallpaperInfo info, WallpaperData wallpaper) {
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
mWallpaper = wallpaper;
|
mWallpaper = wallpaper;
|
||||||
@@ -615,6 +633,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
// locking there and anyway we always need to be able to
|
// locking there and anyway we always need to be able to
|
||||||
// recover if there is something wrong.
|
// recover if there is something wrong.
|
||||||
saveSettingsLocked(mWallpaper.userId);
|
saveSettingsLocked(mWallpaper.userId);
|
||||||
|
FgThread.getHandler().removeCallbacks(mResetRunnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -641,6 +660,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
clearWallpaperLocked(true, FLAG_SYSTEM, mWallpaper.userId, null);
|
clearWallpaperLocked(true, FLAG_SYSTEM, mWallpaper.userId, null);
|
||||||
} else {
|
} else {
|
||||||
mWallpaper.lastDiedTime = SystemClock.uptimeMillis();
|
mWallpaper.lastDiedTime = SystemClock.uptimeMillis();
|
||||||
|
|
||||||
|
// If we didn't reset it right away, do so after we couldn't connect to
|
||||||
|
// it for an extended amount of time to avoid having a black wallpaper.
|
||||||
|
FgThread.getHandler().removeCallbacks(mResetRunnable);
|
||||||
|
FgThread.getHandler().postDelayed(mResetRunnable,
|
||||||
|
WALLPAPER_RECONNECT_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
final String flattened = name.flattenToString();
|
final String flattened = name.flattenToString();
|
||||||
EventLog.writeEvent(EventLogTags.WP_WALLPAPER_CRASHED,
|
EventLog.writeEvent(EventLogTags.WP_WALLPAPER_CRASHED,
|
||||||
@@ -752,6 +777,10 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
if (wallpaper.wallpaperComponent != null
|
if (wallpaper.wallpaperComponent != null
|
||||||
&& wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
|
&& wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
|
||||||
wallpaper.wallpaperUpdating = true;
|
wallpaper.wallpaperUpdating = true;
|
||||||
|
if (wallpaper.connection != null) {
|
||||||
|
FgThread.getHandler().removeCallbacks(
|
||||||
|
wallpaper.connection.mResetRunnable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user