summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-01-20 11:44:05 -0800
committerWinson Chung <winsonc@google.com>2015-01-20 11:44:05 -0800
commit2cf8b221fca18dbee3703388ae7970491c86ec7f (patch)
tree1e7833868f454dd2beb6b8d471d377a246a8f786 /packages/SystemUI
parent8d2e8e2bf7341aa8d4b5c0ea5ce038e745275324 (diff)
downloadframeworks_base-2cf8b221fca18dbee3703388ae7970491c86ec7f.zip
frameworks_base-2cf8b221fca18dbee3703388ae7970491c86ec7f.tar.gz
frameworks_base-2cf8b221fca18dbee3703388ae7970491c86ec7f.tar.bz2
Cherry picking recents fixes to screen pinning and visibility.
Screen pinning fix - 98e8f7ac5e75a47abaa0061aab343b9f06770258 Visibility fix - 5675f018681faefeb50c9003bc9e02cd9ce5659d Bug 18986736, 18802531 Change-Id: Ia37dbcd4f82e80f47f9c0686ed2ad4f534f946a7
Diffstat (limited to 'packages/SystemUI')
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/Constants.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/Recents.java62
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java31
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java35
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java19
7 files changed, 81 insertions, 73 deletions
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/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
index 7d7766b..3c75aac 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
@@ -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();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 95f2b7d..1833e09 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
@@ -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);
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..237d4f0 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -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;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
index 255d642..cac9525 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
@@ -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);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index ee79242..427ffe5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -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
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..5306d28 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()) {