-
-
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import com.genymobile.scrcpy.util.Ln; | ||
import com.genymobile.scrcpy.util.Settings; | ||
import com.genymobile.scrcpy.util.SettingsException; | ||
import com.genymobile.scrcpy.wrappers.ServiceManager; | ||
|
||
import android.os.BatteryManager; | ||
import android.system.ErrnoException; | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the main display must be able to display IME normally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (nitpick: maybe we should still allow |
||
int displayImePolicy = options.getDisplayImePolicy(); | ||
if (displayImePolicy != -1) { | ||
int currentValue = ServiceManager.getWindowManager().getDisplayImePolicy(displayId); | ||
if (currentValue != displayImePolicy) { | ||
ServiceManager.getWindowManager().setDisplayImePolicy(displayId, displayImePolicy); | ||
restoreDisplayImePolicy = currentValue; | ||
} | ||
} | ||
} | ||
|
||
try { | ||
run(displayId, restoreStayOn, disableShowTouches, powerOffScreen, restoreScreenOffTimeout); | ||
run(displayId, restoreStayOn, disableShowTouches, powerOffScreen, restoreScreenOffTimeout, restoreDisplayImePolicy); | ||
} catch (IOException e) { | ||
Ln.e("Clean up I/O exception", e); | ||
} | ||
} | ||
|
||
private void run(int displayId, int restoreStayOn, boolean disableShowTouches, boolean powerOffScreen, int restoreScreenOffTimeout) | ||
throws IOException { | ||
private void run(int displayId, int restoreStayOn, boolean disableShowTouches, boolean powerOffScreen, int restoreScreenOffTimeout, | ||
int restoreDisplayImePolicy) throws IOException { | ||
String[] cmd = { | ||
"app_process", | ||
"/", | ||
|
@@ -118,6 +131,7 @@ private void run(int displayId, int restoreStayOn, boolean disableShowTouches, b | |
String.valueOf(disableShowTouches), | ||
String.valueOf(powerOffScreen), | ||
String.valueOf(restoreScreenOffTimeout), | ||
String.valueOf(restoreDisplayImePolicy), | ||
}; | ||
|
||
ProcessBuilder builder = new ProcessBuilder(cmd); | ||
|
@@ -178,6 +192,7 @@ public static void main(String... args) { | |
boolean disableShowTouches = Boolean.parseBoolean(args[2]); | ||
boolean powerOffScreen = Boolean.parseBoolean(args[3]); | ||
int restoreScreenOffTimeout = Integer.parseInt(args[4]); | ||
int restoreDisplayImePolicy = Integer.parseInt(args[5]); | ||
|
||
// Dynamic option | ||
boolean restoreDisplayPower = false; | ||
|
@@ -223,6 +238,11 @@ public static void main(String... args) { | |
} | ||
} | ||
|
||
if (restoreDisplayImePolicy != -1) { | ||
Ln.i("Restoring \"display IME policy\""); | ||
ServiceManager.getWindowManager().setDisplayImePolicy(displayId, restoreDisplayImePolicy); | ||
} | ||
|
||
// Change the power of the main display when mirroring a virtual display | ||
int targetDisplayId = displayId != Device.DISPLAY_ID_NONE ? displayId : 0; | ||
if (Device.isScreenOn(targetDisplayId)) { | ||
|
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:
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:
print:
[server] DEBUG: displayImePolicy:0 before setDisplayImePolicy
[server] DEBUG: displayImePolicy:0 after setDisplayImePolicy