Merge changes I1c8db490,I96539176 into tm-qpr-dev
* changes: Use system density for window decoration Enable overriding density for desktop tasks
This commit is contained in:
@@ -121,6 +121,19 @@ public final class WindowContainerTransaction implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the densityDpi value in the configuration for the given container.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public WindowContainerTransaction setDensityDpi(@NonNull WindowContainerToken container,
|
||||||
|
int densityDpi) {
|
||||||
|
Change chg = getOrCreateChange(container.asBinder());
|
||||||
|
chg.mConfiguration.densityDpi = densityDpi;
|
||||||
|
chg.mConfigSetMask |= ActivityInfo.CONFIG_DENSITY;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify {@link com.android.server.wm.PinnedTaskController} that the picture-in-picture task
|
* Notify {@link com.android.server.wm.PinnedTaskController} that the picture-in-picture task
|
||||||
* has finished the enter animation with the given bounds.
|
* has finished the enter animation with the given bounds.
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED
|
|||||||
import android.app.WindowConfiguration.WindowingMode
|
import android.app.WindowConfiguration.WindowingMode
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
|
import android.os.SystemProperties
|
||||||
import android.view.SurfaceControl
|
import android.view.SurfaceControl
|
||||||
import android.view.WindowManager.TRANSIT_CHANGE
|
import android.view.WindowManager.TRANSIT_CHANGE
|
||||||
import android.view.WindowManager.TRANSIT_NONE
|
import android.view.WindowManager.TRANSIT_NONE
|
||||||
@@ -32,6 +33,7 @@ import android.view.WindowManager.TRANSIT_OPEN
|
|||||||
import android.view.WindowManager.TRANSIT_TO_FRONT
|
import android.view.WindowManager.TRANSIT_TO_FRONT
|
||||||
import android.window.TransitionInfo
|
import android.window.TransitionInfo
|
||||||
import android.window.TransitionRequestInfo
|
import android.window.TransitionRequestInfo
|
||||||
|
import android.window.WindowContainerToken
|
||||||
import android.window.WindowContainerTransaction
|
import android.window.WindowContainerTransaction
|
||||||
import androidx.annotation.BinderThread
|
import androidx.annotation.BinderThread
|
||||||
import com.android.internal.protolog.common.ProtoLog
|
import com.android.internal.protolog.common.ProtoLog
|
||||||
@@ -115,10 +117,7 @@ class DesktopTasksController(
|
|||||||
val wct = WindowContainerTransaction()
|
val wct = WindowContainerTransaction()
|
||||||
// Bring other apps to front first
|
// Bring other apps to front first
|
||||||
bringDesktopAppsToFront(wct)
|
bringDesktopAppsToFront(wct)
|
||||||
|
addMoveToDesktopChanges(wct, task.token)
|
||||||
wct.setWindowingMode(task.getToken(), WINDOWING_MODE_FREEFORM)
|
|
||||||
wct.reorder(task.getToken(), true /* onTop */)
|
|
||||||
|
|
||||||
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
||||||
transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
|
transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
|
||||||
} else {
|
} else {
|
||||||
@@ -136,8 +135,7 @@ class DesktopTasksController(
|
|||||||
ProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToFullscreen: %d", task.taskId)
|
ProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToFullscreen: %d", task.taskId)
|
||||||
|
|
||||||
val wct = WindowContainerTransaction()
|
val wct = WindowContainerTransaction()
|
||||||
wct.setWindowingMode(task.getToken(), WINDOWING_MODE_FULLSCREEN)
|
addMoveToFullscreenChanges(wct, task.token)
|
||||||
wct.setBounds(task.getToken(), null)
|
|
||||||
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
||||||
transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
|
transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
|
||||||
} else {
|
} else {
|
||||||
@@ -234,8 +232,8 @@ class DesktopTasksController(
|
|||||||
" taskId=%d",
|
" taskId=%d",
|
||||||
task.taskId
|
task.taskId
|
||||||
)
|
)
|
||||||
return WindowContainerTransaction().apply {
|
return WindowContainerTransaction().also { wct ->
|
||||||
setWindowingMode(task.token, WINDOWING_MODE_FREEFORM)
|
addMoveToDesktopChanges(wct, task.token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,15 +249,44 @@ class DesktopTasksController(
|
|||||||
" taskId=%d",
|
" taskId=%d",
|
||||||
task.taskId
|
task.taskId
|
||||||
)
|
)
|
||||||
return WindowContainerTransaction().apply {
|
return WindowContainerTransaction().also { wct ->
|
||||||
setWindowingMode(task.token, WINDOWING_MODE_FULLSCREEN)
|
addMoveToFullscreenChanges(wct, task.token)
|
||||||
setBounds(task.token, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addMoveToDesktopChanges(
|
||||||
|
wct: WindowContainerTransaction,
|
||||||
|
token: WindowContainerToken
|
||||||
|
) {
|
||||||
|
wct.setWindowingMode(token, WINDOWING_MODE_FREEFORM)
|
||||||
|
wct.reorder(token, true /* onTop */)
|
||||||
|
if (isDesktopDensityOverrideSet()) {
|
||||||
|
wct.setDensityDpi(token, getDesktopDensityDpi())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addMoveToFullscreenChanges(
|
||||||
|
wct: WindowContainerTransaction,
|
||||||
|
token: WindowContainerToken
|
||||||
|
) {
|
||||||
|
wct.setWindowingMode(token, WINDOWING_MODE_FULLSCREEN)
|
||||||
|
wct.setBounds(token, null)
|
||||||
|
if (isDesktopDensityOverrideSet()) {
|
||||||
|
wct.setDensityDpi(token, getFullscreenDensityDpi())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getFullscreenDensityDpi(): Int {
|
||||||
|
return context.resources.displayMetrics.densityDpi
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDesktopDensityDpi(): Int {
|
||||||
|
return DESKTOP_DENSITY_OVERRIDE
|
||||||
|
}
|
||||||
|
|
||||||
/** Creates a new instance of the external interface to pass to another process. */
|
/** Creates a new instance of the external interface to pass to another process. */
|
||||||
private fun createExternalInterface(): ExternalInterfaceBinder {
|
private fun createExternalInterface(): ExternalInterfaceBinder {
|
||||||
return IDesktopModeImpl(this)
|
return IDesktopModeImpl(this)
|
||||||
@@ -318,4 +345,18 @@ class DesktopTasksController(
|
|||||||
return result[0]
|
return result[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val DESKTOP_DENSITY_OVERRIDE =
|
||||||
|
SystemProperties.getInt("persist.wm.debug.desktop_mode_density", 0)
|
||||||
|
private val DESKTOP_DENSITY_ALLOWED_RANGE = (100..1000)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if desktop density override is enabled
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun isDesktopDensityOverrideSet(): Boolean {
|
||||||
|
return DESKTOP_DENSITY_OVERRIDE in DESKTOP_DENSITY_ALLOWED_RANGE
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import android.content.Context;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
@@ -46,6 +47,7 @@ import com.android.wm.shell.ShellTaskOrganizer;
|
|||||||
import com.android.wm.shell.common.DisplayController;
|
import com.android.wm.shell.common.DisplayController;
|
||||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||||
import com.android.wm.shell.desktopmode.DesktopModeStatus;
|
import com.android.wm.shell.desktopmode.DesktopModeStatus;
|
||||||
|
import com.android.wm.shell.desktopmode.DesktopTasksController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with
|
* Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with
|
||||||
@@ -95,6 +97,17 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
mDesktopActive = DesktopModeStatus.isActive(mContext);
|
mDesktopActive = DesktopModeStatus.isActive(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Configuration getConfigurationWithOverrides(
|
||||||
|
ActivityManager.RunningTaskInfo taskInfo) {
|
||||||
|
Configuration configuration = taskInfo.getConfiguration();
|
||||||
|
if (DesktopTasksController.isDesktopDensityOverrideSet()) {
|
||||||
|
// Density is overridden for desktop tasks. Keep system density for window decoration.
|
||||||
|
configuration.densityDpi = mContext.getResources().getConfiguration().densityDpi;
|
||||||
|
}
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
void setCaptionListeners(
|
void setCaptionListeners(
|
||||||
View.OnClickListener onCaptionButtonClickListener,
|
View.OnClickListener onCaptionButtonClickListener,
|
||||||
View.OnTouchListener onCaptionTouchListener) {
|
View.OnTouchListener onCaptionTouchListener) {
|
||||||
|
|||||||
@@ -131,7 +131,17 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
|
|||||||
mSurfaceControlViewHostFactory = surfaceControlViewHostFactory;
|
mSurfaceControlViewHostFactory = surfaceControlViewHostFactory;
|
||||||
|
|
||||||
mDisplay = mDisplayController.getDisplay(mTaskInfo.displayId);
|
mDisplay = mDisplayController.getDisplay(mTaskInfo.displayId);
|
||||||
mDecorWindowContext = mContext.createConfigurationContext(mTaskInfo.getConfiguration());
|
mDecorWindowContext = mContext.createConfigurationContext(
|
||||||
|
getConfigurationWithOverrides(mTaskInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get {@link Configuration} from supplied {@link RunningTaskInfo}.
|
||||||
|
*
|
||||||
|
* Allows values to be overridden before returning the configuration.
|
||||||
|
*/
|
||||||
|
protected Configuration getConfigurationWithOverrides(RunningTaskInfo taskInfo) {
|
||||||
|
return taskInfo.getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,7 +175,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
|
|||||||
|
|
||||||
outResult.mRootView = rootView;
|
outResult.mRootView = rootView;
|
||||||
rootView = null; // Clear it just in case we use it accidentally
|
rootView = null; // Clear it just in case we use it accidentally
|
||||||
final Configuration taskConfig = mTaskInfo.getConfiguration();
|
final Configuration taskConfig = getConfigurationWithOverrides(mTaskInfo);
|
||||||
if (oldTaskConfig.densityDpi != taskConfig.densityDpi
|
if (oldTaskConfig.densityDpi != taskConfig.densityDpi
|
||||||
|| mDisplay == null
|
|| mDisplay == null
|
||||||
|| mDisplay.getDisplayId() != mTaskInfo.displayId) {
|
|| mDisplay.getDisplayId() != mTaskInfo.displayId) {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
*/
|
*/
|
||||||
static final int CONTROLLABLE_CONFIGS = ActivityInfo.CONFIG_WINDOW_CONFIGURATION
|
static final int CONTROLLABLE_CONFIGS = ActivityInfo.CONFIG_WINDOW_CONFIGURATION
|
||||||
| ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE | ActivityInfo.CONFIG_SCREEN_SIZE
|
| ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE | ActivityInfo.CONFIG_SCREEN_SIZE
|
||||||
| ActivityInfo.CONFIG_LAYOUT_DIRECTION;
|
| ActivityInfo.CONFIG_LAYOUT_DIRECTION | ActivityInfo.CONFIG_DENSITY;
|
||||||
static final int CONTROLLABLE_WINDOW_CONFIGS = WINDOW_CONFIG_BOUNDS
|
static final int CONTROLLABLE_WINDOW_CONFIGS = WINDOW_CONFIG_BOUNDS
|
||||||
| WindowConfiguration.WINDOW_CONFIG_APP_BOUNDS;
|
| WindowConfiguration.WINDOW_CONFIG_APP_BOUNDS;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user