Adding support for blacklisting apps from Recents transition.

am: fc73eec235

Change-Id: Ie2b253c2dd9bd6660b6a18e21b7e4afd43f99b6e
This commit is contained in:
Winson
2016-08-03 19:33:58 +00:00
committed by android-build-merger
5 changed files with 41 additions and 8 deletions

View File

@@ -790,6 +790,10 @@
<!-- Recents: MultiStack add stack split custom radio button. [CHAR LIMIT=NONE] -->
<string name="recents_multistack_add_stack_dialog_split_custom">Split Custom</string>
<!-- Fully qualified activity class names to be blacklisted in Recents, add package names into overlay as needed -->
<string-array name="recents_blacklist_array">
</string-array>
<!-- Expanded Status Bar Header: Battery Charged [CHAR LIMIT=40] -->
<string name="expanded_header_battery_charged">Charged</string>

View File

@@ -29,6 +29,7 @@ public class RecentsActivityLaunchState {
public boolean launchedWithAltTab;
public boolean launchedFromApp;
public boolean launchedFromBlacklistedApp;
public boolean launchedFromHome;
public boolean launchedViaDragGesture;
public boolean launchedViaDockGesture;
@@ -39,6 +40,7 @@ public class RecentsActivityLaunchState {
public void reset() {
launchedFromHome = false;
launchedFromApp = false;
launchedFromBlacklistedApp = false;
launchedToTaskId = -1;
launchedWithAltTab = false;
launchedViaDragGesture = false;
@@ -53,8 +55,14 @@ public class RecentsActivityLaunchState {
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
if (launchedFromApp) {
if (!launchState.launchedWithAltTab && debugFlags.isFastToggleRecentsEnabled()) {
// If fast toggling, focus the front most task so that the next tap will focus the
// N-1 task
// If fast toggling, focus the front most task so that the next tap will launch the
// task
return numTasks - 1;
}
if (launchState.launchedFromBlacklistedApp) {
// If we are launching from a blacklisted app, focus the front most task so that the
// next tap will launch the task
return numTasks - 1;
}
@@ -67,7 +75,7 @@ public class RecentsActivityLaunchState {
return -1;
}
// If coming from home, focus the first task
// If coming from home, focus the front most task
return numTasks - 1;
}
}

View File

@@ -807,15 +807,19 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
boolean isHomeStackVisible, boolean animate, int growTarget) {
RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
SystemServicesProxy ssp = Recents.getSystemServices();
boolean isBlacklisted = (runningTask != null)
? ssp.isBlackListedActivity(runningTask.baseActivity.getClassName())
: false;
int runningTaskId = !mLaunchedWhileDocking && (runningTask != null)
int runningTaskId = !mLaunchedWhileDocking && !isBlacklisted && (runningTask != null)
? runningTask.id
: -1;
// In the case where alt-tab is triggered, we never get a preloadRecents() call, so we
// should always preload the tasks now. If we are dragging in recents, reload them as
// the stacks might have changed.
if (mLaunchedWhileDocking || mTriggeredFromAltTab ||sInstanceLoadPlan == null) {
if (mLaunchedWhileDocking || mTriggeredFromAltTab || sInstanceLoadPlan == null) {
// Create a new load plan if preloadRecents() was never triggered
sInstanceLoadPlan = loader.createLoadPlan(mContext);
}
@@ -825,11 +829,13 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
TaskStack stack = sInstanceLoadPlan.getTaskStack();
boolean hasRecentTasks = stack.getTaskCount() > 0;
boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks;
boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible &&
hasRecentTasks;
// Update the launch state that we need in updateHeaderBarLayout()
launchState.launchedFromHome = !useThumbnailTransition && !mLaunchedWhileDocking;
launchState.launchedFromApp = useThumbnailTransition || mLaunchedWhileDocking;
launchState.launchedFromBlacklistedApp = launchState.launchedFromApp && isBlacklisted;
launchState.launchedViaDockGesture = mLaunchedWhileDocking;
launchState.launchedViaDragGesture = mDraggingInRecents;
launchState.launchedToTaskId = runningTaskId;
@@ -857,7 +863,9 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
}
ActivityOptions opts;
if (useThumbnailTransition) {
if (isBlacklisted) {
opts = getUnknownTransitionActivityOptions();
} else if (useThumbnailTransition) {
// Try starting with a thumbnail transition
opts = getThumbnailTransitionActivityOptions(runningTask, mDummyStackView,
windowOverrideRect);

View File

@@ -243,6 +243,9 @@ public class SystemServicesProxy {
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
Collections.addAll(sRecentsBlacklist,
res.getStringArray(R.array.recents_tv_blacklist_array));
} else {
Collections.addAll(sRecentsBlacklist,
res.getStringArray(R.array.recents_blacklist_array));
}
}
@@ -260,6 +263,13 @@ public class SystemServicesProxy {
return sSystemServicesProxy;
}
/**
* @return whether the provided {@param className} is blacklisted
*/
public boolean isBlackListedActivity(String className) {
return sRecentsBlacklist.contains(className);
}
/**
* Returns a list of the recents tasks.
*

View File

@@ -556,7 +556,9 @@ public class TaskStackLayoutAlgorithm {
Math.max(0, mUnfocusedRange.getAbsoluteX(maxBottomNormX)));
boolean scrollToFront = launchState.launchedFromHome ||
launchState.launchedViaDockGesture;
if (launchState.launchedWithAltTab) {
if (launchState.launchedFromBlacklistedApp) {
mInitialScrollP = mMaxScrollP;
} else if (launchState.launchedWithAltTab) {
mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
} else if (scrollToFront) {
mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
@@ -579,6 +581,7 @@ public class TaskStackLayoutAlgorithm {
mTaskIndexOverrideMap.clear();
boolean scrollToFront = launchState.launchedFromHome ||
launchState.launchedFromBlacklistedApp ||
launchState.launchedViaDockGesture;
if (getInitialFocusState() == STATE_UNFOCUSED && mNumStackTasks > 1) {
if (ignoreScrollToFront || (!launchState.launchedWithAltTab && !scrollToFront)) {