Merge "DO NOT MERGE. Don't use visibility flags to determine whether to dismiss Recents. (Bug 18802531)" into lmp-mr1-dev
This commit is contained in:
@@ -86,8 +86,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
|||||||
final static int sMinToggleDelay = 350;
|
final static int sMinToggleDelay = 350;
|
||||||
|
|
||||||
final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS";
|
final static String sToggleRecentsAction = "com.android.systemui.recents.SHOW_RECENTS";
|
||||||
final static String sRecentsPackage = "com.android.systemui";
|
public final static String sRecentsPackage = "com.android.systemui";
|
||||||
final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity";
|
public final static String sRecentsActivity = "com.android.systemui.recents.RecentsActivity";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of ITaskStackListener, that allows us to listen for changes to the system
|
* An implementation of ITaskStackListener, that allows us to listen for changes to the system
|
||||||
@@ -111,10 +111,11 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
|||||||
public void run() {
|
public void run() {
|
||||||
RecentsConfiguration config = RecentsConfiguration.getInstance();
|
RecentsConfiguration config = RecentsConfiguration.getInstance();
|
||||||
if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) {
|
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
|
// Load the next task only if we aren't svelte
|
||||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
|
||||||
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
|
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
|
||||||
loader.preloadTasks(plan, true /* isTopTaskHome */);
|
loader.preloadTasks(plan, true /* isTopTaskHome */);
|
||||||
RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
|
RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
|
||||||
@@ -272,8 +273,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
|||||||
}
|
}
|
||||||
void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
|
||||||
if (mBootCompleted) {
|
if (mBootCompleted) {
|
||||||
ActivityManager.RunningTaskInfo topTask = getTopMostTask();
|
ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
|
||||||
if (topTask != null && isRecentsTopMost(topTask, null)) {
|
if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, null)) {
|
||||||
// Notify recents to hide itself
|
// Notify recents to hide itself
|
||||||
Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY);
|
Intent intent = createLocalBroadcastIntent(mContext, ACTION_HIDE_RECENTS_ACTIVITY);
|
||||||
intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab);
|
intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, triggeredFromAltTab);
|
||||||
@@ -336,7 +337,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
|||||||
// Return early if there are no tasks
|
// Return early if there are no tasks
|
||||||
if (stack.getTaskCount() == 0) return;
|
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)
|
// Return early if there is no running task (can't determine affiliated tasks in this case)
|
||||||
if (runningTask == null) return;
|
if (runningTask == null) return;
|
||||||
// Return early if the running task is in the home stack (optimization)
|
// Return early if the running task is in the home stack (optimization)
|
||||||
@@ -480,38 +481,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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 */
|
/** Toggles the recents activity */
|
||||||
void toggleRecentsActivity() {
|
void toggleRecentsActivity() {
|
||||||
// If the user has toggled it too quickly, then just eat up the event here (it's better than
|
// If the user has toggled it too quickly, then just eat up the event here (it's better than
|
||||||
@@ -523,9 +492,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
|||||||
|
|
||||||
// If Recents is the front most activity, then we should just communicate with it directly
|
// If Recents is the front most activity, then we should just communicate with it directly
|
||||||
// to launch the first task or dismiss itself
|
// to launch the first task or dismiss itself
|
||||||
ActivityManager.RunningTaskInfo topTask = getTopMostTask();
|
ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
|
||||||
AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
|
AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
|
||||||
if (topTask != null && isRecentsTopMost(topTask, isTopTaskHome)) {
|
if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
|
||||||
// Notify recents to toggle itself
|
// Notify recents to toggle itself
|
||||||
Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY);
|
Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY);
|
||||||
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||||
@@ -540,9 +509,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
|
|||||||
/** Starts the recents activity if it is not already running */
|
/** Starts the recents activity if it is not already running */
|
||||||
void startRecentsActivity() {
|
void startRecentsActivity() {
|
||||||
// Check if the top task is in the home stack, and start the recents activity
|
// 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);
|
AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
|
||||||
if (topTask == null || !isRecentsTopMost(topTask, isTopTaskHome)) {
|
if (topTask == null || !mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
|
||||||
startRecentsActivity(topTask, isTopTaskHome.get());
|
startRecentsActivity(topTask, isTopTaskHome.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ public class Constants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class TaskStackView {
|
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;
|
public static final int FilterStartDelay = 25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
DebugOverlayView.DebugOverlayViewCallbacks {
|
DebugOverlayView.DebugOverlayViewCallbacks {
|
||||||
|
|
||||||
RecentsConfiguration mConfig;
|
RecentsConfiguration mConfig;
|
||||||
boolean mVisible;
|
|
||||||
long mLastTabKeyEventTime;
|
long mLastTabKeyEventTime;
|
||||||
|
|
||||||
// Top level views
|
// Top level views
|
||||||
@@ -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 */
|
/** Dismisses recents if we are already visible and the intent is to toggle the recents view */
|
||||||
boolean dismissRecentsToFocusedTaskOrHome(boolean checkFilteredStackState) {
|
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 we currently have filtered stacks, then unfilter those first
|
||||||
if (checkFilteredStackState &&
|
if (checkFilteredStackState &&
|
||||||
mRecentsView.unfilterFilteredStacks()) return true;
|
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. */
|
/** Dismisses Recents directly to Home if we currently aren't transitioning. */
|
||||||
boolean dismissRecentsToHome(boolean animated) {
|
boolean dismissRecentsToHome(boolean animated) {
|
||||||
if (mVisible) {
|
SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy();
|
||||||
|
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) {
|
||||||
// Return to Home
|
// Return to Home
|
||||||
dismissRecentsToHomeRaw(animated);
|
dismissRecentsToHomeRaw(animated);
|
||||||
return true;
|
return true;
|
||||||
@@ -429,7 +430,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
mVisible = true;
|
|
||||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||||
SystemServicesProxy ssp = loader.getSystemServicesProxy();
|
SystemServicesProxy ssp = loader.getSystemServicesProxy();
|
||||||
AlternateRecentsComponent.notifyVisibilityChanged(this, ssp, true);
|
AlternateRecentsComponent.notifyVisibilityChanged(this, ssp, true);
|
||||||
@@ -457,7 +457,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
mVisible = false;
|
|
||||||
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
|
||||||
SystemServicesProxy ssp = loader.getSystemServicesProxy();
|
SystemServicesProxy ssp = loader.getSystemServicesProxy();
|
||||||
AlternateRecentsComponent.notifyVisibilityChanged(this, ssp, false);
|
AlternateRecentsComponent.notifyVisibilityChanged(this, ssp, false);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import android.view.SurfaceControl;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.recents.AlternateRecentsComponent;
|
||||||
import com.android.systemui.recents.Constants;
|
import com.android.systemui.recents.Constants;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -66,6 +67,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
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
|
* Acts as a shim around the real system services that we need to access data from, and provides
|
||||||
@@ -217,6 +219,37 @@ public class SystemServicesProxy {
|
|||||||
return mAm.getRunningTasks(numTasks);
|
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(AlternateRecentsComponent.sRecentsPackage) &&
|
||||||
|
topActivity.getClassName().equals(AlternateRecentsComponent.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 */
|
/** Returns whether the specified task is in the home stack */
|
||||||
public boolean isInHomeStack(int taskId) {
|
public boolean isInHomeStack(int taskId) {
|
||||||
if (mAm == null) return false;
|
if (mAm == null) return false;
|
||||||
|
|||||||
@@ -273,20 +273,21 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_UP: {
|
case MotionEvent.ACTION_UP: {
|
||||||
final VelocityTracker velocityTracker = mVelocityTracker;
|
mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
|
||||||
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
|
int velocity = (int) mVelocityTracker.getYVelocity(mActivePointerId);
|
||||||
int velocity = (int) velocityTracker.getYVelocity(mActivePointerId);
|
|
||||||
if (mIsScrolling && (Math.abs(velocity) > mMinimumVelocity)) {
|
if (mIsScrolling && (Math.abs(velocity) > mMinimumVelocity)) {
|
||||||
int overscrollRange = (int) (Math.min(1f,
|
float overscrollRangePct = Math.abs((float) velocity / mMaximumVelocity);
|
||||||
Math.abs((float) velocity / mMaximumVelocity)) *
|
int overscrollRange = (int) (Math.min(1f, overscrollRangePct) *
|
||||||
Constants.Values.TaskStackView.TaskStackOverscrollRange);
|
(Constants.Values.TaskStackView.TaskStackMaxOverscrollRange -
|
||||||
// Fling scroll
|
Constants.Values.TaskStackView.TaskStackMinOverscrollRange));
|
||||||
mScroller.mScroller.fling(0, mScroller.progressToScrollRange(mScroller.getStackScroll()),
|
mScroller.mScroller.fling(0,
|
||||||
|
mScroller.progressToScrollRange(mScroller.getStackScroll()),
|
||||||
0, velocity,
|
0, velocity,
|
||||||
0, 0,
|
0, 0,
|
||||||
mScroller.progressToScrollRange(mSv.mLayoutAlgorithm.mMinScrollP),
|
mScroller.progressToScrollRange(mSv.mLayoutAlgorithm.mMinScrollP),
|
||||||
mScroller.progressToScrollRange(mSv.mLayoutAlgorithm.mMaxScrollP),
|
mScroller.progressToScrollRange(mSv.mLayoutAlgorithm.mMaxScrollP),
|
||||||
0, overscrollRange);
|
0, Constants.Values.TaskStackView.TaskStackMinOverscrollRange +
|
||||||
|
overscrollRange);
|
||||||
// Invalidate to kick off computeScroll
|
// Invalidate to kick off computeScroll
|
||||||
mSv.invalidate();
|
mSv.invalidate();
|
||||||
} else if (mScroller.isScrollOutOfBounds()) {
|
} else if (mScroller.isScrollOutOfBounds()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user