Loading packages/SystemUI/res/layout/recents_task_view.xml +13 −5 Original line number Original line Diff line number Diff line Loading @@ -28,21 +28,29 @@ android:layout_gravity="top|center_horizontal" android:layout_gravity="top|center_horizontal" android:background="#e6444444"> android:background="#e6444444"> <ImageView <ImageView android:id="@+id/activity_icon" android:id="@+id/application_icon" android:layout_width="@dimen/recents_task_view_icon_size" android:layout_width="@dimen/recents_task_view_application_icon_size" android:layout_height="@dimen/recents_task_view_icon_size" android:layout_height="@dimen/recents_task_view_application_icon_size" android:layout_gravity="top|left" android:layout_gravity="center_vertical|left" android:padding="8dp" /> android:padding="8dp" /> <TextView <TextView android:id="@+id/activity_description" android:id="@+id/activity_description" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|left" android:layout_gravity="center_vertical|left" android:layout_marginLeft="@dimen/recents_task_view_icon_size" android:layout_marginLeft="@dimen/recents_task_view_application_icon_size" android:layout_marginRight="@dimen/recents_task_view_activity_icon_size" android:textSize="24sp" android:textSize="24sp" android:textColor="#ffffffff" android:textColor="#ffffffff" android:text="@string/recents_empty_message" android:text="@string/recents_empty_message" android:fontFamily="sans-serif-thin" /> android:fontFamily="sans-serif-thin" /> <ImageView android:id="@+id/activity_icon" android:layout_width="@dimen/recents_task_view_activity_icon_size" android:layout_height="@dimen/recents_task_view_activity_icon_size" android:layout_gravity="center_vertical|right" android:padding="12dp" android:visibility="invisible" /> </com.android.systemui.recents.views.TaskBarView> </com.android.systemui.recents.views.TaskBarView> </com.android.systemui.recents.views.TaskView> </com.android.systemui.recents.views.TaskView> Loading packages/SystemUI/res/values/dimens.xml +5 −2 Original line number Original line Diff line number Diff line Loading @@ -230,8 +230,11 @@ <!-- Default distance from each snap target that GlowPadView considers a "hit" --> <!-- Default distance from each snap target that GlowPadView considers a "hit" --> <dimen name="glowpadview_inner_radius">15dip</dimen> <dimen name="glowpadview_inner_radius">15dip</dimen> <!-- The size of the icon in the recents task view. --> <!-- The size of the application icon in the recents task view. --> <dimen name="recents_task_view_icon_size">60dp</dimen> <dimen name="recents_task_view_application_icon_size">60dp</dimen> <!-- The size of the activity icon in the recents task view. --> <dimen name="recents_task_view_activity_icon_size">60dp</dimen> <!-- Space below the notification stack --> <!-- Space below the notification stack --> <dimen name="notification_stack_margin_bottom">0dp</dimen> <dimen name="notification_stack_margin_bottom">0dp</dimen> Loading packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +0 −1 Original line number Original line Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.os.Bundle; import android.os.Bundle; import android.os.SystemService; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.View; import android.view.View; import android.view.WindowManager; import android.view.WindowManager; Loading packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java +49 −59 Original line number Original line Diff line number Diff line Loading @@ -110,17 +110,18 @@ class TaskResourceLoader implements Runnable { SystemServicesProxy mSystemServicesProxy; SystemServicesProxy mSystemServicesProxy; TaskResourceLoadQueue mLoadQueue; TaskResourceLoadQueue mLoadQueue; DrawableLruCache mIconCache; DrawableLruCache mApplicationIconCache; BitmapLruCache mThumbnailCache; BitmapLruCache mThumbnailCache; boolean mCancelled; boolean mCancelled; boolean mWaitingOnLoadQueue; boolean mWaitingOnLoadQueue; /** Constructor, creates a new loading thread that loads task resources in the background */ /** Constructor, creates a new loading thread that loads task resources in the background */ public TaskResourceLoader(TaskResourceLoadQueue loadQueue, DrawableLruCache iconCache, public TaskResourceLoader(TaskResourceLoadQueue loadQueue, DrawableLruCache applicationIconCache, BitmapLruCache thumbnailCache) { BitmapLruCache thumbnailCache) { mLoadQueue = loadQueue; mLoadQueue = loadQueue; mIconCache = iconCache; mApplicationIconCache = applicationIconCache; mThumbnailCache = thumbnailCache; mThumbnailCache = thumbnailCache; mMainThreadHandler = new Handler(); mMainThreadHandler = new Handler(); mLoadThread = new HandlerThread("Recents-TaskResourceLoader"); mLoadThread = new HandlerThread("Recents-TaskResourceLoader"); Loading Loading @@ -184,13 +185,13 @@ class TaskResourceLoader implements Runnable { final Task t = nextTaskData.first; final Task t = nextTaskData.first; final boolean forceLoadTask = nextTaskData.second; final boolean forceLoadTask = nextTaskData.second; if (t != null) { if (t != null) { Drawable loadIcon = mIconCache.get(t.key); Drawable loadIcon = mApplicationIconCache.get(t.key); Bitmap loadThumbnail = mThumbnailCache.get(t.key); Bitmap loadThumbnail = mThumbnailCache.get(t.key); Console.log(Constants.DebugFlags.App.TaskDataLoader, Console.log(Constants.DebugFlags.App.TaskDataLoader, " [TaskResourceLoader|load]", " [TaskResourceLoader|load]", t + " icon: " + loadIcon + " thumbnail: " + loadThumbnail + t + " icon: " + loadIcon + " thumbnail: " + loadThumbnail + " forceLoad: " + forceLoadTask); " forceLoad: " + forceLoadTask); // Load the icon // Load the application icon if (loadIcon == null || forceLoadTask) { if (loadIcon == null || forceLoadTask) { ActivityInfo info = ssp.getActivityInfo(t.key.baseIntent.getComponent()); ActivityInfo info = ssp.getActivityInfo(t.key.baseIntent.getComponent()); Drawable icon = ssp.getActivityIcon(info); Drawable icon = ssp.getActivityIcon(info); Loading @@ -200,7 +201,7 @@ class TaskResourceLoader implements Runnable { " [TaskResourceLoader|loadIcon]", " [TaskResourceLoader|loadIcon]", icon); icon); loadIcon = icon; loadIcon = icon; mIconCache.put(t.key, icon); mApplicationIconCache.put(t.key, icon); } } } } } } Loading Loading @@ -293,7 +294,7 @@ public class RecentsTaskLoader { static RecentsTaskLoader sInstance; static RecentsTaskLoader sInstance; SystemServicesProxy mSystemServicesProxy; SystemServicesProxy mSystemServicesProxy; DrawableLruCache mIconCache; DrawableLruCache mApplicationIconCache; BitmapLruCache mThumbnailCache; BitmapLruCache mThumbnailCache; TaskResourceLoadQueue mLoadQueue; TaskResourceLoadQueue mLoadQueue; TaskResourceLoader mLoader; TaskResourceLoader mLoader; Loading @@ -301,7 +302,7 @@ public class RecentsTaskLoader { int mMaxThumbnailCacheSize; int mMaxThumbnailCacheSize; int mMaxIconCacheSize; int mMaxIconCacheSize; BitmapDrawable mDefaultIcon; BitmapDrawable mDefaultApplicationIcon; Bitmap mDefaultThumbnail; Bitmap mDefaultThumbnail; /** Private Constructor */ /** Private Constructor */ Loading @@ -324,9 +325,9 @@ public class RecentsTaskLoader { // Initialize the proxy, cache and loaders // Initialize the proxy, cache and loaders mSystemServicesProxy = new SystemServicesProxy(context); mSystemServicesProxy = new SystemServicesProxy(context); mLoadQueue = new TaskResourceLoadQueue(); mLoadQueue = new TaskResourceLoadQueue(); mIconCache = new DrawableLruCache(iconCacheSize); mApplicationIconCache = new DrawableLruCache(iconCacheSize); mThumbnailCache = new BitmapLruCache(thumbnailCacheSize); mThumbnailCache = new BitmapLruCache(thumbnailCacheSize); mLoader = new TaskResourceLoader(mLoadQueue, mIconCache, mThumbnailCache); mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache); // Create the default assets // Create the default assets Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); Loading @@ -337,10 +338,10 @@ public class RecentsTaskLoader { c.setBitmap(mDefaultThumbnail); c.setBitmap(mDefaultThumbnail); c.drawColor(0x00000000); c.drawColor(0x00000000); c.setBitmap(null); c.setBitmap(null); mDefaultIcon = new BitmapDrawable(context.getResources(), icon); mDefaultApplicationIcon = new BitmapDrawable(context.getResources(), icon); Console.log(Constants.DebugFlags.App.TaskDataLoader, Console.log(Constants.DebugFlags.App.TaskDataLoader, "[RecentsTaskLoader|defaultBitmaps]", "[RecentsTaskLoader|defaultBitmaps]", "icon: " + mDefaultIcon + " thumbnail: " + mDefaultThumbnail, Console.AnsiRed); "icon: " + mDefaultApplicationIcon + " thumbnail: " + mDefaultThumbnail, Console.AnsiRed); } } /** Initializes the recents task loader */ /** Initializes the recents task loader */ Loading Loading @@ -406,41 +407,36 @@ public class RecentsTaskLoader { for (int i = 0; i < taskCount; i++) { for (int i = 0; i < taskCount; i++) { ActivityManager.RecentTaskInfo t = tasks.get(i); ActivityManager.RecentTaskInfo t = tasks.get(i); ActivityInfo info = ssp.getActivityInfo(t.baseIntent.getComponent()); ActivityInfo info = ssp.getActivityInfo(t.baseIntent.getComponent()); String title = ssp.getActivityLabel(info); String activityLabel = (t.activityLabel == null ? ssp.getActivityLabel(info) : t.activityLabel.toString()); Bitmap activityIcon = t.activityIcon; boolean isForemostTask = (i == (taskCount - 1)); boolean isForemostTask = (i == (taskCount - 1)); // Create a new task Task task = new Task(t.persistentId, (t.id > -1), t.baseIntent, activityLabel, activityIcon); // Preload the specified number of apps // Preload the specified number of apps if (i >= (taskCount - preloadCount)) { if (i >= (taskCount - preloadCount)) { Console.log(Constants.DebugFlags.App.TaskDataLoader, Console.log(Constants.DebugFlags.App.TaskDataLoader, "[RecentsTaskLoader|preloadTask]", "[RecentsTaskLoader|preloadTask]", "i: " + i + " task: " + t.baseIntent.getComponent().getPackageName()); "i: " + i + " task: " + t.baseIntent.getComponent().getPackageName()); String label = (t.activityLabel == null ? title : t.activityLabel.toString()); BitmapDrawable bd = null; if (t.activityIcon != null) { bd = new BitmapDrawable(res, t.activityIcon); } Task task = new Task(t.persistentId, (t.id > -1), t.baseIntent, label, bd); // Load the icon (if possible and not the foremost task, from the cache) // Load the icon (if possible and not the foremost task, from the cache) if (task.icon != null) { mIconCache.put(task.key, task.icon); } else { if (!isForemostTask) { if (!isForemostTask) { task.icon = mIconCache.get(task.key); task.applicationIcon = mApplicationIconCache.get(task.key); if (task.icon != null) { if (task.applicationIcon != null) { // Even though we get things from the cache, we should update them // Even though we get things from the cache, we should update them // if they've changed in the bg // if they've changed in the bg tasksToForceLoad.add(task); tasksToForceLoad.add(task); } } } } if (task.icon == null) { if (task.applicationIcon == null) { task.icon = ssp.getActivityIcon(info); task.applicationIcon = ssp.getActivityIcon(info); if (task.icon != null) { if (task.applicationIcon != null) { mIconCache.put(task.key, task.icon); mApplicationIconCache.put(task.key, task.applicationIcon); } else { } else { task.icon = mDefaultIcon; task.applicationIcon = mDefaultApplicationIcon; } } } } } Loading @@ -463,18 +459,12 @@ public class RecentsTaskLoader { task.thumbnail = mDefaultThumbnail; task.thumbnail = mDefaultThumbnail; } } } } } // Add the task to the stack // Add the task to the stack Console.log(Constants.DebugFlags.App.TaskDataLoader, Console.log(Constants.DebugFlags.App.TaskDataLoader, " [RecentsTaskLoader|task]", t.baseIntent.getComponent().getPackageName()); " [RecentsTaskLoader|task]", t.baseIntent.getComponent().getPackageName()); stack.addTask(task); stack.addTask(task); } else { // Add the task to the stack Console.log(Constants.DebugFlags.App.TaskDataLoader, " [RecentsTaskLoader|task]", t.baseIntent.getComponent().getPackageName()); stack.addTask(new Task(t.persistentId, (t.id > -1), t.baseIntent, title, null, null)); } } } Console.log(Constants.DebugFlags.App.TimeSystemCalls, Console.log(Constants.DebugFlags.App.TimeSystemCalls, "[RecentsTaskLoader|getAllTaskTopThumbnail]", "[RecentsTaskLoader|getAllTaskTopThumbnail]", Loading Loading @@ -507,16 +497,16 @@ public class RecentsTaskLoader { /** Acquires the task resource data from the pool. */ /** Acquires the task resource data from the pool. */ public void loadTaskData(Task t) { public void loadTaskData(Task t) { Drawable icon = mIconCache.get(t.key); Drawable applicationIcon = mApplicationIconCache.get(t.key); Bitmap thumbnail = mThumbnailCache.get(t.key); Bitmap thumbnail = mThumbnailCache.get(t.key); Console.log(Constants.DebugFlags.App.TaskDataLoader, "[RecentsTaskLoader|loadTask]", Console.log(Constants.DebugFlags.App.TaskDataLoader, "[RecentsTaskLoader|loadTask]", t + " icon: " + icon + " thumbnail: " + thumbnail + t + " applicationIcon: " + applicationIcon + " thumbnail: " + thumbnail + " thumbnailCacheSize: " + mThumbnailCache.size()); " thumbnailCacheSize: " + mThumbnailCache.size()); boolean requiresLoad = false; boolean requiresLoad = false; if (icon == null) { if (applicationIcon == null) { icon = mDefaultIcon; applicationIcon = mDefaultApplicationIcon; requiresLoad = true; requiresLoad = true; } } if (thumbnail == null) { if (thumbnail == null) { Loading @@ -526,7 +516,7 @@ public class RecentsTaskLoader { if (requiresLoad) { if (requiresLoad) { mLoadQueue.addTask(t, false); mLoadQueue.addTask(t, false); } } t.notifyTaskDataLoaded(thumbnail, icon, false); t.notifyTaskDataLoaded(thumbnail, applicationIcon, false); } } /** Releases the task resource data back into the pool. */ /** Releases the task resource data back into the pool. */ Loading @@ -536,7 +526,7 @@ public class RecentsTaskLoader { " thumbnailCacheSize: " + mThumbnailCache.size()); " thumbnailCacheSize: " + mThumbnailCache.size()); mLoadQueue.removeTask(t); mLoadQueue.removeTask(t); t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultIcon); t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultApplicationIcon); } } /** Completely removes the resource data from the pool. */ /** Completely removes the resource data from the pool. */ Loading @@ -546,8 +536,8 @@ public class RecentsTaskLoader { mLoadQueue.removeTask(t); mLoadQueue.removeTask(t); mThumbnailCache.remove(t.key); mThumbnailCache.remove(t.key); mIconCache.remove(t.key); mApplicationIconCache.remove(t.key); t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultIcon); t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultApplicationIcon); } } /** Stops the task loader and clears all pending tasks */ /** Stops the task loader and clears all pending tasks */ Loading @@ -570,19 +560,19 @@ public class RecentsTaskLoader { case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND: case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND: // We are leaving recents, so trim the data a bit // We are leaving recents, so trim the data a bit mThumbnailCache.trimToSize(mMaxThumbnailCacheSize / 2); mThumbnailCache.trimToSize(mMaxThumbnailCacheSize / 2); mIconCache.trimToSize(mMaxIconCacheSize / 2); mApplicationIconCache.trimToSize(mMaxIconCacheSize / 2); break; break; case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW: case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW: case ComponentCallbacks2.TRIM_MEMORY_MODERATE: case ComponentCallbacks2.TRIM_MEMORY_MODERATE: // We are going to be low on memory // We are going to be low on memory mThumbnailCache.trimToSize(mMaxThumbnailCacheSize / 4); mThumbnailCache.trimToSize(mMaxThumbnailCacheSize / 4); mIconCache.trimToSize(mMaxIconCacheSize / 4); mApplicationIconCache.trimToSize(mMaxIconCacheSize / 4); break; break; case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL: case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL: case ComponentCallbacks2.TRIM_MEMORY_COMPLETE: case ComponentCallbacks2.TRIM_MEMORY_COMPLETE: // We are low on memory, so release everything // We are low on memory, so release everything mThumbnailCache.evictAll(); mThumbnailCache.evictAll(); mIconCache.evictAll(); mApplicationIconCache.evictAll(); break; break; default: default: break; break; Loading packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.graphics.drawable.Drawable; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; import java.util.Random; /** /** * Acts as a shim around the real system services that we need to access data from, and provides * Acts as a shim around the real system services that we need to access data from, and provides Loading Loading @@ -76,8 +77,11 @@ public class SystemServicesProxy { rti.id = rti.persistentId = i; rti.id = rti.persistentId = i; rti.baseIntent = new Intent(); rti.baseIntent = new Intent(); rti.baseIntent.setComponent(cn); rti.baseIntent.setComponent(cn); rti.description = rti.activityLabel = "Recent Task"; rti.description = rti.activityLabel = Long.toString(Math.abs(new Random().nextLong()), 36); if (i % 2 == 0) { rti.activityIcon = Bitmap.createBitmap(mDummyIcon); rti.activityIcon = Bitmap.createBitmap(mDummyIcon); } tasks.add(rti); tasks.add(rti); } } return tasks; return tasks; Loading Loading
packages/SystemUI/res/layout/recents_task_view.xml +13 −5 Original line number Original line Diff line number Diff line Loading @@ -28,21 +28,29 @@ android:layout_gravity="top|center_horizontal" android:layout_gravity="top|center_horizontal" android:background="#e6444444"> android:background="#e6444444"> <ImageView <ImageView android:id="@+id/activity_icon" android:id="@+id/application_icon" android:layout_width="@dimen/recents_task_view_icon_size" android:layout_width="@dimen/recents_task_view_application_icon_size" android:layout_height="@dimen/recents_task_view_icon_size" android:layout_height="@dimen/recents_task_view_application_icon_size" android:layout_gravity="top|left" android:layout_gravity="center_vertical|left" android:padding="8dp" /> android:padding="8dp" /> <TextView <TextView android:id="@+id/activity_description" android:id="@+id/activity_description" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|left" android:layout_gravity="center_vertical|left" android:layout_marginLeft="@dimen/recents_task_view_icon_size" android:layout_marginLeft="@dimen/recents_task_view_application_icon_size" android:layout_marginRight="@dimen/recents_task_view_activity_icon_size" android:textSize="24sp" android:textSize="24sp" android:textColor="#ffffffff" android:textColor="#ffffffff" android:text="@string/recents_empty_message" android:text="@string/recents_empty_message" android:fontFamily="sans-serif-thin" /> android:fontFamily="sans-serif-thin" /> <ImageView android:id="@+id/activity_icon" android:layout_width="@dimen/recents_task_view_activity_icon_size" android:layout_height="@dimen/recents_task_view_activity_icon_size" android:layout_gravity="center_vertical|right" android:padding="12dp" android:visibility="invisible" /> </com.android.systemui.recents.views.TaskBarView> </com.android.systemui.recents.views.TaskBarView> </com.android.systemui.recents.views.TaskView> </com.android.systemui.recents.views.TaskView> Loading
packages/SystemUI/res/values/dimens.xml +5 −2 Original line number Original line Diff line number Diff line Loading @@ -230,8 +230,11 @@ <!-- Default distance from each snap target that GlowPadView considers a "hit" --> <!-- Default distance from each snap target that GlowPadView considers a "hit" --> <dimen name="glowpadview_inner_radius">15dip</dimen> <dimen name="glowpadview_inner_radius">15dip</dimen> <!-- The size of the icon in the recents task view. --> <!-- The size of the application icon in the recents task view. --> <dimen name="recents_task_view_icon_size">60dp</dimen> <dimen name="recents_task_view_application_icon_size">60dp</dimen> <!-- The size of the activity icon in the recents task view. --> <dimen name="recents_task_view_activity_icon_size">60dp</dimen> <!-- Space below the notification stack --> <!-- Space below the notification stack --> <dimen name="notification_stack_margin_bottom">0dp</dimen> <dimen name="notification_stack_margin_bottom">0dp</dimen> Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +0 −1 Original line number Original line Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.os.Bundle; import android.os.Bundle; import android.os.SystemService; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.View; import android.view.View; import android.view.WindowManager; import android.view.WindowManager; Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java +49 −59 Original line number Original line Diff line number Diff line Loading @@ -110,17 +110,18 @@ class TaskResourceLoader implements Runnable { SystemServicesProxy mSystemServicesProxy; SystemServicesProxy mSystemServicesProxy; TaskResourceLoadQueue mLoadQueue; TaskResourceLoadQueue mLoadQueue; DrawableLruCache mIconCache; DrawableLruCache mApplicationIconCache; BitmapLruCache mThumbnailCache; BitmapLruCache mThumbnailCache; boolean mCancelled; boolean mCancelled; boolean mWaitingOnLoadQueue; boolean mWaitingOnLoadQueue; /** Constructor, creates a new loading thread that loads task resources in the background */ /** Constructor, creates a new loading thread that loads task resources in the background */ public TaskResourceLoader(TaskResourceLoadQueue loadQueue, DrawableLruCache iconCache, public TaskResourceLoader(TaskResourceLoadQueue loadQueue, DrawableLruCache applicationIconCache, BitmapLruCache thumbnailCache) { BitmapLruCache thumbnailCache) { mLoadQueue = loadQueue; mLoadQueue = loadQueue; mIconCache = iconCache; mApplicationIconCache = applicationIconCache; mThumbnailCache = thumbnailCache; mThumbnailCache = thumbnailCache; mMainThreadHandler = new Handler(); mMainThreadHandler = new Handler(); mLoadThread = new HandlerThread("Recents-TaskResourceLoader"); mLoadThread = new HandlerThread("Recents-TaskResourceLoader"); Loading Loading @@ -184,13 +185,13 @@ class TaskResourceLoader implements Runnable { final Task t = nextTaskData.first; final Task t = nextTaskData.first; final boolean forceLoadTask = nextTaskData.second; final boolean forceLoadTask = nextTaskData.second; if (t != null) { if (t != null) { Drawable loadIcon = mIconCache.get(t.key); Drawable loadIcon = mApplicationIconCache.get(t.key); Bitmap loadThumbnail = mThumbnailCache.get(t.key); Bitmap loadThumbnail = mThumbnailCache.get(t.key); Console.log(Constants.DebugFlags.App.TaskDataLoader, Console.log(Constants.DebugFlags.App.TaskDataLoader, " [TaskResourceLoader|load]", " [TaskResourceLoader|load]", t + " icon: " + loadIcon + " thumbnail: " + loadThumbnail + t + " icon: " + loadIcon + " thumbnail: " + loadThumbnail + " forceLoad: " + forceLoadTask); " forceLoad: " + forceLoadTask); // Load the icon // Load the application icon if (loadIcon == null || forceLoadTask) { if (loadIcon == null || forceLoadTask) { ActivityInfo info = ssp.getActivityInfo(t.key.baseIntent.getComponent()); ActivityInfo info = ssp.getActivityInfo(t.key.baseIntent.getComponent()); Drawable icon = ssp.getActivityIcon(info); Drawable icon = ssp.getActivityIcon(info); Loading @@ -200,7 +201,7 @@ class TaskResourceLoader implements Runnable { " [TaskResourceLoader|loadIcon]", " [TaskResourceLoader|loadIcon]", icon); icon); loadIcon = icon; loadIcon = icon; mIconCache.put(t.key, icon); mApplicationIconCache.put(t.key, icon); } } } } } } Loading Loading @@ -293,7 +294,7 @@ public class RecentsTaskLoader { static RecentsTaskLoader sInstance; static RecentsTaskLoader sInstance; SystemServicesProxy mSystemServicesProxy; SystemServicesProxy mSystemServicesProxy; DrawableLruCache mIconCache; DrawableLruCache mApplicationIconCache; BitmapLruCache mThumbnailCache; BitmapLruCache mThumbnailCache; TaskResourceLoadQueue mLoadQueue; TaskResourceLoadQueue mLoadQueue; TaskResourceLoader mLoader; TaskResourceLoader mLoader; Loading @@ -301,7 +302,7 @@ public class RecentsTaskLoader { int mMaxThumbnailCacheSize; int mMaxThumbnailCacheSize; int mMaxIconCacheSize; int mMaxIconCacheSize; BitmapDrawable mDefaultIcon; BitmapDrawable mDefaultApplicationIcon; Bitmap mDefaultThumbnail; Bitmap mDefaultThumbnail; /** Private Constructor */ /** Private Constructor */ Loading @@ -324,9 +325,9 @@ public class RecentsTaskLoader { // Initialize the proxy, cache and loaders // Initialize the proxy, cache and loaders mSystemServicesProxy = new SystemServicesProxy(context); mSystemServicesProxy = new SystemServicesProxy(context); mLoadQueue = new TaskResourceLoadQueue(); mLoadQueue = new TaskResourceLoadQueue(); mIconCache = new DrawableLruCache(iconCacheSize); mApplicationIconCache = new DrawableLruCache(iconCacheSize); mThumbnailCache = new BitmapLruCache(thumbnailCacheSize); mThumbnailCache = new BitmapLruCache(thumbnailCacheSize); mLoader = new TaskResourceLoader(mLoadQueue, mIconCache, mThumbnailCache); mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache); // Create the default assets // Create the default assets Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); Loading @@ -337,10 +338,10 @@ public class RecentsTaskLoader { c.setBitmap(mDefaultThumbnail); c.setBitmap(mDefaultThumbnail); c.drawColor(0x00000000); c.drawColor(0x00000000); c.setBitmap(null); c.setBitmap(null); mDefaultIcon = new BitmapDrawable(context.getResources(), icon); mDefaultApplicationIcon = new BitmapDrawable(context.getResources(), icon); Console.log(Constants.DebugFlags.App.TaskDataLoader, Console.log(Constants.DebugFlags.App.TaskDataLoader, "[RecentsTaskLoader|defaultBitmaps]", "[RecentsTaskLoader|defaultBitmaps]", "icon: " + mDefaultIcon + " thumbnail: " + mDefaultThumbnail, Console.AnsiRed); "icon: " + mDefaultApplicationIcon + " thumbnail: " + mDefaultThumbnail, Console.AnsiRed); } } /** Initializes the recents task loader */ /** Initializes the recents task loader */ Loading Loading @@ -406,41 +407,36 @@ public class RecentsTaskLoader { for (int i = 0; i < taskCount; i++) { for (int i = 0; i < taskCount; i++) { ActivityManager.RecentTaskInfo t = tasks.get(i); ActivityManager.RecentTaskInfo t = tasks.get(i); ActivityInfo info = ssp.getActivityInfo(t.baseIntent.getComponent()); ActivityInfo info = ssp.getActivityInfo(t.baseIntent.getComponent()); String title = ssp.getActivityLabel(info); String activityLabel = (t.activityLabel == null ? ssp.getActivityLabel(info) : t.activityLabel.toString()); Bitmap activityIcon = t.activityIcon; boolean isForemostTask = (i == (taskCount - 1)); boolean isForemostTask = (i == (taskCount - 1)); // Create a new task Task task = new Task(t.persistentId, (t.id > -1), t.baseIntent, activityLabel, activityIcon); // Preload the specified number of apps // Preload the specified number of apps if (i >= (taskCount - preloadCount)) { if (i >= (taskCount - preloadCount)) { Console.log(Constants.DebugFlags.App.TaskDataLoader, Console.log(Constants.DebugFlags.App.TaskDataLoader, "[RecentsTaskLoader|preloadTask]", "[RecentsTaskLoader|preloadTask]", "i: " + i + " task: " + t.baseIntent.getComponent().getPackageName()); "i: " + i + " task: " + t.baseIntent.getComponent().getPackageName()); String label = (t.activityLabel == null ? title : t.activityLabel.toString()); BitmapDrawable bd = null; if (t.activityIcon != null) { bd = new BitmapDrawable(res, t.activityIcon); } Task task = new Task(t.persistentId, (t.id > -1), t.baseIntent, label, bd); // Load the icon (if possible and not the foremost task, from the cache) // Load the icon (if possible and not the foremost task, from the cache) if (task.icon != null) { mIconCache.put(task.key, task.icon); } else { if (!isForemostTask) { if (!isForemostTask) { task.icon = mIconCache.get(task.key); task.applicationIcon = mApplicationIconCache.get(task.key); if (task.icon != null) { if (task.applicationIcon != null) { // Even though we get things from the cache, we should update them // Even though we get things from the cache, we should update them // if they've changed in the bg // if they've changed in the bg tasksToForceLoad.add(task); tasksToForceLoad.add(task); } } } } if (task.icon == null) { if (task.applicationIcon == null) { task.icon = ssp.getActivityIcon(info); task.applicationIcon = ssp.getActivityIcon(info); if (task.icon != null) { if (task.applicationIcon != null) { mIconCache.put(task.key, task.icon); mApplicationIconCache.put(task.key, task.applicationIcon); } else { } else { task.icon = mDefaultIcon; task.applicationIcon = mDefaultApplicationIcon; } } } } } Loading @@ -463,18 +459,12 @@ public class RecentsTaskLoader { task.thumbnail = mDefaultThumbnail; task.thumbnail = mDefaultThumbnail; } } } } } // Add the task to the stack // Add the task to the stack Console.log(Constants.DebugFlags.App.TaskDataLoader, Console.log(Constants.DebugFlags.App.TaskDataLoader, " [RecentsTaskLoader|task]", t.baseIntent.getComponent().getPackageName()); " [RecentsTaskLoader|task]", t.baseIntent.getComponent().getPackageName()); stack.addTask(task); stack.addTask(task); } else { // Add the task to the stack Console.log(Constants.DebugFlags.App.TaskDataLoader, " [RecentsTaskLoader|task]", t.baseIntent.getComponent().getPackageName()); stack.addTask(new Task(t.persistentId, (t.id > -1), t.baseIntent, title, null, null)); } } } Console.log(Constants.DebugFlags.App.TimeSystemCalls, Console.log(Constants.DebugFlags.App.TimeSystemCalls, "[RecentsTaskLoader|getAllTaskTopThumbnail]", "[RecentsTaskLoader|getAllTaskTopThumbnail]", Loading Loading @@ -507,16 +497,16 @@ public class RecentsTaskLoader { /** Acquires the task resource data from the pool. */ /** Acquires the task resource data from the pool. */ public void loadTaskData(Task t) { public void loadTaskData(Task t) { Drawable icon = mIconCache.get(t.key); Drawable applicationIcon = mApplicationIconCache.get(t.key); Bitmap thumbnail = mThumbnailCache.get(t.key); Bitmap thumbnail = mThumbnailCache.get(t.key); Console.log(Constants.DebugFlags.App.TaskDataLoader, "[RecentsTaskLoader|loadTask]", Console.log(Constants.DebugFlags.App.TaskDataLoader, "[RecentsTaskLoader|loadTask]", t + " icon: " + icon + " thumbnail: " + thumbnail + t + " applicationIcon: " + applicationIcon + " thumbnail: " + thumbnail + " thumbnailCacheSize: " + mThumbnailCache.size()); " thumbnailCacheSize: " + mThumbnailCache.size()); boolean requiresLoad = false; boolean requiresLoad = false; if (icon == null) { if (applicationIcon == null) { icon = mDefaultIcon; applicationIcon = mDefaultApplicationIcon; requiresLoad = true; requiresLoad = true; } } if (thumbnail == null) { if (thumbnail == null) { Loading @@ -526,7 +516,7 @@ public class RecentsTaskLoader { if (requiresLoad) { if (requiresLoad) { mLoadQueue.addTask(t, false); mLoadQueue.addTask(t, false); } } t.notifyTaskDataLoaded(thumbnail, icon, false); t.notifyTaskDataLoaded(thumbnail, applicationIcon, false); } } /** Releases the task resource data back into the pool. */ /** Releases the task resource data back into the pool. */ Loading @@ -536,7 +526,7 @@ public class RecentsTaskLoader { " thumbnailCacheSize: " + mThumbnailCache.size()); " thumbnailCacheSize: " + mThumbnailCache.size()); mLoadQueue.removeTask(t); mLoadQueue.removeTask(t); t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultIcon); t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultApplicationIcon); } } /** Completely removes the resource data from the pool. */ /** Completely removes the resource data from the pool. */ Loading @@ -546,8 +536,8 @@ public class RecentsTaskLoader { mLoadQueue.removeTask(t); mLoadQueue.removeTask(t); mThumbnailCache.remove(t.key); mThumbnailCache.remove(t.key); mIconCache.remove(t.key); mApplicationIconCache.remove(t.key); t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultIcon); t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultApplicationIcon); } } /** Stops the task loader and clears all pending tasks */ /** Stops the task loader and clears all pending tasks */ Loading @@ -570,19 +560,19 @@ public class RecentsTaskLoader { case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND: case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND: // We are leaving recents, so trim the data a bit // We are leaving recents, so trim the data a bit mThumbnailCache.trimToSize(mMaxThumbnailCacheSize / 2); mThumbnailCache.trimToSize(mMaxThumbnailCacheSize / 2); mIconCache.trimToSize(mMaxIconCacheSize / 2); mApplicationIconCache.trimToSize(mMaxIconCacheSize / 2); break; break; case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW: case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW: case ComponentCallbacks2.TRIM_MEMORY_MODERATE: case ComponentCallbacks2.TRIM_MEMORY_MODERATE: // We are going to be low on memory // We are going to be low on memory mThumbnailCache.trimToSize(mMaxThumbnailCacheSize / 4); mThumbnailCache.trimToSize(mMaxThumbnailCacheSize / 4); mIconCache.trimToSize(mMaxIconCacheSize / 4); mApplicationIconCache.trimToSize(mMaxIconCacheSize / 4); break; break; case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL: case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL: case ComponentCallbacks2.TRIM_MEMORY_COMPLETE: case ComponentCallbacks2.TRIM_MEMORY_COMPLETE: // We are low on memory, so release everything // We are low on memory, so release everything mThumbnailCache.evictAll(); mThumbnailCache.evictAll(); mIconCache.evictAll(); mApplicationIconCache.evictAll(); break; break; default: default: break; break; Loading
packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.graphics.drawable.Drawable; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; import java.util.Random; /** /** * Acts as a shim around the real system services that we need to access data from, and provides * Acts as a shim around the real system services that we need to access data from, and provides Loading Loading @@ -76,8 +77,11 @@ public class SystemServicesProxy { rti.id = rti.persistentId = i; rti.id = rti.persistentId = i; rti.baseIntent = new Intent(); rti.baseIntent = new Intent(); rti.baseIntent.setComponent(cn); rti.baseIntent.setComponent(cn); rti.description = rti.activityLabel = "Recent Task"; rti.description = rti.activityLabel = Long.toString(Math.abs(new Random().nextLong()), 36); if (i % 2 == 0) { rti.activityIcon = Bitmap.createBitmap(mDummyIcon); rti.activityIcon = Bitmap.createBitmap(mDummyIcon); } tasks.add(rti); tasks.add(rti); } } return tasks; return tasks; Loading