am 9ba2a188: Merge changes I4ad08873,If0562677,I5fe6ba32 into jb-mr1-dev
* commit '9ba2a188919e6e5bf8c042b26527fc090de677ef': Don't auto-discover peers until scan requested. Use wfdInfo to filter available sinks. Allow adb shell am display-size to use bigger sizes.
This commit is contained in:
@@ -1187,32 +1187,26 @@ public class Am {
|
||||
|
||||
private void runDisplaySize() throws Exception {
|
||||
String size = nextArgRequired();
|
||||
int m, n;
|
||||
int w, h;
|
||||
if ("reset".equals(size)) {
|
||||
m = n = -1;
|
||||
w = h = -1;
|
||||
} else {
|
||||
int div = size.indexOf('x');
|
||||
if (div <= 0 || div >= (size.length()-1)) {
|
||||
System.err.println("Error: bad size " + size);
|
||||
return;
|
||||
}
|
||||
String mstr = size.substring(0, div);
|
||||
String nstr = size.substring(div+1);
|
||||
String wstr = size.substring(0, div);
|
||||
String hstr = size.substring(div+1);
|
||||
try {
|
||||
m = Integer.parseInt(mstr);
|
||||
n = Integer.parseInt(nstr);
|
||||
w = Integer.parseInt(wstr);
|
||||
h = Integer.parseInt(hstr);
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Error: bad number " + e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m < n) {
|
||||
int tmp = m;
|
||||
m = n;
|
||||
n = tmp;
|
||||
}
|
||||
|
||||
IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
|
||||
Context.WINDOW_SERVICE));
|
||||
if (wm == null) {
|
||||
@@ -1221,9 +1215,9 @@ public class Am {
|
||||
}
|
||||
|
||||
try {
|
||||
if (m >= 0 && n >= 0) {
|
||||
if (w >= 0 && h >= 0) {
|
||||
// TODO(multidisplay): For now Configuration only applies to main screen.
|
||||
wm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, m, n);
|
||||
wm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, w, h);
|
||||
} else {
|
||||
wm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
|
||||
}
|
||||
@@ -1444,7 +1438,7 @@ public class Am {
|
||||
" am clear-debug-app\n" +
|
||||
" am monitor [--gdb <port>]\n" +
|
||||
" am screen-compat [on|off] <PACKAGE>\n" +
|
||||
" am display-size [reset|MxN]\n" +
|
||||
" am display-size [reset|WxH]\n" +
|
||||
" am display-density [reset|DENSITY]\n" +
|
||||
" am to-uri [INTENT]\n" +
|
||||
" am to-intent-uri [INTENT]\n" +
|
||||
|
||||
@@ -59,7 +59,7 @@ interface IWindowManager
|
||||
in IInputContext inputContext);
|
||||
boolean inputMethodClientHasFocus(IInputMethodClient client);
|
||||
|
||||
void setForcedDisplaySize(int displayId, int longDimen, int shortDimen);
|
||||
void setForcedDisplaySize(int displayId, int width, int height);
|
||||
void clearForcedDisplaySize(int displayId);
|
||||
void setForcedDisplayDensity(int displayId, int density);
|
||||
void clearForcedDisplayDensity(int displayId);
|
||||
|
||||
@@ -179,7 +179,6 @@ final class WifiDisplayController implements DumpUtils.Dump {
|
||||
if (mWfdEnabling) {
|
||||
mWfdEnabling = false;
|
||||
setWfdEnabled(true);
|
||||
discoverPeers();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,14 +492,8 @@ final class WifiDisplayController implements DumpUtils.Dump {
|
||||
return; // done
|
||||
}
|
||||
|
||||
int port = DEFAULT_CONTROL_PORT;
|
||||
if (mConnectedDevice.deviceName.startsWith("DIRECT-")
|
||||
&& mConnectedDevice.deviceName.endsWith("Broadcom")) {
|
||||
// These dongles ignore the port we broadcast in our WFD IE.
|
||||
port = 8554;
|
||||
}
|
||||
|
||||
final WifiDisplay display = createWifiDisplay(mConnectedDevice);
|
||||
final int port = getPortNumber(mConnectedDevice);
|
||||
final String iface = addr.getHostAddress() + ":" + port;
|
||||
|
||||
mPublishedDevice = mConnectedDevice;
|
||||
@@ -517,9 +510,7 @@ final class WifiDisplayController implements DumpUtils.Dump {
|
||||
if (mWifiP2pEnabled != enabled) {
|
||||
mWifiP2pEnabled = enabled;
|
||||
if (enabled) {
|
||||
if (mWfdEnabled) {
|
||||
discoverPeers();
|
||||
} else {
|
||||
if (!mWfdEnabled) {
|
||||
enableWfd();
|
||||
}
|
||||
} else {
|
||||
@@ -647,12 +638,24 @@ final class WifiDisplayController implements DumpUtils.Dump {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int getPortNumber(WifiP2pDevice device) {
|
||||
if (device.deviceName.startsWith("DIRECT-")
|
||||
&& device.deviceName.endsWith("Broadcom")) {
|
||||
// These dongles ignore the port we broadcast in our WFD IE.
|
||||
return 8554;
|
||||
}
|
||||
return DEFAULT_CONTROL_PORT;
|
||||
}
|
||||
|
||||
private static boolean isWifiDisplay(WifiP2pDevice device) {
|
||||
// FIXME: the wfdInfo API doesn't work yet
|
||||
return device.deviceName.startsWith("DWD-")
|
||||
|| device.deviceName.startsWith("DIRECT-")
|
||||
|| device.deviceName.startsWith("CAVM-");
|
||||
//device.wfdInfo != null && device.wfdInfo.isWfdEnabled();
|
||||
return device.wfdInfo != null
|
||||
&& device.wfdInfo.isWfdEnabled()
|
||||
&& isPrimarySinkDeviceType(device.wfdInfo.getDeviceType());
|
||||
}
|
||||
|
||||
private static boolean isPrimarySinkDeviceType(int deviceType) {
|
||||
return deviceType == WifiP2pWfdInfo.PRIMARY_SINK
|
||||
|| deviceType == WifiP2pWfdInfo.SOURCE_OR_PRIMARY_SINK;
|
||||
}
|
||||
|
||||
private static String describeWifiP2pDevice(WifiP2pDevice device) {
|
||||
|
||||
@@ -7831,24 +7831,22 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
public void setForcedDisplaySize(int displayId, int longDimen, int shortDimen) {
|
||||
public void setForcedDisplaySize(int displayId, int width, int height) {
|
||||
synchronized(mWindowMap) {
|
||||
// Set some sort of reasonable bounds on the size of the display that we
|
||||
// will try to emulate.
|
||||
final int MIN_WIDTH = 200;
|
||||
final int MIN_HEIGHT = 200;
|
||||
final int MAX_SCALE = 2;
|
||||
final DisplayContent displayContent = getDisplayContent(displayId);
|
||||
int width, height;
|
||||
if (displayContent.mInitialDisplayWidth < displayContent.mInitialDisplayHeight) {
|
||||
width = shortDimen < displayContent.mInitialDisplayWidth
|
||||
? shortDimen : displayContent.mInitialDisplayWidth;
|
||||
height = longDimen < displayContent.mInitialDisplayHeight
|
||||
? longDimen : displayContent.mInitialDisplayHeight;
|
||||
} else {
|
||||
width = longDimen < displayContent.mInitialDisplayWidth
|
||||
? longDimen : displayContent.mInitialDisplayWidth;
|
||||
height = shortDimen < displayContent.mInitialDisplayHeight
|
||||
? shortDimen : displayContent.mInitialDisplayHeight;
|
||||
}
|
||||
|
||||
width = Math.min(Math.max(width, MIN_WIDTH),
|
||||
displayContent.mInitialDisplayWidth * MAX_SCALE);
|
||||
height = Math.min(Math.max(height, MIN_HEIGHT),
|
||||
displayContent.mInitialDisplayHeight * MAX_SCALE);
|
||||
setForcedDisplaySizeLocked(displayContent, width, height);
|
||||
Settings.Secure.putString(mContext.getContentResolver(),
|
||||
Settings.Secure.DISPLAY_SIZE_FORCED, width + "," + height);
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
Settings.Global.DISPLAY_SIZE_FORCED, width + "," + height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7895,8 +7893,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
private void readForcedDisplaySizeAndDensityLocked(final DisplayContent displayContent) {
|
||||
boolean changed = false;
|
||||
final String sizeStr = Settings.Secure.getString(mContext.getContentResolver(),
|
||||
Settings.Secure.DISPLAY_SIZE_FORCED);
|
||||
final String sizeStr = Settings.Global.getString(mContext.getContentResolver(),
|
||||
Settings.Global.DISPLAY_SIZE_FORCED);
|
||||
if (sizeStr != null && sizeStr.length() > 0) {
|
||||
final int pos = sizeStr.indexOf(',');
|
||||
if (pos > 0 && sizeStr.lastIndexOf(',') == pos) {
|
||||
@@ -7917,8 +7915,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
}
|
||||
}
|
||||
final String densityStr = Settings.Secure.getString(mContext.getContentResolver(),
|
||||
Settings.Secure.DISPLAY_DENSITY_FORCED);
|
||||
final String densityStr = Settings.Global.getString(mContext.getContentResolver(),
|
||||
Settings.Global.DISPLAY_DENSITY_FORCED);
|
||||
if (densityStr != null && densityStr.length() > 0) {
|
||||
int density;
|
||||
try {
|
||||
@@ -7953,8 +7951,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
final DisplayContent displayContent = getDisplayContent(displayId);
|
||||
setForcedDisplaySizeLocked(displayContent, displayContent.mInitialDisplayWidth,
|
||||
displayContent.mInitialDisplayHeight);
|
||||
Settings.Secure.putString(mContext.getContentResolver(),
|
||||
Settings.Secure.DISPLAY_SIZE_FORCED, "");
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
Settings.Global.DISPLAY_SIZE_FORCED, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7962,8 +7960,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
synchronized(mWindowMap) {
|
||||
final DisplayContent displayContent = getDisplayContent(displayId);
|
||||
setForcedDisplayDensityLocked(displayContent, density);
|
||||
Settings.Secure.putString(mContext.getContentResolver(),
|
||||
Settings.Secure.DISPLAY_DENSITY_FORCED, Integer.toString(density));
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
Settings.Global.DISPLAY_DENSITY_FORCED, Integer.toString(density));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user