Merge "Keep track of two top wallpapers to improve the control over each." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a54b7778f6
@@ -607,9 +607,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
|
|||||||
recordDisplay(wc.getDisplayContent());
|
recordDisplay(wc.getDisplayContent());
|
||||||
if (info.mShowWallpaper) {
|
if (info.mShowWallpaper) {
|
||||||
// Collect the wallpaper token (for isWallpaper(wc)) so it is part of the sync set.
|
// Collect the wallpaper token (for isWallpaper(wc)) so it is part of the sync set.
|
||||||
final WindowState wallpaper =
|
final List<WindowState> wallpapers =
|
||||||
wc.getDisplayContent().mWallpaperController.getTopVisibleWallpaper();
|
wc.getDisplayContent().mWallpaperController.getAllTopWallpapers();
|
||||||
if (wallpaper != null) {
|
for (int i = wallpapers.size() - 1; i >= 0; i--) {
|
||||||
|
WindowState wallpaper = wallpapers.get(i);
|
||||||
collect(wallpaper.mToken);
|
collect(wallpaper.mToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,24 +124,19 @@ class WallpaperController {
|
|||||||
|
|
||||||
final boolean mIsLockscreenLiveWallpaperEnabled;
|
final boolean mIsLockscreenLiveWallpaperEnabled;
|
||||||
|
|
||||||
private final ToBooleanFunction<WindowState> mFindWallpaperTargetFunction = w -> {
|
private final Consumer<WindowState> mFindWallpapers = w -> {
|
||||||
if ((w.mAttrs.type == TYPE_WALLPAPER)) {
|
if (w.mAttrs.type == TYPE_WALLPAPER) {
|
||||||
if (mFindResults.topWallpaper == null || mFindResults.resetTopWallpaper) {
|
WallpaperWindowToken token = w.mToken.asWallpaperToken();
|
||||||
WallpaperWindowToken token = w.mToken.asWallpaperToken();
|
if (token.canShowWhenLocked() && !mFindResults.hasTopShowWhenLockedWallpaper()) {
|
||||||
if (token == null) {
|
mFindResults.setTopShowWhenLockedWallpaper(w);
|
||||||
Slog.w(TAG, "Window " + w + " has wallpaper type but not wallpaper token");
|
} else if (!token.canShowWhenLocked()
|
||||||
return false;
|
&& !mFindResults.hasTopHideWhenLockedWallpaper()) {
|
||||||
}
|
mFindResults.setTopHideWhenLockedWallpaper(w);
|
||||||
if (!token.canShowWhenLocked() && mDisplayContent.isKeyguardLocked()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
mFindResults.setTopWallpaper(w);
|
|
||||||
mFindResults.resetTopWallpaper = false;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
mFindResults.resetTopWallpaper = true;
|
private final ToBooleanFunction<WindowState> mFindWallpaperTargetFunction = w -> {
|
||||||
if (!w.mTransitionController.isShellTransitionsEnabled()) {
|
if (!w.mTransitionController.isShellTransitionsEnabled()) {
|
||||||
if (w.mActivityRecord != null && !w.mActivityRecord.isVisible()
|
if (w.mActivityRecord != null && !w.mActivityRecord.isVisible()
|
||||||
&& !w.mActivityRecord.isAnimating(TRANSITION | PARENTS)) {
|
&& !w.mActivityRecord.isAnimating(TRANSITION | PARENTS)) {
|
||||||
@@ -668,13 +663,26 @@ class WallpaperController {
|
|||||||
mFindResults.setUseTopWallpaperAsTarget(true);
|
mFindResults.setUseTopWallpaperAsTarget(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDisplayContent.forAllWindows(mFindWallpapers, true /* traverseTopToBottom */);
|
||||||
mDisplayContent.forAllWindows(mFindWallpaperTargetFunction, true /* traverseTopToBottom */);
|
mDisplayContent.forAllWindows(mFindWallpaperTargetFunction, true /* traverseTopToBottom */);
|
||||||
|
|
||||||
if (mFindResults.wallpaperTarget == null && mFindResults.useTopWallpaperAsTarget) {
|
if (mFindResults.wallpaperTarget == null && mFindResults.useTopWallpaperAsTarget) {
|
||||||
mFindResults.setWallpaperTarget(mFindResults.topWallpaper);
|
mFindResults.setWallpaperTarget(
|
||||||
|
mFindResults.getTopWallpaper(mDisplayContent.isKeyguardLocked()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<WindowState> getAllTopWallpapers() {
|
||||||
|
ArrayList<WindowState> wallpapers = new ArrayList<>(2);
|
||||||
|
if (mFindResults.hasTopShowWhenLockedWallpaper()) {
|
||||||
|
wallpapers.add(mFindResults.mTopWallpaper.mTopShowWhenLockedWallpaper);
|
||||||
|
}
|
||||||
|
if (mFindResults.hasTopHideWhenLockedWallpaper()) {
|
||||||
|
wallpapers.add(mFindResults.mTopWallpaper.mTopHideWhenLockedWallpaper);
|
||||||
|
}
|
||||||
|
return wallpapers;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isFullscreen(WindowManager.LayoutParams attrs) {
|
private boolean isFullscreen(WindowManager.LayoutParams attrs) {
|
||||||
return attrs.x == 0 && attrs.y == 0
|
return attrs.x == 0 && attrs.y == 0
|
||||||
&& attrs.width == MATCH_PARENT && attrs.height == MATCH_PARENT;
|
&& attrs.width == MATCH_PARENT && attrs.height == MATCH_PARENT;
|
||||||
@@ -760,10 +768,16 @@ class WallpaperController {
|
|||||||
result.setWallpaperTarget(wallpaperTarget);
|
result.setWallpaperTarget(wallpaperTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the visibility of the top wallpaper to {@param visibility} and hide all the others.
|
||||||
|
*/
|
||||||
private void updateWallpaperTokens(boolean visibility, boolean locked) {
|
private void updateWallpaperTokens(boolean visibility, boolean locked) {
|
||||||
|
WindowState topWallpaper = mFindResults.getTopWallpaper(locked);
|
||||||
|
WallpaperWindowToken topWallpaperToken =
|
||||||
|
topWallpaper == null ? null : topWallpaper.mToken.asWallpaperToken();
|
||||||
for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
|
for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
|
||||||
final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
|
final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
|
||||||
token.updateWallpaperWindows(visibility && (!locked || token.canShowWhenLocked()));
|
token.updateWallpaperWindows(visibility && (token == topWallpaperToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,7 +816,10 @@ class WallpaperController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Keep both wallpapers visible unless the keyguard is locked (then hide private wp)
|
// Keep both wallpapers visible unless the keyguard is locked (then hide private wp)
|
||||||
updateWallpaperTokens(visible, mDisplayContent.isKeyguardLocked());
|
if (!mDisplayContent.isKeyguardGoingAway() || !mIsLockscreenLiveWallpaperEnabled) {
|
||||||
|
// When keyguard goes away, KeyguardController handles the visibility
|
||||||
|
updateWallpaperTokens(visible, mDisplayContent.isKeyguardLocked());
|
||||||
|
}
|
||||||
|
|
||||||
if (DEBUG_WALLPAPER) {
|
if (DEBUG_WALLPAPER) {
|
||||||
Slog.v(TAG, "adjustWallpaperWindows: wallpaper visibility " + visible
|
Slog.v(TAG, "adjustWallpaperWindows: wallpaper visibility " + visible
|
||||||
@@ -1019,14 +1036,52 @@ class WallpaperController {
|
|||||||
|
|
||||||
/** Helper class for storing the results of a wallpaper target find operation. */
|
/** Helper class for storing the results of a wallpaper target find operation. */
|
||||||
final private static class FindWallpaperTargetResult {
|
final private static class FindWallpaperTargetResult {
|
||||||
WindowState topWallpaper = null;
|
|
||||||
|
static final class TopWallpaper {
|
||||||
|
// A wp that can be visible on home screen only
|
||||||
|
WindowState mTopHideWhenLockedWallpaper = null;
|
||||||
|
// A wallpaper that has permission to be visible on lock screen (lock or shared wp)
|
||||||
|
WindowState mTopShowWhenLockedWallpaper = null;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
mTopHideWhenLockedWallpaper = null;
|
||||||
|
mTopShowWhenLockedWallpaper = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TopWallpaper mTopWallpaper = new TopWallpaper();
|
||||||
boolean useTopWallpaperAsTarget = false;
|
boolean useTopWallpaperAsTarget = false;
|
||||||
WindowState wallpaperTarget = null;
|
WindowState wallpaperTarget = null;
|
||||||
boolean resetTopWallpaper = false;
|
|
||||||
boolean isWallpaperTargetForLetterbox = false;
|
boolean isWallpaperTargetForLetterbox = false;
|
||||||
|
|
||||||
void setTopWallpaper(WindowState win) {
|
void setTopHideWhenLockedWallpaper(WindowState win) {
|
||||||
topWallpaper = win;
|
if (DEBUG_WALLPAPER) {
|
||||||
|
Slog.v(TAG, "setTopHideWhenLockedWallpaper " + win);
|
||||||
|
}
|
||||||
|
mTopWallpaper.mTopHideWhenLockedWallpaper = win;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTopShowWhenLockedWallpaper(WindowState win) {
|
||||||
|
if (DEBUG_WALLPAPER) {
|
||||||
|
Slog.v(TAG, "setTopShowWhenLockedWallpaper " + win);
|
||||||
|
}
|
||||||
|
mTopWallpaper.mTopShowWhenLockedWallpaper = win;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean hasTopHideWhenLockedWallpaper() {
|
||||||
|
return mTopWallpaper.mTopHideWhenLockedWallpaper != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean hasTopShowWhenLockedWallpaper() {
|
||||||
|
return mTopWallpaper.mTopShowWhenLockedWallpaper != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowState getTopWallpaper(boolean isKeyguardLocked) {
|
||||||
|
if (!isKeyguardLocked && hasTopHideWhenLockedWallpaper()) {
|
||||||
|
return mTopWallpaper.mTopHideWhenLockedWallpaper;
|
||||||
|
} else {
|
||||||
|
return mTopWallpaper.mTopShowWhenLockedWallpaper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWallpaperTarget(WindowState win) {
|
void setWallpaperTarget(WindowState win) {
|
||||||
@@ -1042,10 +1097,9 @@ class WallpaperController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
topWallpaper = null;
|
mTopWallpaper.reset();
|
||||||
wallpaperTarget = null;
|
wallpaperTarget = null;
|
||||||
useTopWallpaperAsTarget = false;
|
useTopWallpaperAsTarget = false;
|
||||||
resetTopWallpaper = false;
|
|
||||||
isWallpaperTargetForLetterbox = false;
|
isWallpaperTargetForLetterbox = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user