Loading packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java +65 −9 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; /** A proxy implementation for the recents component */ public class AlternateRecentsComponent { public class AlternateRecentsComponent implements ActivityOptions.OnAnimationStartedListener { final public static String EXTRA_FROM_HOME = "recents.triggeredOverHome"; final public static String EXTRA_FROM_SEARCH_HOME = "recents.triggeredOverSearchHome"; Loading @@ -62,7 +62,9 @@ public class AlternateRecentsComponent { final public static String EXTRA_FROM_TASK_ID = "recents.activeTaskId"; final public static String EXTRA_TRIGGERED_FROM_ALT_TAB = "recents.triggeredFromAltTab"; final public static String EXTRA_TRIGGERED_FROM_HOME_KEY = "recents.triggeredFromHomeKey"; final public static String EXTRA_REUSE_TASK_STACK_VIEWS = "recents.reuseTaskStackViews"; final public static String ACTION_START_ENTER_ANIMATION = "action_start_enter_animation"; final public static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity"; final public static String ACTION_HIDE_RECENTS_ACTIVITY = "action_hide_recents_activity"; Loading @@ -77,7 +79,10 @@ public class AlternateRecentsComponent { Context mContext; LayoutInflater mInflater; SystemServicesProxy mSystemServicesProxy; Handler mHandler; boolean mBootCompleted; boolean mStartAnimationTriggered; boolean mCanReuseTaskStackViews = true; // Task launching RecentsConfiguration mConfig; Loading @@ -103,6 +108,7 @@ public class AlternateRecentsComponent { mInflater = LayoutInflater.from(context); mContext = context; mSystemServicesProxy = new SystemServicesProxy(context); mHandler = new Handler(); mTaskStackBounds = new Rect(); } Loading @@ -128,7 +134,7 @@ public class AlternateRecentsComponent { } // When we start, preload the metadata associated with the previous tasks RecentsTaskLoader.getInstance().preload(mContext); RecentsTaskLoader.getInstance().preload(mContext, RecentsTaskLoader.ALL_TASKS); } public void onBootCompleted() { Loading Loading @@ -176,7 +182,9 @@ public class AlternateRecentsComponent { } public void onPreloadRecents() { // Do nothing // When we start, preload the metadata associated with the previous tasks RecentsTaskLoader.getInstance().preload(mContext, Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount); } public void onCancelPreloadingRecents() { Loading @@ -186,7 +194,7 @@ public class AlternateRecentsComponent { void showRelativeAffiliatedTask(boolean showNextTask) { RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); TaskStack stack = loader.getTaskStack(mSystemServicesProxy, mContext.getResources(), -1, -1, false, true, null, null); -1, -1, RecentsTaskLoader.ALL_TASKS, false, true, null, null); // Return early if there are no tasks if (stack.getTaskCount() == 0) return; Loading Loading @@ -251,6 +259,8 @@ public class AlternateRecentsComponent { } public void onConfigurationChanged(Configuration newConfig) { // Don't reuse task stack views if the configuration changes mCanReuseTaskStackViews = false; // Reload the header bar layout reloadHeaderBarLayout(); } Loading Loading @@ -364,23 +374,28 @@ public class AlternateRecentsComponent { * Creates the activity options for a unknown state->recents transition. */ ActivityOptions getUnknownTransitionActivityOptions() { mStartAnimationTriggered = false; return ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_from_unknown_enter, R.anim.recents_from_unknown_exit); R.anim.recents_from_unknown_exit, mHandler, this); } /** * Creates the activity options for a home->recents transition. */ ActivityOptions getHomeTransitionActivityOptions(boolean fromSearchHome) { mStartAnimationTriggered = false; if (fromSearchHome) { return ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_from_search_launcher_enter, R.anim.recents_from_search_launcher_exit); R.anim.recents_from_search_launcher_exit, mHandler, this); } return ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_from_launcher_enter, R.anim.recents_from_launcher_exit); R.anim.recents_from_launcher_exit, mHandler, this); } /** Loading Loading @@ -408,9 +423,10 @@ public class AlternateRecentsComponent { c.setBitmap(null); } mStartAnimationTriggered = false; return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mStatusBarView, thumbnail, toTaskRect.left, toTaskRect.top, toTaskRect.width(), toTaskRect.height(), null); toTaskRect.height(), this); } // If both the screenshot and thumbnail fails, then just fall back to the default transition Loading @@ -423,7 +439,7 @@ public class AlternateRecentsComponent { // Get the stack of tasks that we are animating into RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); TaskStack stack = loader.getTaskStack(mSystemServicesProxy, mContext.getResources(), runningTaskId, -1, false, isTopTaskHome, null, null); runningTaskId, -1, RecentsTaskLoader.ALL_TASKS, false, isTopTaskHome, null, null); if (stack.getTaskCount() == 0) { return null; } Loading Loading @@ -529,11 +545,13 @@ public class AlternateRecentsComponent { } intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, mTriggeredFromAltTab); intent.putExtra(EXTRA_FROM_TASK_ID, (topTask != null) ? topTask.id : -1); intent.putExtra(EXTRA_REUSE_TASK_STACK_VIEWS, mCanReuseTaskStackViews); if (opts != null) { mContext.startActivityAsUser(intent, opts.toBundle(), UserHandle.CURRENT); } else { mContext.startActivityAsUser(intent, UserHandle.CURRENT); } mCanReuseTaskStackViews = true; } /** Sets the RecentsComponent callbacks. */ Loading @@ -547,4 +565,42 @@ public class AlternateRecentsComponent { sRecentsComponentCallbacks.onVisibilityChanged(visible); } } /**** OnAnimationStartedListener Implementation ****/ @Override public void onAnimationStarted() { // Notify recents to start the enter animation if (!mStartAnimationTriggered) { // There can be a race condition between the start animation callback and // the start of the new activity (where we register the receiver that listens // to this broadcast, so we add our own receiver and if that gets called, then // we know the activity has not yet started and we can retry sending the broadcast. BroadcastReceiver fallbackReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (getResultCode() == Activity.RESULT_OK) { mStartAnimationTriggered = true; return; } // Schedule for the broadcast to be sent again after some time mHandler.postDelayed(new Runnable() { @Override public void run() { onAnimationStarted(); } }, 25); } }; // Send the broadcast to notify Recents that the animation has started Intent intent = new Intent(ACTION_START_ENTER_ANIMATION); intent.setPackage(mContext.getPackageName()); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT | Intent.FLAG_RECEIVER_FOREGROUND); mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null, fallbackReceiver, null, Activity.RESULT_CANCELED, null, null); } } } packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +20 −20 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; import android.os.Looper; Loading Loading @@ -142,6 +143,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView } else if (action.equals(AlternateRecentsComponent.ACTION_TOGGLE_RECENTS_ACTIVITY)) { // If we are toggling Recents, then first unfilter any filtered stacks first dismissRecentsToFocusedTaskOrHome(true); } else if (action.equals(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION)) { // Trigger the enter animation onEnterAnimationTriggered(); // Notify the fallback receiver that we have successfully got the broadcast // See AlternateRecentsComponent.onAnimationStarted() setResultCode(Activity.RESULT_OK); } } }; Loading @@ -157,7 +164,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // When the screen turns off, dismiss Recents to Home dismissRecentsToHome(false); // Start preloading some tasks in the background RecentsTaskLoader.getInstance().preload(RecentsActivity.this); RecentsTaskLoader.getInstance().preload(RecentsActivity.this, Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount); } else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) { // When the search activity changes, update the Search widget refreshSearchWidget(); Loading Loading @@ -188,6 +196,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView AlternateRecentsComponent.EXTRA_FROM_TASK_ID, -1); mConfig.launchedWithAltTab = launchIntent.getBooleanExtra( AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false); mConfig.launchedReuseTaskStackViews = launchIntent.getBooleanExtra( AlternateRecentsComponent.EXTRA_REUSE_TASK_STACK_VIEWS, false); // Load all the tasks RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); Loading Loading @@ -397,8 +407,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // Update if we are getting a configuration change if (savedInstanceState != null) { // Update RecentsConfiguration mConfig = RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); mConfig.updateOnConfigurationChange(); onConfigurationChange(); // Trigger the enter animation onEnterAnimationTriggered(); } // Start listening for widget package changes if there is one bound, post it since we don't Loading Loading @@ -428,19 +442,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView } } /** Called when the configuration changes. */ void onConfigurationChange() { // Update RecentsConfiguration mConfig = RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); // Try and start the enter animation (or restart it on configuration changed) ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null); mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t)); // Animate the SystemUI scrim views mScrimViews.startEnterRecentsAnimation(); } /** Handles changes to the activity visibility. */ void onRecentsActivityVisibilityChanged(boolean visible) { if (!visible) { Loading Loading @@ -474,6 +475,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView IntentFilter filter = new IntentFilter(); filter.addAction(AlternateRecentsComponent.ACTION_HIDE_RECENTS_ACTIVITY); filter.addAction(AlternateRecentsComponent.ACTION_TOGGLE_RECENTS_ACTIVITY); filter.addAction(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION); registerReceiver(mServiceBroadcastReceiver, filter); // Register any broadcast receivers for the task loader Loading @@ -492,8 +494,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView protected void onStop() { super.onStop(); // Remove all the views mRecentsView.removeAllTaskStacks(); // Notify the views that we are no longer visible mRecentsView.onRecentsHidden(); // Unregister the RecentsService receiver unregisterReceiver(mServiceBroadcastReceiver); Loading @@ -515,8 +517,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView } } @Override public void onEnterAnimationComplete() { public void onEnterAnimationTriggered() { // Try and start the enter animation (or restart it on configuration changed) ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null); mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t)); Loading Loading @@ -584,7 +585,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView /** Called when debug mode is triggered */ public void onDebugModeTriggered() { if (mConfig.developerOptionsEnabled) { SharedPreferences settings = getSharedPreferences(getPackageName(), 0); if (settings.getBoolean(Constants.Values.App.Key_DebugModeEnabled, false)) { Loading packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java +2 −1 Original line number Diff line number Diff line Loading @@ -115,8 +115,8 @@ public class RecentsConfiguration { public boolean launchedWithAltTab; public boolean launchedWithNoRecentTasks; public boolean launchedFromAppWithThumbnail; public boolean launchedFromAppWithScreenshot; public boolean launchedFromHome; public boolean launchedReuseTaskStackViews; public int launchedToTaskId; /** Misc **/ Loading Loading @@ -308,6 +308,7 @@ public class RecentsConfiguration { launchedWithNoRecentTasks = false; launchedFromAppWithThumbnail = false; launchedFromHome = false; launchedReuseTaskStackViews = false; launchedToTaskId = -1; } Loading packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java +5 −0 Original line number Diff line number Diff line Loading @@ -82,4 +82,9 @@ public class DozeTrigger { public boolean hasTriggered() { return mHasTriggered; } /** Resets the doze trigger state. */ public void resetTrigger() { mHasTriggered = false; } } packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +11 −8 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ public class RecentsTaskLoader { private static final String TAG = "RecentsTaskLoader"; static RecentsTaskLoader sInstance; public static final int ALL_TASKS = -1; SystemServicesProxy mSystemServicesProxy; DrawableLruCache mApplicationIconCache; Loading Loading @@ -326,10 +327,9 @@ public class RecentsTaskLoader { /** Gets the list of recent tasks, ordered from back to front. */ private static List<ActivityManager.RecentTaskInfo> getRecentTasks(SystemServicesProxy ssp, boolean isTopTaskHome) { RecentsConfiguration config = RecentsConfiguration.getInstance(); int numTasksToLoad, boolean isTopTaskHome) { List<ActivityManager.RecentTaskInfo> tasks = ssp.getRecentTasks(config.maxNumTasksToLoad, UserHandle.CURRENT.getIdentifier(), ssp.getRecentTasks(numTasksToLoad, UserHandle.CURRENT.getIdentifier(), isTopTaskHome); Collections.reverse(tasks); return tasks; Loading Loading @@ -416,7 +416,8 @@ public class RecentsTaskLoader { ArrayList<Task.TaskKey> taskKeys = new ArrayList<Task.TaskKey>(); ArrayList<Task> tasksToLoad = new ArrayList<Task>(); TaskStack stack = getTaskStack(mSystemServicesProxy, context.getResources(), -1, preloadCount, true, isTopTaskHome, taskKeys, tasksToLoad); -1, preloadCount, RecentsTaskLoader.ALL_TASKS, true, isTopTaskHome, taskKeys, tasksToLoad); SpaceNode root = new SpaceNode(); root.setStack(stack); Loading @@ -428,10 +429,10 @@ public class RecentsTaskLoader { } /** Preloads the set of recent tasks (not including thumbnails). */ public void preload(Context context) { public void preload(Context context, int numTasksToPreload) { ArrayList<Task> tasksToLoad = new ArrayList<Task>(); getTaskStack(mSystemServicesProxy, context.getResources(), -1, -1, true, true, null, tasksToLoad); -1, -1, numTasksToPreload, true, true, null, tasksToLoad); // Start the task loader and add all the tasks we need to load mLoadQueue.addTasks(tasksToLoad); Loading @@ -440,11 +441,13 @@ public class RecentsTaskLoader { /** Creates a lightweight stack of the current recent tasks, without thumbnails and icons. */ public synchronized TaskStack getTaskStack(SystemServicesProxy ssp, Resources res, int preloadTaskId, int preloadTaskCount, int preloadTaskId, int preloadTaskCount, int loadTaskCount, boolean loadTaskThumbnails, boolean isTopTaskHome, List<Task.TaskKey> taskKeysOut, List<Task> tasksToLoadOut) { RecentsConfiguration config = RecentsConfiguration.getInstance(); List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp, isTopTaskHome); List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp, (loadTaskCount == ALL_TASKS ? config.maxNumTasksToLoad : loadTaskCount), isTopTaskHome); HashMap<Task.ComponentNameKey, ActivityInfoHandle> activityInfoCache = new HashMap<Task.ComponentNameKey, ActivityInfoHandle>(); ArrayList<Task> tasksToAdd = new ArrayList<Task>(); Loading Loading
packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java +65 −9 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; /** A proxy implementation for the recents component */ public class AlternateRecentsComponent { public class AlternateRecentsComponent implements ActivityOptions.OnAnimationStartedListener { final public static String EXTRA_FROM_HOME = "recents.triggeredOverHome"; final public static String EXTRA_FROM_SEARCH_HOME = "recents.triggeredOverSearchHome"; Loading @@ -62,7 +62,9 @@ public class AlternateRecentsComponent { final public static String EXTRA_FROM_TASK_ID = "recents.activeTaskId"; final public static String EXTRA_TRIGGERED_FROM_ALT_TAB = "recents.triggeredFromAltTab"; final public static String EXTRA_TRIGGERED_FROM_HOME_KEY = "recents.triggeredFromHomeKey"; final public static String EXTRA_REUSE_TASK_STACK_VIEWS = "recents.reuseTaskStackViews"; final public static String ACTION_START_ENTER_ANIMATION = "action_start_enter_animation"; final public static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity"; final public static String ACTION_HIDE_RECENTS_ACTIVITY = "action_hide_recents_activity"; Loading @@ -77,7 +79,10 @@ public class AlternateRecentsComponent { Context mContext; LayoutInflater mInflater; SystemServicesProxy mSystemServicesProxy; Handler mHandler; boolean mBootCompleted; boolean mStartAnimationTriggered; boolean mCanReuseTaskStackViews = true; // Task launching RecentsConfiguration mConfig; Loading @@ -103,6 +108,7 @@ public class AlternateRecentsComponent { mInflater = LayoutInflater.from(context); mContext = context; mSystemServicesProxy = new SystemServicesProxy(context); mHandler = new Handler(); mTaskStackBounds = new Rect(); } Loading @@ -128,7 +134,7 @@ public class AlternateRecentsComponent { } // When we start, preload the metadata associated with the previous tasks RecentsTaskLoader.getInstance().preload(mContext); RecentsTaskLoader.getInstance().preload(mContext, RecentsTaskLoader.ALL_TASKS); } public void onBootCompleted() { Loading Loading @@ -176,7 +182,9 @@ public class AlternateRecentsComponent { } public void onPreloadRecents() { // Do nothing // When we start, preload the metadata associated with the previous tasks RecentsTaskLoader.getInstance().preload(mContext, Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount); } public void onCancelPreloadingRecents() { Loading @@ -186,7 +194,7 @@ public class AlternateRecentsComponent { void showRelativeAffiliatedTask(boolean showNextTask) { RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); TaskStack stack = loader.getTaskStack(mSystemServicesProxy, mContext.getResources(), -1, -1, false, true, null, null); -1, -1, RecentsTaskLoader.ALL_TASKS, false, true, null, null); // Return early if there are no tasks if (stack.getTaskCount() == 0) return; Loading Loading @@ -251,6 +259,8 @@ public class AlternateRecentsComponent { } public void onConfigurationChanged(Configuration newConfig) { // Don't reuse task stack views if the configuration changes mCanReuseTaskStackViews = false; // Reload the header bar layout reloadHeaderBarLayout(); } Loading Loading @@ -364,23 +374,28 @@ public class AlternateRecentsComponent { * Creates the activity options for a unknown state->recents transition. */ ActivityOptions getUnknownTransitionActivityOptions() { mStartAnimationTriggered = false; return ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_from_unknown_enter, R.anim.recents_from_unknown_exit); R.anim.recents_from_unknown_exit, mHandler, this); } /** * Creates the activity options for a home->recents transition. */ ActivityOptions getHomeTransitionActivityOptions(boolean fromSearchHome) { mStartAnimationTriggered = false; if (fromSearchHome) { return ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_from_search_launcher_enter, R.anim.recents_from_search_launcher_exit); R.anim.recents_from_search_launcher_exit, mHandler, this); } return ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_from_launcher_enter, R.anim.recents_from_launcher_exit); R.anim.recents_from_launcher_exit, mHandler, this); } /** Loading Loading @@ -408,9 +423,10 @@ public class AlternateRecentsComponent { c.setBitmap(null); } mStartAnimationTriggered = false; return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mStatusBarView, thumbnail, toTaskRect.left, toTaskRect.top, toTaskRect.width(), toTaskRect.height(), null); toTaskRect.height(), this); } // If both the screenshot and thumbnail fails, then just fall back to the default transition Loading @@ -423,7 +439,7 @@ public class AlternateRecentsComponent { // Get the stack of tasks that we are animating into RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); TaskStack stack = loader.getTaskStack(mSystemServicesProxy, mContext.getResources(), runningTaskId, -1, false, isTopTaskHome, null, null); runningTaskId, -1, RecentsTaskLoader.ALL_TASKS, false, isTopTaskHome, null, null); if (stack.getTaskCount() == 0) { return null; } Loading Loading @@ -529,11 +545,13 @@ public class AlternateRecentsComponent { } intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, mTriggeredFromAltTab); intent.putExtra(EXTRA_FROM_TASK_ID, (topTask != null) ? topTask.id : -1); intent.putExtra(EXTRA_REUSE_TASK_STACK_VIEWS, mCanReuseTaskStackViews); if (opts != null) { mContext.startActivityAsUser(intent, opts.toBundle(), UserHandle.CURRENT); } else { mContext.startActivityAsUser(intent, UserHandle.CURRENT); } mCanReuseTaskStackViews = true; } /** Sets the RecentsComponent callbacks. */ Loading @@ -547,4 +565,42 @@ public class AlternateRecentsComponent { sRecentsComponentCallbacks.onVisibilityChanged(visible); } } /**** OnAnimationStartedListener Implementation ****/ @Override public void onAnimationStarted() { // Notify recents to start the enter animation if (!mStartAnimationTriggered) { // There can be a race condition between the start animation callback and // the start of the new activity (where we register the receiver that listens // to this broadcast, so we add our own receiver and if that gets called, then // we know the activity has not yet started and we can retry sending the broadcast. BroadcastReceiver fallbackReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (getResultCode() == Activity.RESULT_OK) { mStartAnimationTriggered = true; return; } // Schedule for the broadcast to be sent again after some time mHandler.postDelayed(new Runnable() { @Override public void run() { onAnimationStarted(); } }, 25); } }; // Send the broadcast to notify Recents that the animation has started Intent intent = new Intent(ACTION_START_ENTER_ANIMATION); intent.setPackage(mContext.getPackageName()); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT | Intent.FLAG_RECEIVER_FOREGROUND); mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null, fallbackReceiver, null, Activity.RESULT_CANCELED, null, null); } } }
packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +20 −20 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; import android.os.Looper; Loading Loading @@ -142,6 +143,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView } else if (action.equals(AlternateRecentsComponent.ACTION_TOGGLE_RECENTS_ACTIVITY)) { // If we are toggling Recents, then first unfilter any filtered stacks first dismissRecentsToFocusedTaskOrHome(true); } else if (action.equals(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION)) { // Trigger the enter animation onEnterAnimationTriggered(); // Notify the fallback receiver that we have successfully got the broadcast // See AlternateRecentsComponent.onAnimationStarted() setResultCode(Activity.RESULT_OK); } } }; Loading @@ -157,7 +164,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // When the screen turns off, dismiss Recents to Home dismissRecentsToHome(false); // Start preloading some tasks in the background RecentsTaskLoader.getInstance().preload(RecentsActivity.this); RecentsTaskLoader.getInstance().preload(RecentsActivity.this, Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount); } else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) { // When the search activity changes, update the Search widget refreshSearchWidget(); Loading Loading @@ -188,6 +196,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView AlternateRecentsComponent.EXTRA_FROM_TASK_ID, -1); mConfig.launchedWithAltTab = launchIntent.getBooleanExtra( AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false); mConfig.launchedReuseTaskStackViews = launchIntent.getBooleanExtra( AlternateRecentsComponent.EXTRA_REUSE_TASK_STACK_VIEWS, false); // Load all the tasks RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); Loading Loading @@ -397,8 +407,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // Update if we are getting a configuration change if (savedInstanceState != null) { // Update RecentsConfiguration mConfig = RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); mConfig.updateOnConfigurationChange(); onConfigurationChange(); // Trigger the enter animation onEnterAnimationTriggered(); } // Start listening for widget package changes if there is one bound, post it since we don't Loading Loading @@ -428,19 +442,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView } } /** Called when the configuration changes. */ void onConfigurationChange() { // Update RecentsConfiguration mConfig = RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy()); // Try and start the enter animation (or restart it on configuration changed) ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null); mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t)); // Animate the SystemUI scrim views mScrimViews.startEnterRecentsAnimation(); } /** Handles changes to the activity visibility. */ void onRecentsActivityVisibilityChanged(boolean visible) { if (!visible) { Loading Loading @@ -474,6 +475,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView IntentFilter filter = new IntentFilter(); filter.addAction(AlternateRecentsComponent.ACTION_HIDE_RECENTS_ACTIVITY); filter.addAction(AlternateRecentsComponent.ACTION_TOGGLE_RECENTS_ACTIVITY); filter.addAction(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION); registerReceiver(mServiceBroadcastReceiver, filter); // Register any broadcast receivers for the task loader Loading @@ -492,8 +494,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView protected void onStop() { super.onStop(); // Remove all the views mRecentsView.removeAllTaskStacks(); // Notify the views that we are no longer visible mRecentsView.onRecentsHidden(); // Unregister the RecentsService receiver unregisterReceiver(mServiceBroadcastReceiver); Loading @@ -515,8 +517,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView } } @Override public void onEnterAnimationComplete() { public void onEnterAnimationTriggered() { // Try and start the enter animation (or restart it on configuration changed) ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null); mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t)); Loading Loading @@ -584,7 +585,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView /** Called when debug mode is triggered */ public void onDebugModeTriggered() { if (mConfig.developerOptionsEnabled) { SharedPreferences settings = getSharedPreferences(getPackageName(), 0); if (settings.getBoolean(Constants.Values.App.Key_DebugModeEnabled, false)) { Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java +2 −1 Original line number Diff line number Diff line Loading @@ -115,8 +115,8 @@ public class RecentsConfiguration { public boolean launchedWithAltTab; public boolean launchedWithNoRecentTasks; public boolean launchedFromAppWithThumbnail; public boolean launchedFromAppWithScreenshot; public boolean launchedFromHome; public boolean launchedReuseTaskStackViews; public int launchedToTaskId; /** Misc **/ Loading Loading @@ -308,6 +308,7 @@ public class RecentsConfiguration { launchedWithNoRecentTasks = false; launchedFromAppWithThumbnail = false; launchedFromHome = false; launchedReuseTaskStackViews = false; launchedToTaskId = -1; } Loading
packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java +5 −0 Original line number Diff line number Diff line Loading @@ -82,4 +82,9 @@ public class DozeTrigger { public boolean hasTriggered() { return mHasTriggered; } /** Resets the doze trigger state. */ public void resetTrigger() { mHasTriggered = false; } }
packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +11 −8 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ public class RecentsTaskLoader { private static final String TAG = "RecentsTaskLoader"; static RecentsTaskLoader sInstance; public static final int ALL_TASKS = -1; SystemServicesProxy mSystemServicesProxy; DrawableLruCache mApplicationIconCache; Loading Loading @@ -326,10 +327,9 @@ public class RecentsTaskLoader { /** Gets the list of recent tasks, ordered from back to front. */ private static List<ActivityManager.RecentTaskInfo> getRecentTasks(SystemServicesProxy ssp, boolean isTopTaskHome) { RecentsConfiguration config = RecentsConfiguration.getInstance(); int numTasksToLoad, boolean isTopTaskHome) { List<ActivityManager.RecentTaskInfo> tasks = ssp.getRecentTasks(config.maxNumTasksToLoad, UserHandle.CURRENT.getIdentifier(), ssp.getRecentTasks(numTasksToLoad, UserHandle.CURRENT.getIdentifier(), isTopTaskHome); Collections.reverse(tasks); return tasks; Loading Loading @@ -416,7 +416,8 @@ public class RecentsTaskLoader { ArrayList<Task.TaskKey> taskKeys = new ArrayList<Task.TaskKey>(); ArrayList<Task> tasksToLoad = new ArrayList<Task>(); TaskStack stack = getTaskStack(mSystemServicesProxy, context.getResources(), -1, preloadCount, true, isTopTaskHome, taskKeys, tasksToLoad); -1, preloadCount, RecentsTaskLoader.ALL_TASKS, true, isTopTaskHome, taskKeys, tasksToLoad); SpaceNode root = new SpaceNode(); root.setStack(stack); Loading @@ -428,10 +429,10 @@ public class RecentsTaskLoader { } /** Preloads the set of recent tasks (not including thumbnails). */ public void preload(Context context) { public void preload(Context context, int numTasksToPreload) { ArrayList<Task> tasksToLoad = new ArrayList<Task>(); getTaskStack(mSystemServicesProxy, context.getResources(), -1, -1, true, true, null, tasksToLoad); -1, -1, numTasksToPreload, true, true, null, tasksToLoad); // Start the task loader and add all the tasks we need to load mLoadQueue.addTasks(tasksToLoad); Loading @@ -440,11 +441,13 @@ public class RecentsTaskLoader { /** Creates a lightweight stack of the current recent tasks, without thumbnails and icons. */ public synchronized TaskStack getTaskStack(SystemServicesProxy ssp, Resources res, int preloadTaskId, int preloadTaskCount, int preloadTaskId, int preloadTaskCount, int loadTaskCount, boolean loadTaskThumbnails, boolean isTopTaskHome, List<Task.TaskKey> taskKeysOut, List<Task> tasksToLoadOut) { RecentsConfiguration config = RecentsConfiguration.getInstance(); List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp, isTopTaskHome); List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp, (loadTaskCount == ALL_TASKS ? config.maxNumTasksToLoad : loadTaskCount), isTopTaskHome); HashMap<Task.ComponentNameKey, ActivityInfoHandle> activityInfoCache = new HashMap<Task.ComponentNameKey, ActivityInfoHandle>(); ArrayList<Task> tasksToAdd = new ArrayList<Task>(); Loading