Merge "Implement new API of external display settings (1/2)"

This commit is contained in:
Chilun Huang
2018-11-12 01:50:25 +00:00
committed by Android (Google) Code Review
15 changed files with 681 additions and 25 deletions

View File

@@ -263,6 +263,7 @@ public final class DisplayManager {
* @see KeyguardManager#isDeviceLocked()
* @hide
*/
// TODO (b/114338689): Remove the flag and use IWindowManager#shouldShowWithInsecureKeyguard
// TODO: Update name and documentation and un-hide the flag. Don't change the value before that.
public static final int VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5;
@@ -295,6 +296,7 @@ public final class DisplayManager {
* @see #createVirtualDisplay
* @hide
*/
// TODO (b/114338689): Remove the flag and use WindowManager#REMOVE_CONTENT_MODE_DESTROY
public static final int VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL = 1 << 8;
/**
@@ -304,6 +306,7 @@ public final class DisplayManager {
* @see #createVirtualDisplay
* @hide
*/
// TODO (b/114338689): Remove the flag and use IWindowManager#setShouldShowSystemDecors
public static final int VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 1 << 9;
/** @hide */

View File

@@ -218,6 +218,7 @@ public final class Display {
* @see #getFlags
* @hide
*/
// TODO (b/114338689): Remove the flag and use IWindowManager#shouldShowWithInsecureKeyguard
public static final int FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5;
/**
@@ -230,6 +231,7 @@ public final class Display {
* @see #supportsSystemDecorations
* @hide
*/
// TODO (b/114338689): Remove the flag and use IWindowManager#setShouldShowSystemDecors
public static final int FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 1 << 6;
/**
@@ -384,6 +386,7 @@ public final class Display {
*
* @hide
*/
// TODO (b/114338689): Remove the flag and use WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY
public static final int REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY = 0;
/**
* Indicates that when display is removed, all its stacks and tasks will be removed, all
@@ -391,6 +394,7 @@ public final class Display {
*
* @hide
*/
// TODO (b/114338689): Remove the flag and use WindowManager#REMOVE_CONTENT_MODE_DESTROY
public static final int REMOVE_MODE_DESTROY_CONTENT = 1;
/**
@@ -881,6 +885,7 @@ public final class Display {
* @see #REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY
* @see #REMOVE_MODE_DESTROY_CONTENT
*/
// TODO (b/114338689): Remove the method and use IWindowManager#getRemoveContentMode
public int getRemoveMode() {
return mDisplayInfo.removeMode;
}
@@ -891,6 +896,7 @@ public final class Display {
* @see #FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS
* @hide
*/
// TODO (b/114338689): Remove the method and use IWindowManager#shouldShowSystemDecors
public boolean supportsSystemDecorations() {
return (mDisplayInfo.flags & FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0;
}

View File

@@ -266,6 +266,7 @@ public final class DisplayInfo implements Parcelable {
*
* @see Display#getRemoveMode()
*/
// TODO (b/114338689): Remove the flag and use IWindowManager#getRemoveContentMode
public int removeMode = Display.REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY;
public static final Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() {

View File

@@ -432,4 +432,120 @@ interface IWindowManager
* @param displayId The id of the display.
*/
void dontOverrideDisplayInfo(int displayId);
/**
* Gets the windowing mode of the display.
*
* @param displayId The id of the display.
* @return {@link WindowConfiguration.WindowingMode}
*/
int getWindowingMode(int displayId);
/**
* Sets the windowing mode of the display.
*
* @param displayId The id of the display.
* @param mode {@link WindowConfiguration.WindowingMode}
*/
void setWindowingMode(int displayId, int mode);
/**
* Gets current remove content mode of the display.
* <p>
* What actions should be performed with the display's content when it is removed. Default
* behavior for public displays in this case is to move all activities to the primary display
* and make it focused. For private display is to destroy all activities.
* </p>
*
* @param displayId The id of the display.
* @return The remove content mode of the display.
* @see WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY
* @see WindowManager#REMOVE_CONTENT_MODE_DESTROY
*/
int getRemoveContentMode(int displayId);
/**
* Sets the remove content mode of the display.
* <p>
* This mode indicates what actions should be performed with the display's content when it is
* removed.
* </p>
*
* @param displayId The id of the display.
* @param mode Remove content mode.
* @see WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY
* @see WindowManager#REMOVE_CONTENT_MODE_DESTROY
*/
void setRemoveContentMode(int displayId, int mode);
/**
* Indicates that the display should show its content when non-secure keyguard is shown.
* <p>
* This flag identifies secondary displays that will continue showing content if keyguard can be
* dismissed without entering credentials.
* </p><p>
* An example of usage is a virtual display which content is displayed on external hardware
* display that is not visible to the system directly.
* </p>
*
* @param displayId The id of the display.
* @return {@code true} if the display should show its content when non-secure keyguard is
* shown.
* @see KeyguardManager#isDeviceSecure()
* @see KeyguardManager#isDeviceLocked()
*/
boolean shouldShowWithInsecureKeyguard(int displayId);
/**
* Sets that the display should show its content when non-secure keyguard is shown.
*
* @param displayId The id of the display.
* @param shouldShow Indicates that the display should show its content when non-secure keyguard
* is shown.
* @see KeyguardManager#isDeviceSecure()
* @see KeyguardManager#isDeviceLocked()
*/
void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow);
/**
* Indicates the display should show system decors.
* <p>
* System decors include status bar, navigation bar, launcher.
* </p>
*
* @param displayId The id of the display.
* @return {@code true} if the display should show system decors.
*/
boolean shouldShowSystemDecors(int displayId);
/**
* Sets that the display should show system decors.
* <p>
* System decors include status bar, navigation bar, launcher.
* </p>
*
* @param displayId The id of the display.
* @param shouldShow Indicates that the display should show system decors.
*/
void setShouldShowSystemDecors(int displayId, boolean shouldShow);
/**
* Indicates that the display should show IME.
*
* @param displayId The id of the display.
* @return {@code true} if the display should show IME.
* @see KeyguardManager#isDeviceSecure()
* @see KeyguardManager#isDeviceLocked()
*/
boolean shouldShowIme(int displayId);
/**
* Sets that the display should show IME.
*
* @param displayId The id of the display.
* @param shouldShow Indicates that the display should show IME.
* @see KeyguardManager#isDeviceSecure()
* @see KeyguardManager#isDeviceLocked()
*/
void setShouldShowIme(int displayId, boolean shouldShow);
}

View File

@@ -314,6 +314,36 @@ public interface WindowManager extends ViewManager {
@Retention(RetentionPolicy.SOURCE)
@interface TransitionFlags {}
/**
* Remove content mode: Indicates remove content mode is currently not defined.
* @hide
*/
int REMOVE_CONTENT_MODE_UNDEFINED = 0;
/**
* Remove content mode: Indicates that when display is removed, all its activities will be moved
* to the primary display and the topmost activity should become focused.
* @hide
*/
int REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY = 1;
/**
* Remove content mode: Indicates that when display is removed, all its stacks and tasks will be
* removed, all activities will be destroyed according to the usual lifecycle.
* @hide
*/
int REMOVE_CONTENT_MODE_DESTROY = 2;
/**
* @hide
*/
@IntDef(prefix = { "REMOVE_CONTENT_MODE_" }, value = {
REMOVE_CONTENT_MODE_UNDEFINED,
REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY,
REMOVE_CONTENT_MODE_DESTROY,
})
@interface RemoveContentMode {}
/**
* Exception that is thrown when trying to add view whose
* {@link LayoutParams} {@link LayoutParams#token}
@@ -422,6 +452,47 @@ public interface WindowManager extends ViewManager {
@RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
public Region getCurrentImeTouchRegion();
/**
* Sets that the display should show its content when non-secure keyguard is shown.
*
* @param displayId Display ID.
* @param shouldShow Indicates that the display should show its content when non-secure keyguard
* is shown.
* @see KeyguardManager#isDeviceSecure()
* @see KeyguardManager#isDeviceLocked()
* @hide
*/
@TestApi
default void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow) {
}
/**
* Sets that the display should show system decors.
* <p>
* System decors include status bar, navigation bar, launcher.
* </p>
*
* @param displayId The id of the display.
* @param shouldShow Indicates that the display should show system decors.
* @hide
*/
@TestApi
default void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
}
/**
* Sets that the display should show IME.
*
* @param displayId Display ID.
* @param shouldShow Indicates that the display should show IME.
* @see KeyguardManager#isDeviceSecure()
* @see KeyguardManager#isDeviceLocked()
* @hide
*/
@TestApi
default void setShouldShowIme(int displayId, boolean shouldShow) {
}
public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable {
/**
* X position for this window. With the default gravity it is ignored.

View File

@@ -157,4 +157,30 @@ public final class WindowManagerImpl implements WindowManager {
}
return null;
}
@Override
public void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow) {
try {
WindowManagerGlobal.getWindowManagerService()
.setShouldShowWithInsecureKeyguard(displayId, shouldShow);
} catch (RemoteException e) {
}
}
@Override
public void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
try {
WindowManagerGlobal.getWindowManagerService()
.setShouldShowSystemDecors(displayId, shouldShow);
} catch (RemoteException e) {
}
}
@Override
public void setShouldShowIme(int displayId, boolean shouldShow) {
try {
WindowManagerGlobal.getWindowManagerService().setShouldShowIme(displayId, shouldShow);
} catch (RemoteException e) {
}
}
}