Loading packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +1 −0 Original line number Diff line number Diff line Loading @@ -585,6 +585,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD @Override public void onUserInteraction() { // TODO: Prevent creating so many events here final RecentsDebugFlags debugFlags = Recents.getDebugFlags(); EventBus.getDefault().send(new UserInteractionEvent(debugFlags.isFastToggleRecentsEnabled() && debugFlags.isFastToggleIndicatorEnabled())); Loading packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java +26 −1 Original line number Diff line number Diff line Loading @@ -289,6 +289,28 @@ public class EventBus extends BroadcastReceiver { } } /** * An event that can be reusable, only used for situations where we want to reduce memory * allocations when events are sent frequently (ie. on scroll). */ public static class ReusableEvent extends Event { private int mDispatchCount; protected ReusableEvent() {} @Override void onPostDispatch() { super.onPostDispatch(); mDispatchCount++; } @Override protected Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); } } /** * An inter-process event super class that allows us to track user state across subscriber * invocations. Loading Loading @@ -770,8 +792,11 @@ public class EventBus extends BroadcastReceiver { event.onPreDispatch(); // We need to clone the list in case a subscriber unregisters itself during traversal // TODO: Investigate whether we can skip the object creation here eventHandlers = (ArrayList<EventHandler>) eventHandlers.clone(); for (final EventHandler eventHandler : eventHandlers) { int eventHandlerCount = eventHandlers.size(); for (int i = 0; i < eventHandlerCount; i++) { final EventHandler eventHandler = eventHandlers.get(i); if (eventHandler.subscriber.getReference() != null) { if (event.requiresPost) { mHandler.post(new Runnable() { Loading packages/SystemUI/src/com/android/systemui/recents/events/ui/StackViewScrolledEvent.java +9 −4 Original line number Diff line number Diff line Loading @@ -16,16 +16,21 @@ package com.android.systemui.recents.events.ui; import android.util.MutableInt; import com.android.systemui.recents.events.EventBus; /** * This is sent whenever a new scroll gesture happens on a stack view. */ public class StackViewScrolledEvent extends EventBus.Event { public class StackViewScrolledEvent extends EventBus.ReusableEvent { public final int yMovement; public final MutableInt yMovement; public StackViewScrolledEvent(int yMovement) { this.yMovement = yMovement; public StackViewScrolledEvent() { yMovement = new MutableInt(0); } public void updateY(int y) { yMovement.value = y; } } packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +7 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,9 @@ import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.os.UserManager; import android.util.ArraySet; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.misc.SystemServicesProxy; Loading Loading @@ -120,6 +122,8 @@ public class RecentsTaskLoadPlan { preloadRawTasks(isTopTaskHome); } String dismissDescFormat = mContext.getString( R.string.accessibility_recents_item_will_be_dismissed); long lastStackActiveTime = Prefs.getLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0); long newLastStackActiveTime = -1; Loading @@ -143,6 +147,7 @@ public class RecentsTaskLoadPlan { // Load the title, icon, and color String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription); String contentDescription = loader.getAndUpdateContentDescription(taskKey, title, res); String dismissDescription = String.format(dismissDescFormat, contentDescription); Drawable icon = isStackTask ? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false) : null; Loading @@ -151,8 +156,8 @@ public class RecentsTaskLoadPlan { // Add the task to the stack Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon, thumbnail, title, contentDescription, activityColor, !isStackTask, t.bounds, t.taskDescription); thumbnail, title, contentDescription, dismissDescription, activityColor, !isStackTask, t.bounds, t.taskDescription); allTasks.add(task); } Loading packages/SystemUI/src/com/android/systemui/recents/model/Task.java +20 −5 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ public class Task { public long firstActiveTime; public long lastActiveTime; private int mHashCode; public TaskKey(int id, int stackId, Intent intent, int userId, long firstActiveTime, long lastActiveTime) { this.id = id; Loading @@ -62,6 +64,12 @@ public class Task { this.userId = userId; this.firstActiveTime = firstActiveTime; this.lastActiveTime = lastActiveTime; updateHashCode(); } public void setStackId(int stackId) { this.stackId = stackId; updateHashCode(); } public ComponentName getComponent() { Loading @@ -79,7 +87,7 @@ public class Task { @Override public int hashCode() { return Objects.hash(id, stackId, userId); return mHashCode; } @Override Loading @@ -90,6 +98,10 @@ public class Task { + "lat: " + lastActiveTime + ", " + getComponent().getPackageName(); } private void updateHashCode() { mHashCode = Objects.hash(id, stackId, userId); } } public TaskKey key; Loading @@ -113,6 +125,7 @@ public class Task { public Bitmap thumbnail; public String title; public String contentDescription; public String dismissDescription; public int colorPrimary; public boolean useLightOnPrimaryColor; Loading @@ -139,9 +152,9 @@ public class Task { } public Task(TaskKey key, int affiliationTaskId, int affiliationColor, Drawable icon, Bitmap thumbnail, String title, String contentDescription, int colorPrimary, boolean isHistorical, Rect bounds, ActivityManager.TaskDescription taskDescription) { Bitmap thumbnail, String title, String contentDescription, String dismissDescription, int colorPrimary, boolean isHistorical, Rect bounds, ActivityManager.TaskDescription taskDescription) { boolean isInAffiliationGroup = (affiliationTaskId != key.id); boolean hasAffiliationGroupColor = isInAffiliationGroup && (affiliationColor != 0); this.key = key; Loading @@ -151,6 +164,7 @@ public class Task { this.thumbnail = thumbnail; this.title = title; this.contentDescription = contentDescription; this.dismissDescription = dismissDescription; this.colorPrimary = hasAffiliationGroupColor ? affiliationColor : colorPrimary; this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(this.colorPrimary, Color.WHITE) > 3f; Loading @@ -169,6 +183,7 @@ public class Task { this.thumbnail = o.thumbnail; this.title = o.title; this.contentDescription = o.contentDescription; this.dismissDescription = o.dismissDescription; this.colorPrimary = o.colorPrimary; this.useLightOnPrimaryColor = o.useLightOnPrimaryColor; this.bounds = o.bounds; Loading Loading @@ -201,7 +216,7 @@ public class Task { * Updates the stack id of this task. */ public void setStackId(int stackId) { key.stackId = stackId; key.setStackId(stackId); int callbackCount = mCallbacks.size(); for (int i = 0; i < callbackCount; i++) { mCallbacks.get(i).onTaskStackIdChanged(); Loading Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +1 −0 Original line number Diff line number Diff line Loading @@ -585,6 +585,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD @Override public void onUserInteraction() { // TODO: Prevent creating so many events here final RecentsDebugFlags debugFlags = Recents.getDebugFlags(); EventBus.getDefault().send(new UserInteractionEvent(debugFlags.isFastToggleRecentsEnabled() && debugFlags.isFastToggleIndicatorEnabled())); Loading
packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java +26 −1 Original line number Diff line number Diff line Loading @@ -289,6 +289,28 @@ public class EventBus extends BroadcastReceiver { } } /** * An event that can be reusable, only used for situations where we want to reduce memory * allocations when events are sent frequently (ie. on scroll). */ public static class ReusableEvent extends Event { private int mDispatchCount; protected ReusableEvent() {} @Override void onPostDispatch() { super.onPostDispatch(); mDispatchCount++; } @Override protected Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); } } /** * An inter-process event super class that allows us to track user state across subscriber * invocations. Loading Loading @@ -770,8 +792,11 @@ public class EventBus extends BroadcastReceiver { event.onPreDispatch(); // We need to clone the list in case a subscriber unregisters itself during traversal // TODO: Investigate whether we can skip the object creation here eventHandlers = (ArrayList<EventHandler>) eventHandlers.clone(); for (final EventHandler eventHandler : eventHandlers) { int eventHandlerCount = eventHandlers.size(); for (int i = 0; i < eventHandlerCount; i++) { final EventHandler eventHandler = eventHandlers.get(i); if (eventHandler.subscriber.getReference() != null) { if (event.requiresPost) { mHandler.post(new Runnable() { Loading
packages/SystemUI/src/com/android/systemui/recents/events/ui/StackViewScrolledEvent.java +9 −4 Original line number Diff line number Diff line Loading @@ -16,16 +16,21 @@ package com.android.systemui.recents.events.ui; import android.util.MutableInt; import com.android.systemui.recents.events.EventBus; /** * This is sent whenever a new scroll gesture happens on a stack view. */ public class StackViewScrolledEvent extends EventBus.Event { public class StackViewScrolledEvent extends EventBus.ReusableEvent { public final int yMovement; public final MutableInt yMovement; public StackViewScrolledEvent(int yMovement) { this.yMovement = yMovement; public StackViewScrolledEvent() { yMovement = new MutableInt(0); } public void updateY(int y) { yMovement.value = y; } }
packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +7 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,9 @@ import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.os.UserManager; import android.util.ArraySet; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsConfiguration; import com.android.systemui.recents.misc.SystemServicesProxy; Loading Loading @@ -120,6 +122,8 @@ public class RecentsTaskLoadPlan { preloadRawTasks(isTopTaskHome); } String dismissDescFormat = mContext.getString( R.string.accessibility_recents_item_will_be_dismissed); long lastStackActiveTime = Prefs.getLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0); long newLastStackActiveTime = -1; Loading @@ -143,6 +147,7 @@ public class RecentsTaskLoadPlan { // Load the title, icon, and color String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription); String contentDescription = loader.getAndUpdateContentDescription(taskKey, title, res); String dismissDescription = String.format(dismissDescFormat, contentDescription); Drawable icon = isStackTask ? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false) : null; Loading @@ -151,8 +156,8 @@ public class RecentsTaskLoadPlan { // Add the task to the stack Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon, thumbnail, title, contentDescription, activityColor, !isStackTask, t.bounds, t.taskDescription); thumbnail, title, contentDescription, dismissDescription, activityColor, !isStackTask, t.bounds, t.taskDescription); allTasks.add(task); } Loading
packages/SystemUI/src/com/android/systemui/recents/model/Task.java +20 −5 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ public class Task { public long firstActiveTime; public long lastActiveTime; private int mHashCode; public TaskKey(int id, int stackId, Intent intent, int userId, long firstActiveTime, long lastActiveTime) { this.id = id; Loading @@ -62,6 +64,12 @@ public class Task { this.userId = userId; this.firstActiveTime = firstActiveTime; this.lastActiveTime = lastActiveTime; updateHashCode(); } public void setStackId(int stackId) { this.stackId = stackId; updateHashCode(); } public ComponentName getComponent() { Loading @@ -79,7 +87,7 @@ public class Task { @Override public int hashCode() { return Objects.hash(id, stackId, userId); return mHashCode; } @Override Loading @@ -90,6 +98,10 @@ public class Task { + "lat: " + lastActiveTime + ", " + getComponent().getPackageName(); } private void updateHashCode() { mHashCode = Objects.hash(id, stackId, userId); } } public TaskKey key; Loading @@ -113,6 +125,7 @@ public class Task { public Bitmap thumbnail; public String title; public String contentDescription; public String dismissDescription; public int colorPrimary; public boolean useLightOnPrimaryColor; Loading @@ -139,9 +152,9 @@ public class Task { } public Task(TaskKey key, int affiliationTaskId, int affiliationColor, Drawable icon, Bitmap thumbnail, String title, String contentDescription, int colorPrimary, boolean isHistorical, Rect bounds, ActivityManager.TaskDescription taskDescription) { Bitmap thumbnail, String title, String contentDescription, String dismissDescription, int colorPrimary, boolean isHistorical, Rect bounds, ActivityManager.TaskDescription taskDescription) { boolean isInAffiliationGroup = (affiliationTaskId != key.id); boolean hasAffiliationGroupColor = isInAffiliationGroup && (affiliationColor != 0); this.key = key; Loading @@ -151,6 +164,7 @@ public class Task { this.thumbnail = thumbnail; this.title = title; this.contentDescription = contentDescription; this.dismissDescription = dismissDescription; this.colorPrimary = hasAffiliationGroupColor ? affiliationColor : colorPrimary; this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(this.colorPrimary, Color.WHITE) > 3f; Loading @@ -169,6 +183,7 @@ public class Task { this.thumbnail = o.thumbnail; this.title = o.title; this.contentDescription = o.contentDescription; this.dismissDescription = o.dismissDescription; this.colorPrimary = o.colorPrimary; this.useLightOnPrimaryColor = o.useLightOnPrimaryColor; this.bounds = o.bounds; Loading Loading @@ -201,7 +216,7 @@ public class Task { * Updates the stack id of this task. */ public void setStackId(int stackId) { key.stackId = stackId; key.setStackId(stackId); int callbackCount = mCallbacks.size(); for (int i = 0; i < callbackCount; i++) { mCallbacks.get(i).onTaskStackIdChanged(); Loading