Merge "Added unique id to display devices and their settings." into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
997e632f59
@@ -58,6 +58,11 @@ public final class DisplayInfo implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique identifier for the display. Shouldn't be displayed to the user.
|
||||||
|
*/
|
||||||
|
public String uniqueId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of the portion of the display that is available to applications, in pixels.
|
* The width of the portion of the display that is available to applications, in pixels.
|
||||||
* Represents the size of the display minus any system decorations.
|
* Represents the size of the display minus any system decorations.
|
||||||
@@ -257,7 +262,7 @@ public final class DisplayInfo implements Parcelable {
|
|||||||
&& flags == other.flags
|
&& flags == other.flags
|
||||||
&& type == other.type
|
&& type == other.type
|
||||||
&& Objects.equal(address, other.address)
|
&& Objects.equal(address, other.address)
|
||||||
&& Objects.equal(name, other.name)
|
&& Objects.equal(uniqueId, other.uniqueId)
|
||||||
&& appWidth == other.appWidth
|
&& appWidth == other.appWidth
|
||||||
&& appHeight == other.appHeight
|
&& appHeight == other.appHeight
|
||||||
&& smallestNominalAppWidth == other.smallestNominalAppWidth
|
&& smallestNominalAppWidth == other.smallestNominalAppWidth
|
||||||
@@ -293,6 +298,7 @@ public final class DisplayInfo implements Parcelable {
|
|||||||
type = other.type;
|
type = other.type;
|
||||||
address = other.address;
|
address = other.address;
|
||||||
name = other.name;
|
name = other.name;
|
||||||
|
uniqueId = other.uniqueId;
|
||||||
appWidth = other.appWidth;
|
appWidth = other.appWidth;
|
||||||
appHeight = other.appHeight;
|
appHeight = other.appHeight;
|
||||||
smallestNominalAppWidth = other.smallestNominalAppWidth;
|
smallestNominalAppWidth = other.smallestNominalAppWidth;
|
||||||
@@ -348,6 +354,7 @@ public final class DisplayInfo implements Parcelable {
|
|||||||
state = source.readInt();
|
state = source.readInt();
|
||||||
ownerUid = source.readInt();
|
ownerUid = source.readInt();
|
||||||
ownerPackageName = source.readString();
|
ownerPackageName = source.readString();
|
||||||
|
uniqueId = source.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -380,6 +387,7 @@ public final class DisplayInfo implements Parcelable {
|
|||||||
dest.writeInt(state);
|
dest.writeInt(state);
|
||||||
dest.writeInt(ownerUid);
|
dest.writeInt(ownerUid);
|
||||||
dest.writeString(ownerPackageName);
|
dest.writeString(ownerPackageName);
|
||||||
|
dest.writeString(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -445,6 +453,8 @@ public final class DisplayInfo implements Parcelable {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("DisplayInfo{\"");
|
sb.append("DisplayInfo{\"");
|
||||||
sb.append(name);
|
sb.append(name);
|
||||||
|
sb.append("\", uniqueId \"");
|
||||||
|
sb.append(uniqueId);
|
||||||
sb.append("\", app ");
|
sb.append("\", app ");
|
||||||
sb.append(appWidth);
|
sb.append(appWidth);
|
||||||
sb.append(" x ");
|
sb.append(" x ");
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import java.io.PrintWriter;
|
|||||||
abstract class DisplayDevice {
|
abstract class DisplayDevice {
|
||||||
private final DisplayAdapter mDisplayAdapter;
|
private final DisplayAdapter mDisplayAdapter;
|
||||||
private final IBinder mDisplayToken;
|
private final IBinder mDisplayToken;
|
||||||
|
private final String mUniqueId;
|
||||||
|
|
||||||
// The display device does not manage these properties itself, they are set by
|
// The display device does not manage these properties itself, they are set by
|
||||||
// the display manager service. The display device shouldn't really be looking at these.
|
// the display manager service. The display device shouldn't really be looking at these.
|
||||||
@@ -46,9 +47,10 @@ abstract class DisplayDevice {
|
|||||||
// within a transaction from performTraversalInTransactionLocked.
|
// within a transaction from performTraversalInTransactionLocked.
|
||||||
private Surface mCurrentSurface;
|
private Surface mCurrentSurface;
|
||||||
|
|
||||||
public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken) {
|
public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken, String uniqueId) {
|
||||||
mDisplayAdapter = displayAdapter;
|
mDisplayAdapter = displayAdapter;
|
||||||
mDisplayToken = displayToken;
|
mDisplayToken = displayToken;
|
||||||
|
mUniqueId = uniqueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,6 +81,13 @@ abstract class DisplayDevice {
|
|||||||
return getDisplayDeviceInfoLocked().name;
|
return getDisplayDeviceInfoLocked().name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the unique id of the display device.
|
||||||
|
*/
|
||||||
|
public final String getUniqueId() {
|
||||||
|
return mUniqueId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information about the display device.
|
* Gets information about the display device.
|
||||||
*
|
*
|
||||||
@@ -208,6 +217,7 @@ abstract class DisplayDevice {
|
|||||||
*/
|
*/
|
||||||
public void dumpLocked(PrintWriter pw) {
|
public void dumpLocked(PrintWriter pw) {
|
||||||
pw.println("mAdapter=" + mDisplayAdapter.getName());
|
pw.println("mAdapter=" + mDisplayAdapter.getName());
|
||||||
|
pw.println("mUniqueId=" + mUniqueId);
|
||||||
pw.println("mDisplayToken=" + mDisplayToken);
|
pw.println("mDisplayToken=" + mDisplayToken);
|
||||||
pw.println("mCurrentLayerStack=" + mCurrentLayerStack);
|
pw.println("mCurrentLayerStack=" + mCurrentLayerStack);
|
||||||
pw.println("mCurrentOrientation=" + mCurrentOrientation);
|
pw.println("mCurrentOrientation=" + mCurrentOrientation);
|
||||||
|
|||||||
@@ -104,11 +104,16 @@ final class DisplayDeviceInfo {
|
|||||||
public static final int TOUCH_EXTERNAL = 2;
|
public static final int TOUCH_EXTERNAL = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of the display device, which may be derived from
|
* Gets the name of the display device, which may be derived from EDID or
|
||||||
* EDID or other sources. The name may be displayed to the user.
|
* other sources. The name may be localized and displayed to the user.
|
||||||
*/
|
*/
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique Id of display device.
|
||||||
|
*/
|
||||||
|
public String uniqueId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of the display in its natural orientation, in pixels.
|
* The width of the display in its natural orientation, in pixels.
|
||||||
* This value is not affected by display rotation.
|
* This value is not affected by display rotation.
|
||||||
@@ -235,6 +240,7 @@ final class DisplayDeviceInfo {
|
|||||||
public boolean equals(DisplayDeviceInfo other) {
|
public boolean equals(DisplayDeviceInfo other) {
|
||||||
return other != null
|
return other != null
|
||||||
&& Objects.equal(name, other.name)
|
&& Objects.equal(name, other.name)
|
||||||
|
&& Objects.equal(uniqueId, other.uniqueId)
|
||||||
&& width == other.width
|
&& width == other.width
|
||||||
&& height == other.height
|
&& height == other.height
|
||||||
&& refreshRate == other.refreshRate
|
&& refreshRate == other.refreshRate
|
||||||
@@ -261,6 +267,7 @@ final class DisplayDeviceInfo {
|
|||||||
|
|
||||||
public void copyFrom(DisplayDeviceInfo other) {
|
public void copyFrom(DisplayDeviceInfo other) {
|
||||||
name = other.name;
|
name = other.name;
|
||||||
|
uniqueId = other.uniqueId;
|
||||||
width = other.width;
|
width = other.width;
|
||||||
height = other.height;
|
height = other.height;
|
||||||
refreshRate = other.refreshRate;
|
refreshRate = other.refreshRate;
|
||||||
@@ -285,7 +292,8 @@ final class DisplayDeviceInfo {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("DisplayDeviceInfo{\"");
|
sb.append("DisplayDeviceInfo{\"");
|
||||||
sb.append(name).append("\": ").append(width).append(" x ").append(height);
|
sb.append(name).append("\": uniqueId=\"").append(uniqueId).append("\", ");
|
||||||
|
sb.append(width).append(" x ").append(height);
|
||||||
sb.append(", ").append(refreshRate).append(" fps");
|
sb.append(", ").append(refreshRate).append(" fps");
|
||||||
sb.append(", supportedRefreshRates ").append(Arrays.toString(supportedRefreshRates));
|
sb.append(", supportedRefreshRates ").append(Arrays.toString(supportedRefreshRates));
|
||||||
sb.append(", density ").append(densityDpi);
|
sb.append(", density ").append(densityDpi);
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ import java.util.Arrays;
|
|||||||
final class LocalDisplayAdapter extends DisplayAdapter {
|
final class LocalDisplayAdapter extends DisplayAdapter {
|
||||||
private static final String TAG = "LocalDisplayAdapter";
|
private static final String TAG = "LocalDisplayAdapter";
|
||||||
|
|
||||||
|
private static final String UNIQUE_ID_PREFIX = "local:";
|
||||||
|
|
||||||
private static final int[] BUILT_IN_DISPLAY_IDS_TO_SCAN = new int[] {
|
private static final int[] BUILT_IN_DISPLAY_IDS_TO_SCAN = new int[] {
|
||||||
SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN,
|
SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN,
|
||||||
SurfaceControl.BUILT_IN_DISPLAY_ID_HDMI,
|
SurfaceControl.BUILT_IN_DISPLAY_ID_HDMI,
|
||||||
@@ -140,7 +142,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
|||||||
|
|
||||||
public LocalDisplayDevice(IBinder displayToken, int builtInDisplayId,
|
public LocalDisplayDevice(IBinder displayToken, int builtInDisplayId,
|
||||||
SurfaceControl.PhysicalDisplayInfo[] physicalDisplayInfos, int activeDisplayInfo) {
|
SurfaceControl.PhysicalDisplayInfo[] physicalDisplayInfos, int activeDisplayInfo) {
|
||||||
super(LocalDisplayAdapter.this, displayToken);
|
super(LocalDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + builtInDisplayId);
|
||||||
mBuiltInDisplayId = builtInDisplayId;
|
mBuiltInDisplayId = builtInDisplayId;
|
||||||
mPhys = new SurfaceControl.PhysicalDisplayInfo(
|
mPhys = new SurfaceControl.PhysicalDisplayInfo(
|
||||||
physicalDisplayInfos[activeDisplayInfo]);
|
physicalDisplayInfos[activeDisplayInfo]);
|
||||||
@@ -179,6 +181,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
|||||||
mInfo.appVsyncOffsetNanos = mPhys.appVsyncOffsetNanos;
|
mInfo.appVsyncOffsetNanos = mPhys.appVsyncOffsetNanos;
|
||||||
mInfo.presentationDeadlineNanos = mPhys.presentationDeadlineNanos;
|
mInfo.presentationDeadlineNanos = mPhys.presentationDeadlineNanos;
|
||||||
mInfo.state = mState;
|
mInfo.state = mState;
|
||||||
|
mInfo.uniqueId = getUniqueId();
|
||||||
|
|
||||||
// Assume that all built-in displays that have secure output (eg. HDCP) also
|
// Assume that all built-in displays that have secure output (eg. HDCP) also
|
||||||
// support compositing from gralloc protected buffers.
|
// support compositing from gralloc protected buffers.
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ final class LogicalDisplay {
|
|||||||
mInfo.copyFrom(mOverrideDisplayInfo);
|
mInfo.copyFrom(mOverrideDisplayInfo);
|
||||||
mInfo.layerStack = mBaseDisplayInfo.layerStack;
|
mInfo.layerStack = mBaseDisplayInfo.layerStack;
|
||||||
mInfo.name = mBaseDisplayInfo.name;
|
mInfo.name = mBaseDisplayInfo.name;
|
||||||
|
mInfo.uniqueId = mBaseDisplayInfo.uniqueId;
|
||||||
mInfo.state = mBaseDisplayInfo.state;
|
mInfo.state = mBaseDisplayInfo.state;
|
||||||
} else {
|
} else {
|
||||||
mInfo.copyFrom(mBaseDisplayInfo);
|
mInfo.copyFrom(mBaseDisplayInfo);
|
||||||
@@ -208,6 +209,7 @@ final class LogicalDisplay {
|
|||||||
mBaseDisplayInfo.type = deviceInfo.type;
|
mBaseDisplayInfo.type = deviceInfo.type;
|
||||||
mBaseDisplayInfo.address = deviceInfo.address;
|
mBaseDisplayInfo.address = deviceInfo.address;
|
||||||
mBaseDisplayInfo.name = deviceInfo.name;
|
mBaseDisplayInfo.name = deviceInfo.name;
|
||||||
|
mBaseDisplayInfo.uniqueId = deviceInfo.uniqueId;
|
||||||
mBaseDisplayInfo.appWidth = deviceInfo.width;
|
mBaseDisplayInfo.appWidth = deviceInfo.width;
|
||||||
mBaseDisplayInfo.appHeight = deviceInfo.height;
|
mBaseDisplayInfo.appHeight = deviceInfo.height;
|
||||||
mBaseDisplayInfo.logicalWidth = deviceInfo.width;
|
mBaseDisplayInfo.logicalWidth = deviceInfo.width;
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
|||||||
private static final Pattern SETTING_PATTERN =
|
private static final Pattern SETTING_PATTERN =
|
||||||
Pattern.compile("(\\d+)x(\\d+)/(\\d+)(,[a-z]+)*");
|
Pattern.compile("(\\d+)x(\\d+)/(\\d+)(,[a-z]+)*");
|
||||||
|
|
||||||
|
// Unique id prefix for overlay displays.
|
||||||
|
private static final String UNIQUE_ID_PREFIX = "overlay:";
|
||||||
|
|
||||||
private final Handler mUiHandler;
|
private final Handler mUiHandler;
|
||||||
private final ArrayList<OverlayDisplayHandle> mOverlays =
|
private final ArrayList<OverlayDisplayHandle> mOverlays =
|
||||||
new ArrayList<OverlayDisplayHandle>();
|
new ArrayList<OverlayDisplayHandle>();
|
||||||
@@ -160,7 +163,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
|||||||
+ ", densityDpi=" + densityDpi + ", secure=" + secure);
|
+ ", densityDpi=" + densityDpi + ", secure=" + secure);
|
||||||
|
|
||||||
mOverlays.add(new OverlayDisplayHandle(name,
|
mOverlays.add(new OverlayDisplayHandle(name,
|
||||||
width, height, densityDpi, gravity, secure));
|
width, height, densityDpi, gravity, secure, number));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
@@ -203,8 +206,8 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
|||||||
public OverlayDisplayDevice(IBinder displayToken, String name,
|
public OverlayDisplayDevice(IBinder displayToken, String name,
|
||||||
int width, int height, float refreshRate, long presentationDeadlineNanos,
|
int width, int height, float refreshRate, long presentationDeadlineNanos,
|
||||||
int densityDpi, boolean secure, int state,
|
int densityDpi, boolean secure, int state,
|
||||||
SurfaceTexture surfaceTexture) {
|
SurfaceTexture surfaceTexture, int number) {
|
||||||
super(OverlayDisplayAdapter.this, displayToken);
|
super(OverlayDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + number);
|
||||||
mName = name;
|
mName = name;
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
@@ -245,6 +248,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
|||||||
if (mInfo == null) {
|
if (mInfo == null) {
|
||||||
mInfo = new DisplayDeviceInfo();
|
mInfo = new DisplayDeviceInfo();
|
||||||
mInfo.name = mName;
|
mInfo.name = mName;
|
||||||
|
mInfo.uniqueId = getUniqueId();
|
||||||
mInfo.width = mWidth;
|
mInfo.width = mWidth;
|
||||||
mInfo.height = mHeight;
|
mInfo.height = mHeight;
|
||||||
mInfo.refreshRate = mRefreshRate;
|
mInfo.refreshRate = mRefreshRate;
|
||||||
@@ -279,18 +283,20 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
|||||||
private final int mDensityDpi;
|
private final int mDensityDpi;
|
||||||
private final int mGravity;
|
private final int mGravity;
|
||||||
private final boolean mSecure;
|
private final boolean mSecure;
|
||||||
|
private final int mNumber;
|
||||||
|
|
||||||
private OverlayDisplayWindow mWindow;
|
private OverlayDisplayWindow mWindow;
|
||||||
private OverlayDisplayDevice mDevice;
|
private OverlayDisplayDevice mDevice;
|
||||||
|
|
||||||
public OverlayDisplayHandle(String name,
|
public OverlayDisplayHandle(String name, int width,
|
||||||
int width, int height, int densityDpi, int gravity, boolean secure) {
|
int height, int densityDpi, int gravity, boolean secure, int number) {
|
||||||
mName = name;
|
mName = name;
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
mDensityDpi = densityDpi;
|
mDensityDpi = densityDpi;
|
||||||
mGravity = gravity;
|
mGravity = gravity;
|
||||||
mSecure = secure;
|
mSecure = secure;
|
||||||
|
mNumber = number;
|
||||||
|
|
||||||
mUiHandler.post(mShowRunnable);
|
mUiHandler.post(mShowRunnable);
|
||||||
}
|
}
|
||||||
@@ -308,7 +314,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
|||||||
IBinder displayToken = SurfaceControl.createDisplay(mName, mSecure);
|
IBinder displayToken = SurfaceControl.createDisplay(mName, mSecure);
|
||||||
mDevice = new OverlayDisplayDevice(displayToken, mName,
|
mDevice = new OverlayDisplayDevice(displayToken, mName,
|
||||||
mWidth, mHeight, refreshRate, presentationDeadlineNanos,
|
mWidth, mHeight, refreshRate, presentationDeadlineNanos,
|
||||||
mDensityDpi, mSecure, state, surfaceTexture);
|
mDensityDpi, mSecure, state, surfaceTexture, mNumber);
|
||||||
|
|
||||||
sendDisplayDeviceEventLocked(mDevice, DISPLAY_DEVICE_EVENT_ADDED);
|
sendDisplayDeviceEventLocked(mDevice, DISPLAY_DEVICE_EVENT_ADDED);
|
||||||
}
|
}
|
||||||
@@ -343,6 +349,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
|||||||
pw.println(" mDensityDpi=" + mDensityDpi);
|
pw.println(" mDensityDpi=" + mDensityDpi);
|
||||||
pw.println(" mGravity=" + mGravity);
|
pw.println(" mGravity=" + mGravity);
|
||||||
pw.println(" mSecure=" + mSecure);
|
pw.println(" mSecure=" + mSecure);
|
||||||
|
pw.println(" mNumber=" + mNumber);
|
||||||
|
|
||||||
// Try to dump the window state.
|
// Try to dump the window state.
|
||||||
if (mWindow != null) {
|
if (mWindow != null) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.view.Surface;
|
|||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A display adapter that provides virtual displays on behalf of applications.
|
* A display adapter that provides virtual displays on behalf of applications.
|
||||||
@@ -45,6 +46,9 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
|||||||
static final String TAG = "VirtualDisplayAdapter";
|
static final String TAG = "VirtualDisplayAdapter";
|
||||||
static final boolean DEBUG = false;
|
static final boolean DEBUG = false;
|
||||||
|
|
||||||
|
// Unique id prefix for virtual displays
|
||||||
|
private static final String UNIQUE_ID_PREFIX = "virtual:";
|
||||||
|
|
||||||
private final ArrayMap<IBinder, VirtualDisplayDevice> mVirtualDisplayDevices =
|
private final ArrayMap<IBinder, VirtualDisplayDevice> mVirtualDisplayDevices =
|
||||||
new ArrayMap<IBinder, VirtualDisplayDevice>();
|
new ArrayMap<IBinder, VirtualDisplayDevice>();
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
@@ -62,9 +66,12 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
|||||||
boolean secure = (flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE) != 0;
|
boolean secure = (flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE) != 0;
|
||||||
IBinder appToken = callback.asBinder();
|
IBinder appToken = callback.asBinder();
|
||||||
IBinder displayToken = SurfaceControl.createDisplay(name, secure);
|
IBinder displayToken = SurfaceControl.createDisplay(name, secure);
|
||||||
|
final String baseUniqueId =
|
||||||
|
UNIQUE_ID_PREFIX + ownerPackageName + "," + ownerUid + "," + name + ",";
|
||||||
|
final int uniqueIndex = getNextUniqueIndex(baseUniqueId);
|
||||||
VirtualDisplayDevice device = new VirtualDisplayDevice(displayToken, appToken,
|
VirtualDisplayDevice device = new VirtualDisplayDevice(displayToken, appToken,
|
||||||
ownerUid, ownerPackageName, name, width, height, densityDpi, surface, flags,
|
ownerUid, ownerPackageName, name, width, height, densityDpi, surface, flags,
|
||||||
new Callback(callback, mHandler));
|
new Callback(callback, mHandler), baseUniqueId + uniqueIndex, uniqueIndex);
|
||||||
|
|
||||||
mVirtualDisplayDevices.put(appToken, device);
|
mVirtualDisplayDevices.put(appToken, device);
|
||||||
|
|
||||||
@@ -112,6 +119,29 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
|||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next unique index for the uniqueIdPrefix
|
||||||
|
*/
|
||||||
|
private int getNextUniqueIndex(String uniqueIdPrefix) {
|
||||||
|
if (mVirtualDisplayDevices.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nextUniqueIndex = 0;
|
||||||
|
Iterator<VirtualDisplayDevice> it = mVirtualDisplayDevices.values().iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
VirtualDisplayDevice device = it.next();
|
||||||
|
if (device.getUniqueId().startsWith(uniqueIdPrefix)
|
||||||
|
&& device.mUniqueIndex >= nextUniqueIndex) {
|
||||||
|
// Increment the next unique index to be greater than ones we have already ran
|
||||||
|
// across for displays that have the same unique Id prefix.
|
||||||
|
nextUniqueIndex = device.mUniqueIndex + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nextUniqueIndex;
|
||||||
|
}
|
||||||
|
|
||||||
private void handleBinderDiedLocked(IBinder appToken) {
|
private void handleBinderDiedLocked(IBinder appToken) {
|
||||||
VirtualDisplayDevice device = mVirtualDisplayDevices.remove(appToken);
|
VirtualDisplayDevice device = mVirtualDisplayDevices.remove(appToken);
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
@@ -150,12 +180,13 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
|||||||
private int mDisplayState;
|
private int mDisplayState;
|
||||||
private boolean mStopped;
|
private boolean mStopped;
|
||||||
private int mPendingChanges;
|
private int mPendingChanges;
|
||||||
|
private int mUniqueIndex;
|
||||||
|
|
||||||
public VirtualDisplayDevice(IBinder displayToken, IBinder appToken,
|
public VirtualDisplayDevice(IBinder displayToken, IBinder appToken,
|
||||||
int ownerUid, String ownerPackageName,
|
int ownerUid, String ownerPackageName,
|
||||||
String name, int width, int height, int densityDpi, Surface surface, int flags,
|
String name, int width, int height, int densityDpi, Surface surface, int flags,
|
||||||
Callback callback) {
|
Callback callback, String uniqueId, int uniqueIndex) {
|
||||||
super(VirtualDisplayAdapter.this, displayToken);
|
super(VirtualDisplayAdapter.this, displayToken, uniqueId);
|
||||||
mAppToken = appToken;
|
mAppToken = appToken;
|
||||||
mOwnerUid = ownerUid;
|
mOwnerUid = ownerUid;
|
||||||
mOwnerPackageName = ownerPackageName;
|
mOwnerPackageName = ownerPackageName;
|
||||||
@@ -168,6 +199,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
|||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
mDisplayState = Display.STATE_UNKNOWN;
|
mDisplayState = Display.STATE_UNKNOWN;
|
||||||
mPendingChanges |= PENDING_SURFACE_CHANGE;
|
mPendingChanges |= PENDING_SURFACE_CHANGE;
|
||||||
|
mUniqueIndex = uniqueIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -255,6 +287,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
|||||||
if (mInfo == null) {
|
if (mInfo == null) {
|
||||||
mInfo = new DisplayDeviceInfo();
|
mInfo = new DisplayDeviceInfo();
|
||||||
mInfo.name = mName;
|
mInfo.name = mName;
|
||||||
|
mInfo.uniqueId = getUniqueId();
|
||||||
mInfo.width = mWidth;
|
mInfo.width = mWidth;
|
||||||
mInfo.height = mHeight;
|
mInfo.height = mHeight;
|
||||||
mInfo.refreshRate = 60;
|
mInfo.refreshRate = 60;
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ final class WifiDisplayAdapter extends DisplayAdapter {
|
|||||||
|
|
||||||
private static final String ACTION_DISCONNECT = "android.server.display.wfd.DISCONNECT";
|
private static final String ACTION_DISCONNECT = "android.server.display.wfd.DISCONNECT";
|
||||||
|
|
||||||
|
// Unique id prefix for wifi displays
|
||||||
|
private static final String DISPLAY_NAME_PREFIX = "wifi:";
|
||||||
|
|
||||||
private final WifiDisplayHandler mHandler;
|
private final WifiDisplayHandler mHandler;
|
||||||
private final PersistentDataStore mPersistentDataStore;
|
private final PersistentDataStore mPersistentDataStore;
|
||||||
private final boolean mSupportsProtectedBuffers;
|
private final boolean mSupportsProtectedBuffers;
|
||||||
@@ -587,7 +590,7 @@ final class WifiDisplayAdapter extends DisplayAdapter {
|
|||||||
public WifiDisplayDevice(IBinder displayToken, String name,
|
public WifiDisplayDevice(IBinder displayToken, String name,
|
||||||
int width, int height, float refreshRate, int flags, String address,
|
int width, int height, float refreshRate, int flags, String address,
|
||||||
Surface surface) {
|
Surface surface) {
|
||||||
super(WifiDisplayAdapter.this, displayToken);
|
super(WifiDisplayAdapter.this, displayToken, DISPLAY_NAME_PREFIX + address);
|
||||||
mName = name;
|
mName = name;
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
@@ -622,6 +625,7 @@ final class WifiDisplayAdapter extends DisplayAdapter {
|
|||||||
if (mInfo == null) {
|
if (mInfo == null) {
|
||||||
mInfo = new DisplayDeviceInfo();
|
mInfo = new DisplayDeviceInfo();
|
||||||
mInfo.name = mName;
|
mInfo.name = mName;
|
||||||
|
mInfo.uniqueId = getUniqueId();
|
||||||
mInfo.width = mWidth;
|
mInfo.width = mWidth;
|
||||||
mInfo.height = mHeight;
|
mInfo.height = mHeight;
|
||||||
mInfo.refreshRate = mRefreshRate;
|
mInfo.refreshRate = mRefreshRate;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.AtomicFile;
|
import android.util.AtomicFile;
|
||||||
@@ -41,7 +40,6 @@ import java.util.HashMap;
|
|||||||
public class DisplaySettings {
|
public class DisplaySettings {
|
||||||
private static final String TAG = WindowManagerService.TAG;
|
private static final String TAG = WindowManagerService.TAG;
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
private final AtomicFile mFile;
|
private final AtomicFile mFile;
|
||||||
private final HashMap<String, Entry> mEntries = new HashMap<String, Entry>();
|
private final HashMap<String, Entry> mEntries = new HashMap<String, Entry>();
|
||||||
|
|
||||||
@@ -57,15 +55,19 @@ public class DisplaySettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplaySettings(Context context) {
|
public DisplaySettings() {
|
||||||
mContext = context;
|
|
||||||
File dataDir = Environment.getDataDirectory();
|
File dataDir = Environment.getDataDirectory();
|
||||||
File systemDir = new File(dataDir, "system");
|
File systemDir = new File(dataDir, "system");
|
||||||
mFile = new AtomicFile(new File(systemDir, "display_settings.xml"));
|
mFile = new AtomicFile(new File(systemDir, "display_settings.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getOverscanLocked(String name, Rect outRect) {
|
public void getOverscanLocked(String name, String uniqueId, Rect outRect) {
|
||||||
Entry entry = mEntries.get(name);
|
// Try to get the entry with the unique if possible.
|
||||||
|
// Else, fall back on the display name.
|
||||||
|
Entry entry;
|
||||||
|
if (uniqueId == null || (entry = mEntries.get(uniqueId)) == null) {
|
||||||
|
entry = mEntries.get(name);
|
||||||
|
}
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
outRect.left = entry.overscanLeft;
|
outRect.left = entry.overscanLeft;
|
||||||
outRect.top = entry.overscanTop;
|
outRect.top = entry.overscanTop;
|
||||||
@@ -110,7 +112,7 @@ public class DisplaySettings {
|
|||||||
int type;
|
int type;
|
||||||
while ((type = parser.next()) != XmlPullParser.START_TAG
|
while ((type = parser.next()) != XmlPullParser.START_TAG
|
||||||
&& type != XmlPullParser.END_DOCUMENT) {
|
&& type != XmlPullParser.END_DOCUMENT) {
|
||||||
;
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != XmlPullParser.START_TAG) {
|
if (type != XmlPullParser.START_TAG) {
|
||||||
|
|||||||
@@ -825,7 +825,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
com.android.internal.R.bool.config_hasPermanentDpad);
|
com.android.internal.R.bool.config_hasPermanentDpad);
|
||||||
mInputManager = inputManager; // Must be before createDisplayContentLocked.
|
mInputManager = inputManager; // Must be before createDisplayContentLocked.
|
||||||
mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
|
mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
|
||||||
mDisplaySettings = new DisplaySettings(context);
|
mDisplaySettings = new DisplaySettings();
|
||||||
mDisplaySettings.readSettingsLocked();
|
mDisplaySettings.readSettingsLocked();
|
||||||
|
|
||||||
LocalServices.addService(WindowManagerPolicy.class, mPolicy);
|
LocalServices.addService(WindowManagerPolicy.class, mPolicy);
|
||||||
@@ -8476,7 +8476,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
displayInfo.overscanBottom = bottom;
|
displayInfo.overscanBottom = bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDisplaySettings.setOverscanLocked(displayInfo.name, left, top, right, bottom);
|
mDisplaySettings.setOverscanLocked(displayInfo.uniqueId, left, top, right, bottom);
|
||||||
mDisplaySettings.writeSettingsLocked();
|
mDisplaySettings.writeSettingsLocked();
|
||||||
|
|
||||||
reconfigureDisplayLocked(displayContent);
|
reconfigureDisplayLocked(displayContent);
|
||||||
@@ -11458,7 +11458,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
DisplayInfo displayInfo = displayContent.getDisplayInfo();
|
DisplayInfo displayInfo = displayContent.getDisplayInfo();
|
||||||
final Rect rect = new Rect();
|
final Rect rect = new Rect();
|
||||||
mDisplaySettings.getOverscanLocked(displayInfo.name, rect);
|
mDisplaySettings.getOverscanLocked(displayInfo.name, displayInfo.uniqueId, rect);
|
||||||
synchronized (displayContent.mDisplaySizeLock) {
|
synchronized (displayContent.mDisplaySizeLock) {
|
||||||
displayInfo.overscanLeft = rect.left;
|
displayInfo.overscanLeft = rect.left;
|
||||||
displayInfo.overscanTop = rect.top;
|
displayInfo.overscanTop = rect.top;
|
||||||
|
|||||||
Reference in New Issue
Block a user