Skip to content
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

Send wakeup keycode alongside trying to turn screen on when restoring #1670

Closed

Conversation

brunoais
Copy link
Contributor

No description provided.

Device.setScreenPowerMode(Device.POWER_MODE_NORMAL);
Device device = new Device(new Options());
if(device.isScreenOn()){
Device.setScreenPowerMode(Device.POWER_MODE_NORMAL);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rom1v Is it better this way? It works too with my phone.

@brunoais brunoais marked this pull request as ready for review August 13, 2020 19:48
rom1v pushed a commit that referenced this pull request Aug 21, 2020
PR #1670 <#1670>

Signed-off-by: Romain Vimont <rom@rom1v.com>
@rom1v
Copy link
Collaborator

rom1v commented Aug 21, 2020

My first thought was it was incorrect to reset the power mode to normal only when the screen is on: I still want to be able to physically turn the screen on with a double tab on the screen (without pressing POWER)¹. If the screen is not reset to normal, I thought it would not work.

In fact, it's the opposite:

  • double tab allows to turn the screen on even if power mode is not NORMAL;
  • setting power mode to NORMAL while screen is off is not handled correctly, so this breaks "screen on on double tab".

Therefore, I agree with this change. I made isScreenOn() static (0c5e0a4) then adapted your commit: 0bf110d.

Could you please review/test? (branch pr1670)

¹ Btw, turning the screen on with a double tap (only supported on some devices) is not catched by #1577.

@brunoais
Copy link
Contributor Author

brunoais commented Aug 21, 2020

double tab allows to turn the screen on even if power mode is not NORMAL;

Doesn't work on my phone. I need this API to turn it back on, otherwise, the double-tab turns off and locks and then double-tab turns it back on.

then adapted your commit: 0bf110d.

LGTM.

Btw, turning the screen on with a double tap (only supported on some devices) is not catched by #1577.

True, that's by design. #1577, by design, is intended to act only for actions done in scrcpy. Do you think the documentation requires more clarification?

@rom1v
Copy link
Collaborator

rom1v commented Aug 29, 2020

LGTM.

👍 Merged into dev.

Doesn't work on my phone. I need this API to turn it back on, otherwise, the double-tab turns off and locks and then double-tab turns it back on.

Sorry, I don't get it.

With the following steps:

  • scrcpy --turn-screen-off (physical screen off, mirror screen on)
  • Alt+p (physical screen off, mirror screen off)
  • close scrcpy
  • double-tap on the physical screen

Without this change, it stays black. With this change, it works. (Initially, I thought it would be the contrary)

True, that's by design.

👍

Btw, double-tap with a double-click in scrcpy works to turn the screen off, but not to turn it back on.

@rom1v rom1v closed this Aug 29, 2020
@brunoais
Copy link
Contributor Author

With the following steps:

* `scrcpy --turn-screen-off` (physical screen off, mirror screen on)
* Alt+p (physical screen off, mirror screen off)
* close scrcpy
* double-tap on the physical screen

Without this change, it stays black. With this change, it works. (Initially, I thought it would be the contrary)

Without this change:
On my phone, that 3rd step would turn the screen and display on; ready to unlock. Then the double-tap would turn the screen off.
Closing scrcpy turns on the screen and the display.

Seems like in phones like yours, only the screen turns on but not the display (no image but light on). However, the OS changes mode to "awaken" (or whatever name). So when you double-tap it, it turns off both screen and display.

With this change:
I guess we get consistent behavior because now my phone behaves as you describe in the quote above.
If the display is on but the screen if off, the screen is turned back on.
If both display and screen are off, they stay off.

Makes sense?

jellopuddingstick added a commit to jellopuddingstick/scrcpy that referenced this pull request Jan 23, 2021
scrcpy v1.17

Changes since v1.16:
 - Fix errors on Android 11 (Genymobile#1468)
 - Add --encoder option (Genymobile#1810, Genymobile#1827)
 - Add --forward-all-clicks option (Genymobile#1302, Genymobile#1613)
 - Add --legacy-paste option (Genymobile#1750, Genymobile#1771)
 - Workaround screen off/on issue on exit (Genymobile#1670)
 - Rework console/noconsole versions on Windows (Genymobile#1875, Genymobile#1988)
 - Terminate server properly without killing it on close (Genymobile#1992)
 - List available shortcut keys on error (Genymobile#1681)
 - Upgrade platform-tools to 30.0.5 (adb) in Windows releases
 - Upgrade SDL to 2.0.14 in Windows releases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants