DO NOT MERGE Transform UDFPS touch coordinates to portrait mode

Bug: 215810673
Test: manual on device
Change-Id: Ia88a3e2e3fcba4f503cb4f8b746653eae9ad9d25
This commit is contained in:
Kris Chen
2022-01-24 22:37:44 +08:00
committed by KRIS CHEN
parent 99f9addc90
commit a9e20f2f23

View File

@@ -480,8 +480,33 @@ public class UdfpsController implements DozeReceiver {
final long sinceLastLog = mSystemClock.elapsedRealtime() - mTouchLogTime; final long sinceLastLog = mSystemClock.elapsedRealtime() - mTouchLogTime;
if (!isIlluminationRequested && !mGoodCaptureReceived && if (!isIlluminationRequested && !mGoodCaptureReceived &&
!exceedsVelocityThreshold) { !exceedsVelocityThreshold) {
onFingerDown((int) event.getRawX(), (int) event.getRawY(), minor, final int rawX = (int) event.getRawX();
major); final int rawY = (int) event.getRawY();
// Default coordinates assume portrait mode.
int x = rawX;
int y = rawY;
// Gets the size based on the current rotation of the display.
Point p = new Point();
mContext.getDisplay().getRealSize(p);
// Transform x, y to portrait mode if the device is in landscape mode.
switch (mContext.getDisplay().getRotation()) {
case Surface.ROTATION_90:
x = p.y - rawY;
y = rawX;
break;
case Surface.ROTATION_270:
x = rawY;
y = p.x - rawX;
break;
default:
// Do nothing to stay in portrait mode.
}
onFingerDown(x, y, minor, major);
Log.v(TAG, "onTouch | finger down: " + touchInfo); Log.v(TAG, "onTouch | finger down: " + touchInfo);
mTouchLogTime = mSystemClock.elapsedRealtime(); mTouchLogTime = mSystemClock.elapsedRealtime();
mPowerManager.userActivity(mSystemClock.uptimeMillis(), mPowerManager.userActivity(mSystemClock.uptimeMillis(),