Don’t relaunch activity in fullscreen stack when entering split screen mode

When entering split-screen mode by long pressing the recents button, the
top task in the fullscreen stack is moved to the docked stack and the new
top task is the fullscreen stack is considered visible for a short amount
of time until sys-ui launches the recents activity. This causes the new
top activity in the fullscreen stack to be relaunched due to configuration
change.
To fix this sys-ui now sends an hint to activity manager to move the home
stack forward so that it can be on-top of the fullscreen stack and makes
it invisible before recent is launched and animated in.

Bug: 28470261
Change-Id: Icfd85e932fe913dfb498752b5878cc7c690fd559
This commit is contained in:
Wale Ogunwale
2016-05-01 16:02:16 -07:00
parent d971a9d5f2
commit a4d92a0152
5 changed files with 20 additions and 10 deletions

View File

@@ -794,7 +794,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
if (hasBounds) {
bounds = Rect.CREATOR.createFromParcel(data);
}
boolean res = moveTaskToDockedStack(taskId, createMode, toTop, animate, bounds);
final boolean moveHomeStackFront = data.readInt() != 0;
final boolean res = moveTaskToDockedStack(
taskId, createMode, toTop, animate, bounds, moveHomeStackFront);
reply.writeNoException();
reply.writeInt(res ? 1 : 0);
return true;
@@ -3865,7 +3867,7 @@ class ActivityManagerProxy implements IActivityManager
}
@Override
public boolean moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate,
Rect initialBounds) throws RemoteException
Rect initialBounds, boolean moveHomeStackFront) throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
@@ -3880,6 +3882,7 @@ class ActivityManagerProxy implements IActivityManager
} else {
data.writeInt(0);
}
data.writeInt(moveHomeStackFront ? 1 : 0);
mRemote.transact(MOVE_TASK_TO_DOCKED_STACK_TRANSACTION, data, reply, 0);
reply.readException();
boolean res = reply.readInt() > 0;

View File

@@ -147,7 +147,7 @@ public interface IActivityManager extends IInterface {
public void moveTaskBackwards(int task) throws RemoteException;
public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException;
public boolean moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate,
Rect initialBounds) throws RemoteException;
Rect initialBounds, boolean moveHomeStackFront) throws RemoteException;
public boolean moveTopActivityToPinnedStack(int stackId, Rect bounds) throws RemoteException;
/**

View File

@@ -414,8 +414,8 @@ public class SystemServicesProxy {
}
try {
return mIam.moveTaskToDockedStack(
taskId, createMode, true /* onTop */, false /* animate */, initialBounds);
return mIam.moveTaskToDockedStack(taskId, createMode, true /* onTop */,
false /* animate */, initialBounds, true /* moveHomeStackFront */ );
} catch (RemoteException e) {
e.printStackTrace();
}

View File

@@ -9700,7 +9700,7 @@ public final class ActivityManagerService extends ActivityManagerNative
*/
@Override
public boolean moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate,
Rect initialBounds) {
Rect initialBounds, boolean moveHomeStackFront) {
enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "moveTaskToDockedStack()");
synchronized (this) {
long ident = Binder.clearCallingIdentity();
@@ -9708,9 +9708,16 @@ public final class ActivityManagerService extends ActivityManagerNative
if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToDockedStack: moving task=" + taskId
+ " to createMode=" + createMode + " toTop=" + toTop);
mWindowManager.setDockedStackCreateState(createMode, initialBounds);
return mStackSupervisor.moveTaskToStackLocked(
taskId, DOCKED_STACK_ID, toTop, !FORCE_FOCUS,
"moveTaskToDockedStack", animate);
final boolean moved = mStackSupervisor.moveTaskToStackLocked(
taskId, DOCKED_STACK_ID, toTop, !FORCE_FOCUS, "moveTaskToDockedStack",
animate, DEFER_RESUME);
if (moved) {
if (moveHomeStackFront) {
mStackSupervisor.moveHomeStackToFront("moveTaskToDockedStack");
}
mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
}
return moved;
} finally {
Binder.restoreCallingIdentity(ident);
}

View File

@@ -204,7 +204,7 @@ class TaskPositioner implements DimLayer.DimLayerUser {
: DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
mService.mActivityManager.moveTaskToDockedStack(
mTask.mTaskId, createMode, true /*toTop*/, true /* animate */,
null /* initialBounds */);
null /* initialBounds */, false /* moveHomeStackFront */);
}
} catch(RemoteException e) {}