summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorAhan Wu <ahanwu@google.com>2021-09-15 17:35:04 +0800
committerWu Ahan <ahanwu@google.com>2021-09-23 12:51:32 +0000
commita381ebd20500bcb6d79e24bbaa9096e3464e7008 (patch)
treef6fde98892c40624b1ddd6ed228589e7b9cda1dd /core/java/android
parent977ab888a5d9a2c4824bf3f903d18258aabf5544 (diff)
Use longer timeout for reportShown call
If the system is under somewhat pressure, the one second timeout might not be enough, let's use a longer timeout to mitigate it. Bug: 194080642 Test: see b/199700573#comment10 Change-Id: I8b9f40b332138b771d0892917b3f737caa2311a0
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index c198a492d4c9..c9a0121936dc 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -548,12 +548,16 @@ public abstract class WallpaperService extends Service {
*/
public void reportEngineShown(boolean waitForEngineShown) {
if (mIWallpaperEngine.mShownReported) return;
- Message message = mCaller.obtainMessage(MSG_REPORT_SHOWN);
if (!waitForEngineShown) {
+ Message message = mCaller.obtainMessage(MSG_REPORT_SHOWN);
mCaller.removeMessages(MSG_REPORT_SHOWN);
mCaller.sendMessage(message);
} else {
- mCaller.sendMessageDelayed(message, TimeUnit.SECONDS.toMillis(1));
+ // if we are already waiting, no need to reset the timeout.
+ if (!mCaller.hasMessages(MSG_REPORT_SHOWN)) {
+ Message message = mCaller.obtainMessage(MSG_REPORT_SHOWN);
+ mCaller.sendMessageDelayed(message, TimeUnit.SECONDS.toMillis(5));
+ }
}
}
@@ -2078,6 +2082,8 @@ public abstract class WallpaperService extends Service {
mShownReported = true;
try {
mConnection.engineShown(this);
+ Log.d(TAG, "Wallpaper has updated the surface:"
+ + mWallpaperManager.getWallpaperInfo());
} catch (RemoteException e) {
Log.w(TAG, "Wallpaper host disappeared", e);
return;