summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-01-16 20:09:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-01-16 20:09:40 +0000
commit166cf980afafb83add7479cfeb3a8e0283cfee81 (patch)
tree300ae93b2811c4a2a96f6402b3a132caf5141404 /packages
parentfadcbc705f8669ce5276089da466bd08f8bb11e1 (diff)
parent5675f018681faefeb50c9003bc9e02cd9ce5659d (diff)
downloadframeworks_base-166cf980afafb83add7479cfeb3a8e0283cfee81.zip
frameworks_base-166cf980afafb83add7479cfeb3a8e0283cfee81.tar.gz
frameworks_base-166cf980afafb83add7479cfeb3a8e0283cfee81.tar.bz2
Merge "DO NOT MERGE. Don't use visibility flags to determine whether to dismiss Recents. (Bug 18802531)" into lmp-mr1-dev
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java55
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/Constants.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java33
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java19
5 files changed, 61 insertions, 58 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index 4ce2c2b..910a57e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -86,8 +86,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
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 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
@@ -111,10 +111,11 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
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();
@@ -272,8 +273,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
}
void hideRecents(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);
@@ -336,7 +337,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
// 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)
@@ -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 */
void toggleRecentsActivity() {
// 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
// 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);
@@ -540,9 +509,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
/** 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());
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Constants.java b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
index 4c76af7..0a1718d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Constants.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
@@ -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;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 0f535db..cb1baeb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -65,7 +65,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
DebugOverlayView.DebugOverlayViewCallbacks {
RecentsConfiguration mConfig;
- boolean mVisible;
long mLastTabKeyEventTime;
// 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 */
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;
@@ -429,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();
AlternateRecentsComponent.notifyVisibilityChanged(this, ssp, true);
@@ -457,7 +457,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
@Override
protected void onStop() {
super.onStop();
- mVisible = false;
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
SystemServicesProxy ssp = loader.getSystemServicesProxy();
AlternateRecentsComponent.notifyVisibilityChanged(this, ssp, false);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index 542f21c..90b099c 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -59,6 +59,7 @@ import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
import com.android.systemui.R;
+import com.android.systemui.recents.AlternateRecentsComponent;
import com.android.systemui.recents.Constants;
import java.io.IOException;
@@ -66,6 +67,7 @@ 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
@@ -217,6 +219,37 @@ public class SystemServicesProxy {
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 */
public boolean isInHomeStack(int taskId) {
if (mAm == null) return false;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index c59f82c..59e38f4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -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()) {