Loading core/java/android/view/Display.java +9 −0 Original line number Diff line number Diff line Loading @@ -390,6 +390,15 @@ public class Display { return 720; } /** * If the display is mirrored to an external HDMI display, returns the * rotation of that display relative to its natural orientation. * @hide */ public int getExternalRotation() { return Surface.ROTATION_0; } /** * Gets display metrics based on an explicit assumed display size. * @hide Loading services/java/com/android/server/input/InputManagerService.java +6 −4 Original line number Diff line number Diff line Loading @@ -140,7 +140,8 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. private static native void nativeStart(int ptr); private static native void nativeSetDisplaySize(int ptr, int displayId, int width, int height, int externalWidth, int externalHeight); private static native void nativeSetDisplayOrientation(int ptr, int displayId, int rotation); private static native void nativeSetDisplayOrientation(int ptr, int displayId, int rotation, int externalRotation); private static native int nativeGetScanCodeState(int ptr, int deviceId, int sourceMask, int scanCode); Loading Loading @@ -287,15 +288,16 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. nativeSetDisplaySize(mPtr, displayId, width, height, externalWidth, externalHeight); } public void setDisplayOrientation(int displayId, int rotation) { public void setDisplayOrientation(int displayId, int rotation, int externalRotation) { if (rotation < Surface.ROTATION_0 || rotation > Surface.ROTATION_270) { throw new IllegalArgumentException("Invalid rotation."); } if (DEBUG) { Slog.d(TAG, "Setting display #" + displayId + " orientation to " + rotation); Slog.d(TAG, "Setting display #" + displayId + " orientation to rotation " + rotation + " external rotation " + externalRotation); } nativeSetDisplayOrientation(mPtr, displayId, rotation); nativeSetDisplayOrientation(mPtr, displayId, rotation, externalRotation); } /** Loading services/java/com/android/server/wm/WindowManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -5580,7 +5580,8 @@ public class WindowManagerService extends IWindowManager.Stub mWaitingForConfig = true; mLayoutNeeded = true; startFreezingDisplayLocked(inTransaction); mInputManager.setDisplayOrientation(0, rotation); mInputManager.setDisplayOrientation(0, rotation, mDisplay != null ? mDisplay.getExternalRotation() : Surface.ROTATION_0); // We need to update our screen size information to match the new // rotation. Note that this is redundant with the later call to Loading Loading @@ -6606,6 +6607,8 @@ public class WindowManagerService extends IWindowManager.Stub mInputManager.setDisplaySize(Display.DEFAULT_DISPLAY, mDisplay.getRawWidth(), mDisplay.getRawHeight(), mDisplay.getRawExternalWidth(), mDisplay.getRawExternalHeight()); mInputManager.setDisplayOrientation(Display.DEFAULT_DISPLAY, mDisplay.getRotation(), mDisplay.getExternalRotation()); mPolicy.setInitialDisplaySize(mDisplay, mInitialDisplayWidth, mInitialDisplayHeight); } Loading services/jni/com_android_server_input_InputManagerService.cpp +16 −8 Original line number Diff line number Diff line Loading @@ -166,7 +166,7 @@ public: void setDisplaySize(int32_t displayId, int32_t width, int32_t height, int32_t externalWidth, int32_t externalHeight); void setDisplayOrientation(int32_t displayId, int32_t orientation); void setDisplayOrientation(int32_t displayId, int32_t orientation, int32_t externalOrientation); status_t registerInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel, const sp<InputWindowHandle>& inputWindowHandle, bool monitor); Loading Loading @@ -224,8 +224,9 @@ private: struct Locked { // Display size information. int32_t displayWidth, displayHeight; // -1 when not initialized int32_t displayExternalWidth, displayExternalHeight; // -1 when not initialized int32_t displayOrientation; int32_t displayExternalWidth, displayExternalHeight; // -1 when not initialized int32_t displayExternalOrientation; // System UI visibility. int32_t systemUiVisibility; Loading Loading @@ -275,9 +276,10 @@ NativeInputManager::NativeInputManager(jobject contextObj, AutoMutex _l(mLock); mLocked.displayWidth = -1; mLocked.displayHeight = -1; mLocked.displayOrientation = DISPLAY_ORIENTATION_0; mLocked.displayExternalWidth = -1; mLocked.displayExternalHeight = -1; mLocked.displayOrientation = DISPLAY_ORIENTATION_0; mLocked.displayExternalOrientation = DISPLAY_ORIENTATION_0; mLocked.systemUiVisibility = ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE; mLocked.pointerSpeed = 0; Loading Loading @@ -345,7 +347,8 @@ void NativeInputManager::setDisplaySize(int32_t displayId, int32_t width, int32_ } } void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orientation) { void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orientation, int32_t externalOrientation) { bool changed = false; if (displayId == 0) { AutoMutex _l(mLock); Loading @@ -359,6 +362,11 @@ void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orient controller->setDisplayOrientation(orientation); } } if (mLocked.displayExternalOrientation != externalOrientation) { changed = true; mLocked.displayExternalOrientation = externalOrientation; } } if (changed) { Loading Loading @@ -444,7 +452,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon mLocked.displayWidth, mLocked.displayHeight, mLocked.displayOrientation); outConfig->setDisplayInfo(0, true /*external*/, mLocked.displayExternalWidth, mLocked.displayExternalHeight, mLocked.displayOrientation); mLocked.displayExternalOrientation); } // release lock } Loading Loading @@ -1041,10 +1049,10 @@ static void nativeSetDisplaySize(JNIEnv* env, jclass clazz, jint ptr, } static void nativeSetDisplayOrientation(JNIEnv* env, jclass clazz, jint ptr, jint displayId, jint orientation) { jint ptr, jint displayId, jint orientation, jint externalOrientation) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setDisplayOrientation(displayId, orientation); im->setDisplayOrientation(displayId, orientation, externalOrientation); } static jint nativeGetScanCodeState(JNIEnv* env, jclass clazz, Loading Loading @@ -1327,7 +1335,7 @@ static JNINativeMethod gInputManagerMethods[] = { (void*) nativeStart }, { "nativeSetDisplaySize", "(IIIIII)V", (void*) nativeSetDisplaySize }, { "nativeSetDisplayOrientation", "(III)V", { "nativeSetDisplayOrientation", "(IIII)V", (void*) nativeSetDisplayOrientation }, { "nativeGetScanCodeState", "(IIII)I", (void*) nativeGetScanCodeState }, Loading Loading
core/java/android/view/Display.java +9 −0 Original line number Diff line number Diff line Loading @@ -390,6 +390,15 @@ public class Display { return 720; } /** * If the display is mirrored to an external HDMI display, returns the * rotation of that display relative to its natural orientation. * @hide */ public int getExternalRotation() { return Surface.ROTATION_0; } /** * Gets display metrics based on an explicit assumed display size. * @hide Loading
services/java/com/android/server/input/InputManagerService.java +6 −4 Original line number Diff line number Diff line Loading @@ -140,7 +140,8 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. private static native void nativeStart(int ptr); private static native void nativeSetDisplaySize(int ptr, int displayId, int width, int height, int externalWidth, int externalHeight); private static native void nativeSetDisplayOrientation(int ptr, int displayId, int rotation); private static native void nativeSetDisplayOrientation(int ptr, int displayId, int rotation, int externalRotation); private static native int nativeGetScanCodeState(int ptr, int deviceId, int sourceMask, int scanCode); Loading Loading @@ -287,15 +288,16 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. nativeSetDisplaySize(mPtr, displayId, width, height, externalWidth, externalHeight); } public void setDisplayOrientation(int displayId, int rotation) { public void setDisplayOrientation(int displayId, int rotation, int externalRotation) { if (rotation < Surface.ROTATION_0 || rotation > Surface.ROTATION_270) { throw new IllegalArgumentException("Invalid rotation."); } if (DEBUG) { Slog.d(TAG, "Setting display #" + displayId + " orientation to " + rotation); Slog.d(TAG, "Setting display #" + displayId + " orientation to rotation " + rotation + " external rotation " + externalRotation); } nativeSetDisplayOrientation(mPtr, displayId, rotation); nativeSetDisplayOrientation(mPtr, displayId, rotation, externalRotation); } /** Loading
services/java/com/android/server/wm/WindowManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -5580,7 +5580,8 @@ public class WindowManagerService extends IWindowManager.Stub mWaitingForConfig = true; mLayoutNeeded = true; startFreezingDisplayLocked(inTransaction); mInputManager.setDisplayOrientation(0, rotation); mInputManager.setDisplayOrientation(0, rotation, mDisplay != null ? mDisplay.getExternalRotation() : Surface.ROTATION_0); // We need to update our screen size information to match the new // rotation. Note that this is redundant with the later call to Loading Loading @@ -6606,6 +6607,8 @@ public class WindowManagerService extends IWindowManager.Stub mInputManager.setDisplaySize(Display.DEFAULT_DISPLAY, mDisplay.getRawWidth(), mDisplay.getRawHeight(), mDisplay.getRawExternalWidth(), mDisplay.getRawExternalHeight()); mInputManager.setDisplayOrientation(Display.DEFAULT_DISPLAY, mDisplay.getRotation(), mDisplay.getExternalRotation()); mPolicy.setInitialDisplaySize(mDisplay, mInitialDisplayWidth, mInitialDisplayHeight); } Loading
services/jni/com_android_server_input_InputManagerService.cpp +16 −8 Original line number Diff line number Diff line Loading @@ -166,7 +166,7 @@ public: void setDisplaySize(int32_t displayId, int32_t width, int32_t height, int32_t externalWidth, int32_t externalHeight); void setDisplayOrientation(int32_t displayId, int32_t orientation); void setDisplayOrientation(int32_t displayId, int32_t orientation, int32_t externalOrientation); status_t registerInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel, const sp<InputWindowHandle>& inputWindowHandle, bool monitor); Loading Loading @@ -224,8 +224,9 @@ private: struct Locked { // Display size information. int32_t displayWidth, displayHeight; // -1 when not initialized int32_t displayExternalWidth, displayExternalHeight; // -1 when not initialized int32_t displayOrientation; int32_t displayExternalWidth, displayExternalHeight; // -1 when not initialized int32_t displayExternalOrientation; // System UI visibility. int32_t systemUiVisibility; Loading Loading @@ -275,9 +276,10 @@ NativeInputManager::NativeInputManager(jobject contextObj, AutoMutex _l(mLock); mLocked.displayWidth = -1; mLocked.displayHeight = -1; mLocked.displayOrientation = DISPLAY_ORIENTATION_0; mLocked.displayExternalWidth = -1; mLocked.displayExternalHeight = -1; mLocked.displayOrientation = DISPLAY_ORIENTATION_0; mLocked.displayExternalOrientation = DISPLAY_ORIENTATION_0; mLocked.systemUiVisibility = ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE; mLocked.pointerSpeed = 0; Loading Loading @@ -345,7 +347,8 @@ void NativeInputManager::setDisplaySize(int32_t displayId, int32_t width, int32_ } } void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orientation) { void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orientation, int32_t externalOrientation) { bool changed = false; if (displayId == 0) { AutoMutex _l(mLock); Loading @@ -359,6 +362,11 @@ void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orient controller->setDisplayOrientation(orientation); } } if (mLocked.displayExternalOrientation != externalOrientation) { changed = true; mLocked.displayExternalOrientation = externalOrientation; } } if (changed) { Loading Loading @@ -444,7 +452,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon mLocked.displayWidth, mLocked.displayHeight, mLocked.displayOrientation); outConfig->setDisplayInfo(0, true /*external*/, mLocked.displayExternalWidth, mLocked.displayExternalHeight, mLocked.displayOrientation); mLocked.displayExternalOrientation); } // release lock } Loading Loading @@ -1041,10 +1049,10 @@ static void nativeSetDisplaySize(JNIEnv* env, jclass clazz, jint ptr, } static void nativeSetDisplayOrientation(JNIEnv* env, jclass clazz, jint ptr, jint displayId, jint orientation) { jint ptr, jint displayId, jint orientation, jint externalOrientation) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setDisplayOrientation(displayId, orientation); im->setDisplayOrientation(displayId, orientation, externalOrientation); } static jint nativeGetScanCodeState(JNIEnv* env, jclass clazz, Loading Loading @@ -1327,7 +1335,7 @@ static JNINativeMethod gInputManagerMethods[] = { (void*) nativeStart }, { "nativeSetDisplaySize", "(IIIIII)V", (void*) nativeSetDisplaySize }, { "nativeSetDisplayOrientation", "(III)V", { "nativeSetDisplayOrientation", "(IIII)V", (void*) nativeSetDisplayOrientation }, { "nativeGetScanCodeState", "(IIII)I", (void*) nativeGetScanCodeState }, Loading