-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sets the policy for how the display should show IME. #5703
base: dev
Are you sure you want to change the base?
Conversation
Possible values are "local", "fallback_display" and "hide".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR. After a quick glance, it looks very good and clean (with all details implemented) 👍
As a French speaker, I have never needed to use an IME, so I'm not very familiar with IME policies. I'd like to get opinions from IME users 🙂
There are 3 options (local, fallback, hide), is it absolutely necessary to expose them? (Maybe yes, I'm just asking.)
Or isn't there an "obvious" default option to set without asking the user?
For example, are there cases where you need to use an IME on your main display if you're mirroring a virtual display?
Wouldn't it be sufficient to call unconditionnally in NewDisplayCapture
:
ServiceManager.getWindowManager().setDisplayImePolicy(virtualDisplayId, DISPLAY_IME_POLICY_LOCAL)`
@@ -100,15 +101,27 @@ private void runCleanUp(Options options) { | |||
boolean powerOffScreen = options.getPowerOffScreenOnClose(); | |||
int displayId = options.getDisplayId(); | |||
|
|||
int restoreDisplayImePolicy = -1; | |||
if (displayId > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only for secondary displays? (not the main display?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the main display must be able to display IME normally.
I think We shouldn't modify the main display settings。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nitpick: maybe we should still allow --display-ime-policy
for display 0, and let the user not pass the option for the main display if he does not want to?)
if (setDisplayImePolicyMethod == null) { | ||
try { | ||
setDisplayImePolicyMethod = manager.getClass().getMethod("setDisplayImePolicy", int.class, int.class); | ||
} catch (NoSuchMethodException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change between shouldShowIme()
and getDisplayImePolicy()
was performed by this commit introduced in Android 12, so it can be checked directly with Build.VERSION.SDK_INT < AndroidVersions.API_31_ANDROID_12
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
Thank you for your replay. I have a project about Huawei electric car,the project sometimes needs to input text then search on secondary display, and then notify the main driver(main display).Huawei electric cars are very expensive, and not every developer can have one. The secondary display is TYPE_HDMI on Huawei electric car, IME show in secondary display. I'm very confused, then I find Developer options-Force desktop mode, it can show IME in secondary display. We know,the main display must be able to display IME normally,so,I just want to display IME in secondary display when I touch in secondary display such as Huawei electric car and Android Studio‘s secondary display。
If the secondary screen wants to display IME, it must has the VIRTUAL_DISPLAY_FLAG_TRUSTED and VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS flag, otherwise it will report a permission problem.
The virtualdisplay that created by my app does not have VIRTUAL_DISPLAY_FLAG_TRUSTED in Android 11 、12.
Although Android 10 does not have a VIRTUAL_DISPLAY_FLAG_TRUSTED flag, But Android 10 will check OwnerUid. |
…ShowIme and getDisplayImePolicy
} else { | ||
if (!opts->new_display | ||
&& opts->display_ime_policy != SC_DISPLAY_IME_POLICY_UNDEFINDED) { | ||
LOGE("--display-ime-policy not supported if display_id == 0 and new_display == NULL"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--display-ime-policy=hide
would not make sense for the main display?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try "setDisplayImePolicy(0, 2)", it doest not work, the main display always show IME. I don't know why until now.
Testing Machine List:
brand | model | api-level | abi |
---|---|---|---|
HUAWEI | AGS5-W00 | 31 | arm64-v8a |
Pixel 3a | 32 | arm64-v8a | |
Lenovo | TB331FC | 33 | arm64-v8a |
Xiaomi | 23073RPBFC | 34 | arm64-v8a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code:
int displayImePolicy = ServiceManager.getWindowManager().getDisplayImePolicy(0);
Ln.d("displayImePolicy:" + displayImePolicy + " before setDisplayImePolicy");
ServiceManager.getWindowManager().setDisplayImePolicy(0, 2);
displayImePolicy = ServiceManager.getWindowManager().getDisplayImePolicy(0);
Ln.d("displayImePolicy:" + displayImePolicy + " after setDisplayImePolicy");
print:
[server] DEBUG: displayImePolicy:0 before setDisplayImePolicy
[server] DEBUG: displayImePolicy:0 after setDisplayImePolicy
@@ -100,15 +101,27 @@ private void runCleanUp(Options options) { | |||
boolean powerOffScreen = options.getPowerOffScreenOnClose(); | |||
int displayId = options.getDisplayId(); | |||
|
|||
int restoreDisplayImePolicy = -1; | |||
if (displayId > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nitpick: maybe we should still allow --display-ime-policy
for display 0, and let the user not pass the option for the main display if he does not want to?)
One more question: The display IME policy is set at two different places:
For the second case, does it work if you apply the IME policy to the mirroring virtual display instead of using the "clean up" mechanism? Something like: diff --git server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java
index 5f4e1803f..e9ab32534 100644
--- server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java
+++ server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java
@@ -127,6 +127,8 @@ public class ScreenCapture extends SurfaceCapture {
try {
virtualDisplay = ServiceManager.getDisplayManager()
.createVirtualDisplay("scrcpy", inputSize.getWidth(), inputSize.getHeight(), displayId, surface);
+ int virtualDisplayId = virtualDisplay.getDisplay().getDisplayId();
+ ServiceManager.getWindowManager().setDisplayImePolicy(virtualDisplayId, displayImePolicy);
Ln.d("Display: using DisplayManager API");
} catch (Exception displayManagerException) {
try { |
The virtualdiplay created by this way is private and untrusted. throws SecurityException when setDisplayImePolicy.
|
Hi,bro.
Scrcpy is very good, I like it.
I want to display IME in virtualdisplay。