diff --git a/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java b/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java index 323f84aef8ec9e89972610b9094f067f4fbb2824..678830c73ddf50382f7cc3ee7e0bce52928350f2 100644 --- a/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java +++ b/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java @@ -101,12 +101,8 @@ public class CloudPhoneImpl implements ICloudPhone { private Activity mActivity; private ViewGroup mViewGroup; private SurfaceView mSurfaceView = null; - private int mDisplayWidth = 9; + private int mDisplayWidth = 0; private int mDisplayHeight = 0; - private int mInputWidth = 720; - private int mInputHeight = 1280; - private float mInputXScale; - private float mInputYScale; private int mCurrentState; private DisplayMode mDisplayMode = DISPLAY_MODE_FILL; private boolean mServiceConnect = false; @@ -354,16 +350,10 @@ public class CloudPhoneImpl implements ICloudPhone { @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - CASLog.i(TAG, "width = " + width + " height = " + height); - mDisplayWidth = width; - mDisplayHeight = height; - if (mDisplayWidth > mDisplayHeight) { - mInputYScale = (float) mDisplayWidth / (float) mInputHeight; - mInputXScale = (float) mDisplayHeight / (float) mInputWidth; - } else { - mInputXScale = (float) mDisplayWidth / (float) mInputWidth; - mInputYScale = (float) mDisplayHeight / (float) mInputHeight; - } + + mDisplayWidth = Math.min(width, height); + mDisplayHeight = Math.max(width, height); + CASLog.i(TAG, "width = " + mDisplayWidth + " height = " + mDisplayHeight); if (!mIsNewCreated) { return; @@ -660,7 +650,7 @@ public class CloudPhoneImpl implements ICloudPhone { private boolean sendTouchEvent(int id, int action, final int x1, final int y1, final int pressure, long time) { int orientation = 0; - int new_orientation = 0; + int newOrientation = 0; if (mActivity != null) { try { orientation = mActivity.getRequestedOrientation(); @@ -673,24 +663,29 @@ public class CloudPhoneImpl implements ICloudPhone { switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: - new_orientation = 0; + newOrientation = 0; break; case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: - new_orientation = 1; + newOrientation = 1; break; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: - new_orientation = 2; + newOrientation = 2; break; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: - new_orientation = 3; + newOrientation = 3; break; default: CASLog.i(TAG, "invalid directation " + orientation); - break; + return false; } - return mCASClient.sendTouchEvent(id, action, x1, y1, pressure, time, new_orientation, mDisplayHeight, mDisplayWidth); + int x = x1, y = y1; + if (newOrientation == 1 || newOrientation == 3) { + x = x1 * mDisplayWidth / mDisplayHeight; + y = y1 * mDisplayHeight / mDisplayWidth; + } + return mCASClient.sendTouchEvent(id, action, x, y, pressure, time, newOrientation, mDisplayHeight, mDisplayWidth); } public static class JNIState {