Merge "Allow controlling SystemUI flags during RecentsAnimation" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-03-14 16:00:49 +00:00
committed by Android (Google) Code Review
6 changed files with 64 additions and 2 deletions

View File

@@ -51,4 +51,12 @@ interface IRecentsAnimationController {
* and then enable it mid-animation to start receiving touch events.
*/
void setInputConsumerEnabled(boolean enabled);
/**
* Informs the system whether the animation targets passed into
* IRecentsAnimationRunner.onAnimationStart are currently behind the system bars. If they are,
* they can control the SystemUI flags, otherwise the SystemUI flags from home activity will be
* taken.
*/
void setAnimationTargetsBehindSystemBars(boolean behindSystemBars);
}

View File

@@ -51,6 +51,14 @@ public class RecentsAnimationControllerCompat {
}
}
public void setAnimationTargetsBehindSystemBars(boolean behindSystemBars) {
try {
mAnimationController.setAnimationTargetsBehindSystemBars(behindSystemBars);
} catch (RemoteException e) {
Log.e(TAG, "Failed to set whether animation targets are behind system bars", e);
}
}
public void finish(boolean toHome) {
try {
mAnimationController.finish(toHome);

View File

@@ -140,6 +140,22 @@ public class RecentsAnimationController {
}
}
@Override
public void setAnimationTargetsBehindSystemBars(boolean behindSystemBars)
throws RemoteException {
long token = Binder.clearCallingIdentity();
try {
synchronized (mService.getWindowManagerLock()) {
for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
mPendingAnimations.get(i).mTask.setCanAffectSystemUiFlags(behindSystemBars);
}
mService.mWindowPlacerLocked.requestTraversal();
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
@Override
public void setInputConsumerEnabled(boolean enabled) {
if (DEBUG) Log.d(TAG, "setInputConsumerEnabled(" + enabled + "): mCanceled="
@@ -289,6 +305,7 @@ public class RecentsAnimationController {
+ mPendingAnimations.size());
for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
final TaskAnimationAdapter adapter = mPendingAnimations.get(i);
adapter.mTask.setCanAffectSystemUiFlags(true);
adapter.mCapturedFinishCallback.onAnimationFinished(adapter);
}
mPendingAnimations.clear();

View File

@@ -96,6 +96,9 @@ class Task extends WindowContainer<AppWindowToken> {
private Dimmer mDimmer = new Dimmer(this);
private final Rect mTmpDimBoundsRect = new Rect();
/** @see #setCanAffectSystemUiFlags */
private boolean mCanAffectSystemUiFlags = true;
Task(int taskId, TaskStack stack, int userId, WindowManagerService service, int resizeMode,
boolean supportsPictureInPicture, TaskDescription taskDescription,
TaskWindowContainerController controller) {
@@ -627,6 +630,21 @@ class Task extends WindowContainer<AppWindowToken> {
callback.accept(this);
}
/**
* @param canAffectSystemUiFlags If false, all windows in this task can not affect SystemUI
* flags. See {@link WindowState#canAffectSystemUiFlags()}.
*/
void setCanAffectSystemUiFlags(boolean canAffectSystemUiFlags) {
mCanAffectSystemUiFlags = canAffectSystemUiFlags;
}
/**
* @see #setCanAffectSystemUiFlags
*/
boolean canAffectSystemUiFlags() {
return mCanAffectSystemUiFlags;
}
@Override
public String toString() {
return "{taskId=" + mTaskId + " appTokens=" + mChildren + " mdr=" + mDeferRemoval + "}";

View File

@@ -1573,7 +1573,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
final boolean exiting = mAnimatingExit || mDestroying;
return shown && !exiting;
} else {
return !mAppToken.isHidden();
final Task task = getTask();
final boolean canFromTask = task != null && task.canAffectSystemUiFlags();
return canFromTask && !mAppToken.isHidden();
}
}

View File

@@ -38,7 +38,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static org.junit.Assert.assertEquals;
@@ -288,6 +287,16 @@ public class WindowStateTests extends WindowTestsBase {
app.mToken.setHidden(false);
app.mAttrs.alpha = 0.0f;
assertFalse(app.canAffectSystemUiFlags());
}
@Test
public void testCanAffectSystemUiFlags_disallow() throws Exception {
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
app.mToken.setHidden(false);
assertTrue(app.canAffectSystemUiFlags());
app.getTask().setCanAffectSystemUiFlags(false);
assertFalse(app.canAffectSystemUiFlags());
}
@Test