From 096f36b8db3e513687b78da3e1dd0197fce148a3 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 20 Aug 2014 15:39:01 -0700 Subject: Minor tweaks to recents thumbnails. - Reducing the size of the recents thumbnails - Skip persisting if we never update the last thumbnail - Don't bother loading the last thumbnail file descriptor if we have it in memory - Fixing warning in getting drawable from resource Change-Id: Ieddaeac75a5e5d80876a9b6b1d50f7cc84c7d6fd --- .../java/com/android/server/am/ActivityRecord.java | 4 ++-- .../java/com/android/server/am/TaskRecord.java | 25 +++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'services') diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index 24b7cb3..fcbe71e 100755 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -773,8 +773,8 @@ final class ActivityRecord { if (newThumbnail != null) { if (ActivityManagerService.DEBUG_THUMBNAILS) Slog.i(ActivityManagerService.TAG, "Setting thumbnail of " + this + " to " + newThumbnail); - task.setLastThumbnail(newThumbnail); - if (isPersistable()) { + boolean thumbnailUpdated = task.setLastThumbnail(newThumbnail); + if (thumbnailUpdated && isPersistable()) { mStackSupervisor.mService.notifyTaskPersisterLocked(task, false); } } diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index 2a8c6fb..d35e09f 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -386,15 +386,23 @@ final class TaskRecord { setNextAffiliate(null); } - void setLastThumbnail(Bitmap thumbnail) { - mLastThumbnail = thumbnail; - if (thumbnail == null) { - if (mLastThumbnailFile != null) { - mLastThumbnailFile.delete(); + /** + * Sets the last thumbnail. + * @return whether the thumbnail was set + */ + boolean setLastThumbnail(Bitmap thumbnail) { + if (mLastThumbnail != thumbnail) { + mLastThumbnail = thumbnail; + if (thumbnail == null) { + if (mLastThumbnailFile != null) { + mLastThumbnailFile.delete(); + } + } else { + mService.mTaskPersister.saveImage(thumbnail, mFilename); } - } else { - mService.mTaskPersister.saveImage(thumbnail, mFilename); + return true; } + return false; } void getLastThumbnail(TaskThumbnail thumbs) { @@ -403,7 +411,8 @@ final class TaskRecord { if (mLastThumbnail == null) { thumbs.mainThumbnail = mService.mTaskPersister.getThumbnail(mFilename); } - if (mLastThumbnailFile.exists()) { + // Only load the thumbnail file if we don't have a thumbnail + if (thumbs.mainThumbnail == null && mLastThumbnailFile.exists()) { try { thumbs.thumbnailFileDescriptor = ParcelFileDescriptor.open(mLastThumbnailFile, ParcelFileDescriptor.MODE_READ_ONLY); -- cgit v1.1