Loading core/java/android/hardware/display/DisplayManager.java +14 −4 Original line number Original line Diff line number Diff line Loading @@ -251,6 +251,15 @@ public final class DisplayManager { */ */ public static final int VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5; public static final int VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5; /** * Virtual display flag: Specifies that the virtual display can be associated with a * touchpad device that matches its uniqueId. * * @see #createVirtualDisplay * @hide */ public static final int VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH = 1 << 6; /** @hide */ /** @hide */ public DisplayManager(Context context) { public DisplayManager(Context context) { mContext = context; mContext = context; Loading Loading @@ -547,16 +556,17 @@ public final class DisplayManager { public VirtualDisplay createVirtualDisplay(@NonNull String name, public VirtualDisplay createVirtualDisplay(@NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface, int flags, int width, int height, int densityDpi, @Nullable Surface surface, int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) { @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) { return createVirtualDisplay(null, return createVirtualDisplay(null /* projection */, name, width, height, densityDpi, surface, name, width, height, densityDpi, surface, flags, callback, handler); flags, callback, handler, null /* uniqueId */); } } /** @hide */ /** @hide */ public VirtualDisplay createVirtualDisplay(@Nullable MediaProjection projection, public VirtualDisplay createVirtualDisplay(@Nullable MediaProjection projection, @NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface, @NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface, int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) { int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler, @Nullable String uniqueId) { return mGlobal.createVirtualDisplay(mContext, projection, return mGlobal.createVirtualDisplay(mContext, projection, name, width, height, densityDpi, surface, flags, callback, handler); name, width, height, densityDpi, surface, flags, callback, handler, uniqueId); } } /** /** Loading core/java/android/hardware/display/DisplayManagerGlobal.java +5 −5 Original line number Original line Diff line number Diff line Loading @@ -17,11 +17,10 @@ package android.hardware.display; package android.hardware.display; import android.content.Context; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.Resources; import android.hardware.display.DisplayManager.DisplayListener; import android.hardware.display.DisplayManager.DisplayListener; import android.media.projection.MediaProjection; import android.media.projection.IMediaProjection; import android.media.projection.IMediaProjection; import android.media.projection.MediaProjection; import android.os.Handler; import android.os.Handler; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; Loading @@ -31,8 +30,8 @@ import android.os.ServiceManager; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.util.SparseArray; import android.util.SparseArray; import android.view.DisplayAdjustments; import android.view.Display; import android.view.Display; import android.view.DisplayAdjustments; import android.view.DisplayInfo; import android.view.DisplayInfo; import android.view.Surface; import android.view.Surface; Loading Loading @@ -383,7 +382,7 @@ public final class DisplayManagerGlobal { public VirtualDisplay createVirtualDisplay(Context context, MediaProjection projection, public VirtualDisplay createVirtualDisplay(Context context, MediaProjection projection, String name, int width, int height, int densityDpi, Surface surface, int flags, String name, int width, int height, int densityDpi, Surface surface, int flags, VirtualDisplay.Callback callback, Handler handler) { VirtualDisplay.Callback callback, Handler handler, String uniqueId) { if (TextUtils.isEmpty(name)) { if (TextUtils.isEmpty(name)) { throw new IllegalArgumentException("name must be non-null and non-empty"); throw new IllegalArgumentException("name must be non-null and non-empty"); } } Loading @@ -397,7 +396,8 @@ public final class DisplayManagerGlobal { int displayId; int displayId; try { try { displayId = mDm.createVirtualDisplay(callbackWrapper, projectionToken, displayId = mDm.createVirtualDisplay(callbackWrapper, projectionToken, context.getPackageName(), name, width, height, densityDpi, surface, flags); context.getPackageName(), name, width, height, densityDpi, surface, flags, uniqueId); } catch (RemoteException ex) { } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); throw ex.rethrowFromSystemServer(); } } Loading core/java/android/hardware/display/DisplayViewport.java +51 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.hardware.display; package android.hardware.display; import android.graphics.Rect; import android.graphics.Rect; import android.text.TextUtils; /** /** * Describes how the pixels of physical display device reflects the content of * Describes how the pixels of physical display device reflects the content of Loading Loading @@ -52,6 +53,9 @@ public final class DisplayViewport { public int deviceWidth; public int deviceWidth; public int deviceHeight; public int deviceHeight; // The ID used to uniquely identify this display. public String uniqueId; public void copyFrom(DisplayViewport viewport) { public void copyFrom(DisplayViewport viewport) { valid = viewport.valid; valid = viewport.valid; displayId = viewport.displayId; displayId = viewport.displayId; Loading @@ -60,6 +64,52 @@ public final class DisplayViewport { physicalFrame.set(viewport.physicalFrame); physicalFrame.set(viewport.physicalFrame); deviceWidth = viewport.deviceWidth; deviceWidth = viewport.deviceWidth; deviceHeight = viewport.deviceHeight; deviceHeight = viewport.deviceHeight; uniqueId = viewport.uniqueId; } /** * Creates a copy of this DisplayViewport. */ public DisplayViewport makeCopy() { DisplayViewport dv = new DisplayViewport(); dv.copyFrom(this); return dv; } @Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof DisplayViewport)) { return false; } DisplayViewport other = (DisplayViewport) o; return valid == other.valid && displayId == other.displayId && orientation == other.orientation && logicalFrame.equals(other.logicalFrame) && physicalFrame.equals(other.physicalFrame) && deviceWidth == other.deviceWidth && deviceHeight == other.deviceHeight && TextUtils.equals(uniqueId, other.uniqueId); } @Override public int hashCode() { final int prime = 31; int result = 1; result += prime * result + (valid ? 1 : 0); result += prime * result + displayId; result += prime * result + orientation; result += prime * result + logicalFrame.hashCode(); result += prime * result + physicalFrame.hashCode(); result += prime * result + deviceWidth; result += prime * result + deviceHeight; result += prime * result + uniqueId.hashCode(); return result; } } // For debugging purposes. // For debugging purposes. Loading @@ -67,6 +117,7 @@ public final class DisplayViewport { public String toString() { public String toString() { return "DisplayViewport{valid=" + valid return "DisplayViewport{valid=" + valid + ", displayId=" + displayId + ", displayId=" + displayId + ", uniqueId='" + uniqueId + "'" + ", orientation=" + orientation + ", orientation=" + orientation + ", logicalFrame=" + logicalFrame + ", logicalFrame=" + logicalFrame + ", physicalFrame=" + physicalFrame + ", physicalFrame=" + physicalFrame Loading core/java/android/hardware/display/IDisplayManager.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -66,7 +66,7 @@ interface IDisplayManager { // MediaProjection token for certain combinations of flags. // MediaProjection token for certain combinations of flags. int createVirtualDisplay(in IVirtualDisplayCallback callback, int createVirtualDisplay(in IVirtualDisplayCallback callback, in IMediaProjection projectionToken, String packageName, String name, in IMediaProjection projectionToken, String packageName, String name, int width, int height, int densityDpi, in Surface surface, int flags); int width, int height, int densityDpi, in Surface surface, int flags, String uniqueId); // No permissions required, but must be same Uid as the creator. // No permissions required, but must be same Uid as the creator. void resizeVirtualDisplay(in IVirtualDisplayCallback token, void resizeVirtualDisplay(in IVirtualDisplayCallback token, Loading core/java/android/hardware/input/InputManagerInternal.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.view.InputEvent; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype; import java.util.List; /** /** * Input manager local system service interface. * Input manager local system service interface. * * Loading @@ -35,7 +37,7 @@ public abstract class InputManagerInternal { * by the input system. The input system must copy this information to retain it. * by the input system. The input system must copy this information to retain it. */ */ public abstract void setDisplayViewports(DisplayViewport defaultViewport, public abstract void setDisplayViewports(DisplayViewport defaultViewport, DisplayViewport externalTouchViewport); DisplayViewport externalTouchViewport, List<DisplayViewport> virtualTouchViewports); /** /** * Called by the power manager to tell the input manager whether it should start * Called by the power manager to tell the input manager whether it should start Loading Loading
core/java/android/hardware/display/DisplayManager.java +14 −4 Original line number Original line Diff line number Diff line Loading @@ -251,6 +251,15 @@ public final class DisplayManager { */ */ public static final int VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5; public static final int VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5; /** * Virtual display flag: Specifies that the virtual display can be associated with a * touchpad device that matches its uniqueId. * * @see #createVirtualDisplay * @hide */ public static final int VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH = 1 << 6; /** @hide */ /** @hide */ public DisplayManager(Context context) { public DisplayManager(Context context) { mContext = context; mContext = context; Loading Loading @@ -547,16 +556,17 @@ public final class DisplayManager { public VirtualDisplay createVirtualDisplay(@NonNull String name, public VirtualDisplay createVirtualDisplay(@NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface, int flags, int width, int height, int densityDpi, @Nullable Surface surface, int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) { @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) { return createVirtualDisplay(null, return createVirtualDisplay(null /* projection */, name, width, height, densityDpi, surface, name, width, height, densityDpi, surface, flags, callback, handler); flags, callback, handler, null /* uniqueId */); } } /** @hide */ /** @hide */ public VirtualDisplay createVirtualDisplay(@Nullable MediaProjection projection, public VirtualDisplay createVirtualDisplay(@Nullable MediaProjection projection, @NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface, @NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface, int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) { int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler, @Nullable String uniqueId) { return mGlobal.createVirtualDisplay(mContext, projection, return mGlobal.createVirtualDisplay(mContext, projection, name, width, height, densityDpi, surface, flags, callback, handler); name, width, height, densityDpi, surface, flags, callback, handler, uniqueId); } } /** /** Loading
core/java/android/hardware/display/DisplayManagerGlobal.java +5 −5 Original line number Original line Diff line number Diff line Loading @@ -17,11 +17,10 @@ package android.hardware.display; package android.hardware.display; import android.content.Context; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.Resources; import android.hardware.display.DisplayManager.DisplayListener; import android.hardware.display.DisplayManager.DisplayListener; import android.media.projection.MediaProjection; import android.media.projection.IMediaProjection; import android.media.projection.IMediaProjection; import android.media.projection.MediaProjection; import android.os.Handler; import android.os.Handler; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; Loading @@ -31,8 +30,8 @@ import android.os.ServiceManager; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.util.SparseArray; import android.util.SparseArray; import android.view.DisplayAdjustments; import android.view.Display; import android.view.Display; import android.view.DisplayAdjustments; import android.view.DisplayInfo; import android.view.DisplayInfo; import android.view.Surface; import android.view.Surface; Loading Loading @@ -383,7 +382,7 @@ public final class DisplayManagerGlobal { public VirtualDisplay createVirtualDisplay(Context context, MediaProjection projection, public VirtualDisplay createVirtualDisplay(Context context, MediaProjection projection, String name, int width, int height, int densityDpi, Surface surface, int flags, String name, int width, int height, int densityDpi, Surface surface, int flags, VirtualDisplay.Callback callback, Handler handler) { VirtualDisplay.Callback callback, Handler handler, String uniqueId) { if (TextUtils.isEmpty(name)) { if (TextUtils.isEmpty(name)) { throw new IllegalArgumentException("name must be non-null and non-empty"); throw new IllegalArgumentException("name must be non-null and non-empty"); } } Loading @@ -397,7 +396,8 @@ public final class DisplayManagerGlobal { int displayId; int displayId; try { try { displayId = mDm.createVirtualDisplay(callbackWrapper, projectionToken, displayId = mDm.createVirtualDisplay(callbackWrapper, projectionToken, context.getPackageName(), name, width, height, densityDpi, surface, flags); context.getPackageName(), name, width, height, densityDpi, surface, flags, uniqueId); } catch (RemoteException ex) { } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); throw ex.rethrowFromSystemServer(); } } Loading
core/java/android/hardware/display/DisplayViewport.java +51 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.hardware.display; package android.hardware.display; import android.graphics.Rect; import android.graphics.Rect; import android.text.TextUtils; /** /** * Describes how the pixels of physical display device reflects the content of * Describes how the pixels of physical display device reflects the content of Loading Loading @@ -52,6 +53,9 @@ public final class DisplayViewport { public int deviceWidth; public int deviceWidth; public int deviceHeight; public int deviceHeight; // The ID used to uniquely identify this display. public String uniqueId; public void copyFrom(DisplayViewport viewport) { public void copyFrom(DisplayViewport viewport) { valid = viewport.valid; valid = viewport.valid; displayId = viewport.displayId; displayId = viewport.displayId; Loading @@ -60,6 +64,52 @@ public final class DisplayViewport { physicalFrame.set(viewport.physicalFrame); physicalFrame.set(viewport.physicalFrame); deviceWidth = viewport.deviceWidth; deviceWidth = viewport.deviceWidth; deviceHeight = viewport.deviceHeight; deviceHeight = viewport.deviceHeight; uniqueId = viewport.uniqueId; } /** * Creates a copy of this DisplayViewport. */ public DisplayViewport makeCopy() { DisplayViewport dv = new DisplayViewport(); dv.copyFrom(this); return dv; } @Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof DisplayViewport)) { return false; } DisplayViewport other = (DisplayViewport) o; return valid == other.valid && displayId == other.displayId && orientation == other.orientation && logicalFrame.equals(other.logicalFrame) && physicalFrame.equals(other.physicalFrame) && deviceWidth == other.deviceWidth && deviceHeight == other.deviceHeight && TextUtils.equals(uniqueId, other.uniqueId); } @Override public int hashCode() { final int prime = 31; int result = 1; result += prime * result + (valid ? 1 : 0); result += prime * result + displayId; result += prime * result + orientation; result += prime * result + logicalFrame.hashCode(); result += prime * result + physicalFrame.hashCode(); result += prime * result + deviceWidth; result += prime * result + deviceHeight; result += prime * result + uniqueId.hashCode(); return result; } } // For debugging purposes. // For debugging purposes. Loading @@ -67,6 +117,7 @@ public final class DisplayViewport { public String toString() { public String toString() { return "DisplayViewport{valid=" + valid return "DisplayViewport{valid=" + valid + ", displayId=" + displayId + ", displayId=" + displayId + ", uniqueId='" + uniqueId + "'" + ", orientation=" + orientation + ", orientation=" + orientation + ", logicalFrame=" + logicalFrame + ", logicalFrame=" + logicalFrame + ", physicalFrame=" + physicalFrame + ", physicalFrame=" + physicalFrame Loading
core/java/android/hardware/display/IDisplayManager.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -66,7 +66,7 @@ interface IDisplayManager { // MediaProjection token for certain combinations of flags. // MediaProjection token for certain combinations of flags. int createVirtualDisplay(in IVirtualDisplayCallback callback, int createVirtualDisplay(in IVirtualDisplayCallback callback, in IMediaProjection projectionToken, String packageName, String name, in IMediaProjection projectionToken, String packageName, String name, int width, int height, int densityDpi, in Surface surface, int flags); int width, int height, int densityDpi, in Surface surface, int flags, String uniqueId); // No permissions required, but must be same Uid as the creator. // No permissions required, but must be same Uid as the creator. void resizeVirtualDisplay(in IVirtualDisplayCallback token, void resizeVirtualDisplay(in IVirtualDisplayCallback token, Loading
core/java/android/hardware/input/InputManagerInternal.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.view.InputEvent; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype; import java.util.List; /** /** * Input manager local system service interface. * Input manager local system service interface. * * Loading @@ -35,7 +37,7 @@ public abstract class InputManagerInternal { * by the input system. The input system must copy this information to retain it. * by the input system. The input system must copy this information to retain it. */ */ public abstract void setDisplayViewports(DisplayViewport defaultViewport, public abstract void setDisplayViewports(DisplayViewport defaultViewport, DisplayViewport externalTouchViewport); DisplayViewport externalTouchViewport, List<DisplayViewport> virtualTouchViewports); /** /** * Called by the power manager to tell the input manager whether it should start * Called by the power manager to tell the input manager whether it should start Loading