Merge "Generate ACTION_CANCEL event when screen turned off by proximity sensor." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aaec0d4ac3
@@ -49,6 +49,9 @@ public final class DisplayViewport {
|
|||||||
// True if this viewport is valid.
|
// True if this viewport is valid.
|
||||||
public boolean valid;
|
public boolean valid;
|
||||||
|
|
||||||
|
// True if this viewport is active.
|
||||||
|
public boolean isActive;
|
||||||
|
|
||||||
// The logical display id.
|
// The logical display id.
|
||||||
public int displayId;
|
public int displayId;
|
||||||
|
|
||||||
@@ -79,6 +82,7 @@ public final class DisplayViewport {
|
|||||||
|
|
||||||
public void copyFrom(DisplayViewport viewport) {
|
public void copyFrom(DisplayViewport viewport) {
|
||||||
valid = viewport.valid;
|
valid = viewport.valid;
|
||||||
|
isActive = viewport.isActive;
|
||||||
displayId = viewport.displayId;
|
displayId = viewport.displayId;
|
||||||
orientation = viewport.orientation;
|
orientation = viewport.orientation;
|
||||||
logicalFrame.set(viewport.logicalFrame);
|
logicalFrame.set(viewport.logicalFrame);
|
||||||
@@ -111,6 +115,7 @@ public final class DisplayViewport {
|
|||||||
|
|
||||||
DisplayViewport other = (DisplayViewport) o;
|
DisplayViewport other = (DisplayViewport) o;
|
||||||
return valid == other.valid
|
return valid == other.valid
|
||||||
|
&& isActive == other.isActive
|
||||||
&& displayId == other.displayId
|
&& displayId == other.displayId
|
||||||
&& orientation == other.orientation
|
&& orientation == other.orientation
|
||||||
&& logicalFrame.equals(other.logicalFrame)
|
&& logicalFrame.equals(other.logicalFrame)
|
||||||
@@ -127,6 +132,7 @@ public final class DisplayViewport {
|
|||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result += prime * result + (valid ? 1 : 0);
|
result += prime * result + (valid ? 1 : 0);
|
||||||
|
result += prime * result + (isActive ? 1 : 0);
|
||||||
result += prime * result + displayId;
|
result += prime * result + displayId;
|
||||||
result += prime * result + orientation;
|
result += prime * result + orientation;
|
||||||
result += prime * result + logicalFrame.hashCode();
|
result += prime * result + logicalFrame.hashCode();
|
||||||
@@ -147,6 +153,7 @@ public final class DisplayViewport {
|
|||||||
final Integer port = physicalPort == null ? null : Byte.toUnsignedInt(physicalPort);
|
final Integer port = physicalPort == null ? null : Byte.toUnsignedInt(physicalPort);
|
||||||
return "DisplayViewport{type=" + typeToString(type)
|
return "DisplayViewport{type=" + typeToString(type)
|
||||||
+ ", valid=" + valid
|
+ ", valid=" + valid
|
||||||
|
+ ", isActive=" + isActive
|
||||||
+ ", displayId=" + displayId
|
+ ", displayId=" + displayId
|
||||||
+ ", uniqueId='" + uniqueId + "'"
|
+ ", uniqueId='" + uniqueId + "'"
|
||||||
+ ", physicalPort=" + port
|
+ ", physicalPort=" + port
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ static struct {
|
|||||||
jclass clazz;
|
jclass clazz;
|
||||||
|
|
||||||
jfieldID displayId;
|
jfieldID displayId;
|
||||||
|
jfieldID isActive;
|
||||||
jfieldID orientation;
|
jfieldID orientation;
|
||||||
jfieldID logicalFrame;
|
jfieldID logicalFrame;
|
||||||
jfieldID physicalFrame;
|
jfieldID physicalFrame;
|
||||||
@@ -59,6 +60,7 @@ status_t android_hardware_display_DisplayViewport_toNative(JNIEnv* env, jobject
|
|||||||
static const jmethodID byteValue = env->GetMethodID(byteClass, "byteValue", "()B");
|
static const jmethodID byteValue = env->GetMethodID(byteClass, "byteValue", "()B");
|
||||||
|
|
||||||
viewport->displayId = env->GetIntField(viewportObj, gDisplayViewportClassInfo.displayId);
|
viewport->displayId = env->GetIntField(viewportObj, gDisplayViewportClassInfo.displayId);
|
||||||
|
viewport->isActive = env->GetBooleanField(viewportObj, gDisplayViewportClassInfo.isActive);
|
||||||
viewport->orientation = env->GetIntField(viewportObj, gDisplayViewportClassInfo.orientation);
|
viewport->orientation = env->GetIntField(viewportObj, gDisplayViewportClassInfo.orientation);
|
||||||
viewport->deviceWidth = env->GetIntField(viewportObj, gDisplayViewportClassInfo.deviceWidth);
|
viewport->deviceWidth = env->GetIntField(viewportObj, gDisplayViewportClassInfo.deviceWidth);
|
||||||
viewport->deviceHeight = env->GetIntField(viewportObj, gDisplayViewportClassInfo.deviceHeight);
|
viewport->deviceHeight = env->GetIntField(viewportObj, gDisplayViewportClassInfo.deviceHeight);
|
||||||
@@ -104,6 +106,9 @@ int register_android_hardware_display_DisplayViewport(JNIEnv* env) {
|
|||||||
gDisplayViewportClassInfo.displayId = GetFieldIDOrDie(env,
|
gDisplayViewportClassInfo.displayId = GetFieldIDOrDie(env,
|
||||||
gDisplayViewportClassInfo.clazz, "displayId", "I");
|
gDisplayViewportClassInfo.clazz, "displayId", "I");
|
||||||
|
|
||||||
|
gDisplayViewportClassInfo.isActive =
|
||||||
|
GetFieldIDOrDie(env, gDisplayViewportClassInfo.clazz, "isActive", "Z");
|
||||||
|
|
||||||
gDisplayViewportClassInfo.orientation = GetFieldIDOrDie(env,
|
gDisplayViewportClassInfo.orientation = GetFieldIDOrDie(env,
|
||||||
gDisplayViewportClassInfo.clazz, "orientation", "I");
|
gDisplayViewportClassInfo.clazz, "orientation", "I");
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ import java.io.PrintWriter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -971,6 +972,18 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
if (diff == DisplayDeviceInfo.DIFF_STATE) {
|
if (diff == DisplayDeviceInfo.DIFF_STATE) {
|
||||||
Slog.i(TAG, "Display device changed state: \"" + info.name
|
Slog.i(TAG, "Display device changed state: \"" + info.name
|
||||||
+ "\", " + Display.stateToString(info.state));
|
+ "\", " + Display.stateToString(info.state));
|
||||||
|
final Optional<Integer> viewportType = getViewportType(info);
|
||||||
|
if (viewportType.isPresent()) {
|
||||||
|
for (DisplayViewport d : mViewports) {
|
||||||
|
if (d.type == viewportType.get() && info.uniqueId.equals(d.uniqueId)) {
|
||||||
|
// Update display view port power state
|
||||||
|
d.isActive = Display.isActiveState(info.state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mInputManagerInternal != null) {
|
||||||
|
mHandler.sendEmptyMessage(MSG_UPDATE_VIEWPORT);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (diff != 0) {
|
} else if (diff != 0) {
|
||||||
Slog.i(TAG, "Display device changed: " + info);
|
Slog.i(TAG, "Display device changed: " + info);
|
||||||
}
|
}
|
||||||
@@ -1507,6 +1520,23 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
mViewports.clear();
|
mViewports.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Optional<Integer> getViewportType(DisplayDeviceInfo info) {
|
||||||
|
// Get the corresponding viewport type.
|
||||||
|
if ((info.flags & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) {
|
||||||
|
return Optional.of(VIEWPORT_INTERNAL);
|
||||||
|
} else if (info.touch == DisplayDeviceInfo.TOUCH_EXTERNAL) {
|
||||||
|
return Optional.of(VIEWPORT_EXTERNAL);
|
||||||
|
} else if (info.touch == DisplayDeviceInfo.TOUCH_VIRTUAL
|
||||||
|
&& !TextUtils.isEmpty(info.uniqueId)) {
|
||||||
|
return Optional.of(VIEWPORT_VIRTUAL);
|
||||||
|
} else {
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.i(TAG, "Display " + info + " does not support input device matching.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
private void configureDisplayLocked(SurfaceControl.Transaction t, DisplayDevice device) {
|
private void configureDisplayLocked(SurfaceControl.Transaction t, DisplayDevice device) {
|
||||||
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
|
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
|
||||||
final boolean ownContent = (info.flags & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0;
|
final boolean ownContent = (info.flags & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0;
|
||||||
@@ -1533,21 +1563,10 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
display.configureDisplayLocked(t, device, info.state == Display.STATE_OFF);
|
display.configureDisplayLocked(t, device, info.state == Display.STATE_OFF);
|
||||||
final int viewportType;
|
final Optional<Integer> viewportType = getViewportType(info);
|
||||||
// Update the corresponding viewport.
|
if (viewportType.isPresent()) {
|
||||||
if ((info.flags & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) {
|
populateViewportLocked(viewportType.get(), display.getDisplayIdLocked(), device, info);
|
||||||
viewportType = VIEWPORT_INTERNAL;
|
|
||||||
} else if (info.touch == DisplayDeviceInfo.TOUCH_EXTERNAL) {
|
|
||||||
viewportType = VIEWPORT_EXTERNAL;
|
|
||||||
} else if (info.touch == DisplayDeviceInfo.TOUCH_VIRTUAL
|
|
||||||
&& !TextUtils.isEmpty(info.uniqueId)) {
|
|
||||||
viewportType = VIEWPORT_VIRTUAL;
|
|
||||||
} else {
|
|
||||||
Slog.i(TAG, "Display " + info + " does not support input device matching.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
populateViewportLocked(viewportType, display.getDisplayIdLocked(), device, info.uniqueId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1587,12 +1606,13 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
return viewport;
|
return viewport;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateViewportLocked(int viewportType,
|
private void populateViewportLocked(int viewportType, int displayId, DisplayDevice device,
|
||||||
int displayId, DisplayDevice device, String uniqueId) {
|
DisplayDeviceInfo info) {
|
||||||
final DisplayViewport viewport = getViewportLocked(viewportType, uniqueId);
|
final DisplayViewport viewport = getViewportLocked(viewportType, info.uniqueId);
|
||||||
device.populateViewportLocked(viewport);
|
device.populateViewportLocked(viewport);
|
||||||
viewport.valid = true;
|
viewport.valid = true;
|
||||||
viewport.displayId = displayId;
|
viewport.displayId = displayId;
|
||||||
|
viewport.isActive = Display.isActiveState(info.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LogicalDisplay findLogicalDisplayForDeviceLocked(DisplayDevice device) {
|
private LogicalDisplay findLogicalDisplayForDeviceLocked(DisplayDevice device) {
|
||||||
|
|||||||
@@ -403,7 +403,8 @@ void NativeInputManager::setDisplayViewports(JNIEnv* env, jobjectArray viewportO
|
|||||||
|
|
||||||
DisplayViewport viewport;
|
DisplayViewport viewport;
|
||||||
android_hardware_display_DisplayViewport_toNative(env, viewportObj, &viewport);
|
android_hardware_display_DisplayViewport_toNative(env, viewportObj, &viewport);
|
||||||
ALOGI("Viewport [%d] to add: %s", (int) i, viewport.uniqueId.c_str());
|
ALOGI("Viewport [%d] to add: %s, isActive: %s", (int)i, viewport.uniqueId.c_str(),
|
||||||
|
toString(viewport.isActive));
|
||||||
viewports.push_back(viewport);
|
viewports.push_back(viewport);
|
||||||
|
|
||||||
env->DeleteLocalRef(viewportObj);
|
env->DeleteLocalRef(viewportObj);
|
||||||
|
|||||||
Reference in New Issue
Block a user