Cherry picking recents fixes to screen pinning and visibility.
Screen pinning fix -98e8f7ac5eVisibility fix -5675f01868Bug 18986736, 18802531 Change-Id: Ia37dbcd4f82e80f47f9c0686ed2ad4f534f946a7
This commit is contained in:
@@ -65,7 +65,8 @@ public class Constants {
|
||||
}
|
||||
|
||||
public static class TaskStackView {
|
||||
public static final int TaskStackOverscrollRange = 150;
|
||||
public static final int TaskStackMinOverscrollRange = 32;
|
||||
public static final int TaskStackMaxOverscrollRange = 128;
|
||||
public static final int FilterStartDelay = 25;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ public class Recents extends SystemUI
|
||||
|
||||
final static int sMinToggleDelay = 350;
|
||||
|
||||
final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS";
|
||||
final static String sRecentsPackage = "com.android.systemui";
|
||||
final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity";
|
||||
public final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS";
|
||||
public final static String sRecentsPackage = "com.android.systemui";
|
||||
public final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity";
|
||||
|
||||
/**
|
||||
* An implementation of ITaskStackListener, that allows us to listen for changes to the system
|
||||
@@ -114,10 +114,11 @@ public class Recents extends SystemUI
|
||||
public void run() {
|
||||
RecentsConfiguration config = RecentsConfiguration.getInstance();
|
||||
if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) {
|
||||
ActivityManager.RunningTaskInfo runningTaskInfo = getTopMostTask();
|
||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||
SystemServicesProxy ssp = loader.getSystemServicesProxy();
|
||||
ActivityManager.RunningTaskInfo runningTaskInfo = ssp.getTopMostTask();
|
||||
|
||||
// Load the next task only if we aren't svelte
|
||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
|
||||
loader.preloadTasks(plan, true /* isTopTaskHome */);
|
||||
RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
|
||||
@@ -300,8 +301,8 @@ public class Recents extends SystemUI
|
||||
|
||||
void hideRecentsInternal(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||
if (mBootCompleted) {
|
||||
ActivityManager.RunningTaskInfo topTask = getTopMostTask();
|
||||
if (topTask != null && isRecentsTopMost(topTask, null)) {
|
||||
ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
|
||||
if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, null)) {
|
||||
// Notify recents to hide itself
|
||||
Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY);
|
||||
intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab);
|
||||
@@ -369,7 +370,7 @@ public class Recents extends SystemUI
|
||||
// Return early if there are no tasks
|
||||
if (stack.getTaskCount() == 0) return;
|
||||
|
||||
ActivityManager.RunningTaskInfo runningTask = getTopMostTask();
|
||||
ActivityManager.RunningTaskInfo runningTask = mSystemServicesProxy.getTopMostTask();
|
||||
// Return early if there is no running task (can't determine affiliated tasks in this case)
|
||||
if (runningTask == null) return;
|
||||
// Return early if the running task is in the home stack (optimization)
|
||||
@@ -515,38 +516,6 @@ public class Recents extends SystemUI
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets the top task. */
|
||||
ActivityManager.RunningTaskInfo getTopMostTask() {
|
||||
SystemServicesProxy ssp = mSystemServicesProxy;
|
||||
List<ActivityManager.RunningTaskInfo> tasks = ssp.getRunningTasks(1);
|
||||
if (!tasks.isEmpty()) {
|
||||
return tasks.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns whether the recents is currently running */
|
||||
boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask, AtomicBoolean isHomeTopMost) {
|
||||
SystemServicesProxy ssp = mSystemServicesProxy;
|
||||
if (topTask != null) {
|
||||
ComponentName topActivity = topTask.topActivity;
|
||||
|
||||
// Check if the front most activity is recents
|
||||
if (topActivity.getPackageName().equals(sRecentsPackage) &&
|
||||
topActivity.getClassName().equals(sRecentsActivity)) {
|
||||
if (isHomeTopMost != null) {
|
||||
isHomeTopMost.set(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isHomeTopMost != null) {
|
||||
isHomeTopMost.set(ssp.isInHomeStack(topTask.id));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Toggles the recents activity */
|
||||
void toggleRecentsActivity() {
|
||||
// If the user has toggled it too quickly, then just eat up the event here (it's better than
|
||||
@@ -558,9 +527,9 @@ public class Recents extends SystemUI
|
||||
|
||||
// If Recents is the front most activity, then we should just communicate with it directly
|
||||
// to launch the first task or dismiss itself
|
||||
ActivityManager.RunningTaskInfo topTask = getTopMostTask();
|
||||
ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
|
||||
AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
|
||||
if (topTask != null && isRecentsTopMost(topTask, isTopTaskHome)) {
|
||||
if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
|
||||
// Notify recents to toggle itself
|
||||
Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY);
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||
@@ -575,9 +544,9 @@ public class Recents extends SystemUI
|
||||
/** Starts the recents activity if it is not already running */
|
||||
void startRecentsActivity() {
|
||||
// Check if the top task is in the home stack, and start the recents activity
|
||||
ActivityManager.RunningTaskInfo topTask = getTopMostTask();
|
||||
ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
|
||||
AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
|
||||
if (topTask == null || !isRecentsTopMost(topTask, isTopTaskHome)) {
|
||||
if (topTask == null || !mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
|
||||
startRecentsActivity(topTask, isTopTaskHome.get());
|
||||
}
|
||||
}
|
||||
@@ -677,12 +646,13 @@ public class Recents extends SystemUI
|
||||
|
||||
/** Starts the recents activity */
|
||||
void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, boolean isTopTaskHome) {
|
||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||
RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy);
|
||||
|
||||
if (sInstanceLoadPlan == null) {
|
||||
// Create a new load plan if onPreloadRecents() was never triggered
|
||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||
sInstanceLoadPlan = loader.createLoadPlan(mContext);
|
||||
}
|
||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||
loader.preloadTasks(sInstanceLoadPlan, isTopTaskHome);
|
||||
TaskStack stack = sInstanceLoadPlan.getTaskStack();
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
DebugOverlayView.DebugOverlayViewCallbacks {
|
||||
|
||||
RecentsConfiguration mConfig;
|
||||
boolean mVisible;
|
||||
long mLastTabKeyEventTime;
|
||||
|
||||
// Top level views
|
||||
@@ -181,7 +180,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
});
|
||||
|
||||
/** Updates the set of recent tasks */
|
||||
void updateRecentsTasks(Intent launchIntent) {
|
||||
void updateRecentsTasks() {
|
||||
// If AlternateRecentsComponent has preloaded a load plan, then use that to prevent
|
||||
// reconstructing the task stack
|
||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||
@@ -315,7 +314,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
|
||||
/** Dismisses recents if we are already visible and the intent is to toggle the recents view */
|
||||
boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) {
|
||||
if (mVisible) {
|
||||
SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy();
|
||||
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) {
|
||||
// If we currently have filtered stacks, then unfilter those first
|
||||
if (checkFilteredStackState &&
|
||||
mRecentsView.unfilterFilteredStacks()) return true;
|
||||
@@ -349,7 +349,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
|
||||
/** Dismisses Recents directly to Home if we currently aren't transitioning. */
|
||||
boolean dismissRecentsToHome(boolean animated) {
|
||||
if (mVisible) {
|
||||
SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy();
|
||||
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) {
|
||||
// Return to Home
|
||||
dismissRecentsToHomeRaw(animated);
|
||||
return true;
|
||||
@@ -361,12 +362,11 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// For the non-primary user, ensure that the SystemSericesProxy is initialized
|
||||
// For the non-primary user, ensure that the SystemServicesProxy and configuration is
|
||||
// initialized
|
||||
RecentsTaskLoader.initialize(this);
|
||||
|
||||
// Initialize the loader and the configuration
|
||||
mConfig = RecentsConfiguration.reinitialize(this,
|
||||
RecentsTaskLoader.getInstance().getSystemServicesProxy());
|
||||
SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy();
|
||||
mConfig = RecentsConfiguration.reinitialize(this, ssp);
|
||||
|
||||
// Initialize the widget host (the host id is static and does not change)
|
||||
mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId);
|
||||
@@ -421,9 +421,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
super.onNewIntent(intent);
|
||||
setIntent(intent);
|
||||
|
||||
// Reinitialize the configuration
|
||||
RecentsConfiguration.reinitialize(this, RecentsTaskLoader.getInstance().getSystemServicesProxy());
|
||||
|
||||
// Clear any debug rects
|
||||
if (mDebugOverlay != null) {
|
||||
mDebugOverlay.clear();
|
||||
@@ -433,7 +430,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mVisible = true;
|
||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||
SystemServicesProxy ssp = loader.getSystemServicesProxy();
|
||||
Recents.notifyVisibilityChanged(this, ssp, true);
|
||||
@@ -449,13 +445,18 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
||||
loader.registerReceivers(this, mRecentsView);
|
||||
|
||||
// Update the recent tasks
|
||||
updateRecentsTasks(getIntent());
|
||||
updateRecentsTasks();
|
||||
|
||||
// If this is a new instance from a configuration change, then we have to manually trigger
|
||||
// the enter animation state
|
||||
if (mConfig.launchedHasConfigurationChanged) {
|
||||
onEnterAnimationTriggered();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mVisible = false;
|
||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||
SystemServicesProxy ssp = loader.getSystemServicesProxy();
|
||||
Recents.notifyVisibilityChanged(this, ssp, false);
|
||||
|
||||
@@ -60,12 +60,14 @@ import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.recents.Constants;
|
||||
import com.android.systemui.recents.Recents;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Acts as a shim around the real system services that we need to access data from, and provides
|
||||
@@ -212,11 +214,42 @@ public class SystemServicesProxy {
|
||||
}
|
||||
|
||||
/** Returns a list of the running tasks */
|
||||
public List<ActivityManager.RunningTaskInfo> getRunningTasks(int numTasks) {
|
||||
private List<ActivityManager.RunningTaskInfo> getRunningTasks(int numTasks) {
|
||||
if (mAm == null) return null;
|
||||
return mAm.getRunningTasks(numTasks);
|
||||
}
|
||||
|
||||
/** Returns the top task. */
|
||||
public ActivityManager.RunningTaskInfo getTopMostTask() {
|
||||
List<ActivityManager.RunningTaskInfo> tasks = getRunningTasks(1);
|
||||
if (!tasks.isEmpty()) {
|
||||
return tasks.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns whether the recents is currently running */
|
||||
public boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask,
|
||||
AtomicBoolean isHomeTopMost) {
|
||||
if (topTask != null) {
|
||||
ComponentName topActivity = topTask.topActivity;
|
||||
|
||||
// Check if the front most activity is recents
|
||||
if (topActivity.getPackageName().equals(Recents.sRecentsPackage) &&
|
||||
topActivity.getClassName().equals(Recents.sRecentsActivity)) {
|
||||
if (isHomeTopMost != null) {
|
||||
isHomeTopMost.set(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isHomeTopMost != null) {
|
||||
isHomeTopMost.set(isInHomeStack(topTask.id));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns whether the specified task is in the home stack */
|
||||
public boolean isInHomeStack(int taskId) {
|
||||
if (mAm == null) return false;
|
||||
|
||||
@@ -252,6 +252,8 @@ public class TaskStack {
|
||||
if (group.getTaskCount() == 0) {
|
||||
removeGroup(group);
|
||||
}
|
||||
// Update the lock-to-app state
|
||||
t.lockToThisTask = false;
|
||||
if (mCb != null) {
|
||||
// Notify that a task has been removed
|
||||
mCb.onStackTaskRemoved(this, t, null);
|
||||
|
||||
@@ -542,7 +542,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
|
||||
loader.deleteTaskData(t, false);
|
||||
|
||||
// Remove the old task from activity manager
|
||||
RecentsTaskLoader.getInstance().getSystemServicesProxy().removeTask(t.key.id);
|
||||
loader.getSystemServicesProxy().removeTask(t.key.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -273,20 +273,21 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
|
||||
break;
|
||||
}
|
||||
case MotionEvent.ACTION_UP: {
|
||||
final VelocityTracker velocityTracker = mVelocityTracker;
|
||||
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
|
||||
int velocity = (int) velocityTracker.getYVelocity(mActivePointerId);
|
||||
mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
|
||||
int velocity = (int) mVelocityTracker.getYVelocity(mActivePointerId);
|
||||
if (mIsScrolling && (Math.abs(velocity) > mMinimumVelocity)) {
|
||||
int overscrollRange = (int) (Math.min(1f,
|
||||
Math.abs((float) velocity / mMaximumVelocity)) *
|
||||
Constants.Values.TaskStackView.TaskStackOverscrollRange);
|
||||
// Fling scroll
|
||||
mScroller.mScroller.fling(0, mScroller.progressToScrollRange(mScroller.getStackScroll()),
|
||||
float overscrollRangePct = Math.abs((float) velocity / mMaximumVelocity);
|
||||
int overscrollRange = (int) (Math.min(1f, overscrollRangePct) *
|
||||
(Constants.Values.TaskStackView.TaskStackMaxOverscrollRange -
|
||||
Constants.Values.TaskStackView.TaskStackMinOverscrollRange));
|
||||
mScroller.mScroller.fling(0,
|
||||
mScroller.progressToScrollRange(mScroller.getStackScroll()),
|
||||
0, velocity,
|
||||
0, 0,
|
||||
mScroller.progressToScrollRange(mSv.mLayoutAlgorithm.mMinScrollP),
|
||||
mScroller.progressToScrollRange(mSv.mLayoutAlgorithm.mMaxScrollP),
|
||||
0, overscrollRange);
|
||||
0, Constants.Values.TaskStackView.TaskStackMinOverscrollRange +
|
||||
overscrollRange);
|
||||
// Invalidate to kick off computeScroll
|
||||
mSv.invalidate();
|
||||
} else if (mScroller.isScrollOutOfBounds()) {
|
||||
|
||||
Reference in New Issue
Block a user