Open ulno opened 4 years ago
When I disconnect the phone or terminate scrcpy it breaks the capability of my phone to ever switch off the display again
Actually, pressing POWER once should turn it off, pressing POWER again should turn it on, screen included.
Anyway, it's implemented and merged in dev
: #1572 #1576
I haven't had the chance yet to compile the new version, I will test tomorrow.
However, I am not sure that the two issues cover really the same problem I have here: after disconnecting, my screen does turn on pressing the power button, and then I can operate the phone normally. When pressing power again or waiting a couple of seconds, the screen turns black but the screen doesn't turn off anymore - the backlight is still onandn the phone starts heating up notably in my pocket. So, yes something turns off (screen goes black), but backlight/the physical screen is not turned off anymore.
OK, looks like a problem in the device ROM then. Scrcpy just requests the device to set the power mode, the way the device handles it is not defined by scrcpy.
There were also similar bugs with turning the screen on some time ago, see discussion: https://github.com/Genymobile/scrcpy/issues/175#issuecomment-497946596
Compiled scrcpy from master, same problems persist. I see at least some pattern: After reboot it usually works once. So after running scrcpy with --turn-off-screen and then closing scrcpy gracefully (or even when just disconnecting), the display still DOES turn off. running scrcpy with --turn-off-screen a second time though usually destroys the display turning off (it still turns black) and destroys the working of the brightness settings as in #1143. These two problems always happen together.
I can still use adb shell settings put system screen_brightness xxx
to move the brightness slider, but actual brightness settings are ignored.
As it works the first time though, I wonder if we could find some kind of cleanup that can put the phone in a normal state even when running scrcpy twice. I wonder if it is some kind of timing issue?
I am trying to find something suspicious in the log, but I can't find anything, I think this is the relevant part when turning the screen off, but only reaching black state with display light set to full: Some lines that I think sound suspicious from below full log
07-20 09:45:32.676 2121 2251 D SurfaceControl: Excessive delay in setPowerMode()
07-20 09:45:32.677 428 454 I vendor.mediatek.hardware.power@2.0-impl: setInteractive Disable All 13 1281
07-20 09:45:32.679 1868 1895 E : flp_screen_monitor_thread: Screen off
07-20 09:45:32.680 1868 1901 D : mnld_main_thread: flp2mnl_hdlr msg
07-20 09:45:32.681 1868 1901 D flpint : mtk_flp2mnl_process: mtk_flp2mnl_process, recv prmsg, type:502, len:1 status:2
07-20 09:45:32.681 1868 1901 D flpint : mtk_flp2mnl_process: free screen dbg
07-20 09:45:32.681 1868 1901 D : mnld_main_thread: gfc2mnl_hdlr msg
07-20 09:45:32.681 1868 1901 D : mtk_gfc_ofl2mnl_process: free screen dbg
07-20 09:45:32.682 2283 2283 D StatusBarKeyguardViewManager: reset() is called, mShowing = true ,mOccluded = falsehideBouncerWhenShowing = true
07-20 09:45:32.691 2121 2217 E WifiVendorHal: getWifiLinkLayerStats(l.937) failed {.code = ERROR_NOT_SUPPORTED, .description = }
07-20 09:45:32.710 2264 2264 W SessionManager: SessionManager.beginSession():53 Try to begin an already begun session [INPUT_SESSION], end it first
07-20 09:45:32.832 3084 3084 D NfcService: BroadcastReceiver - SCREEN_STATE_OFF_LOCKED
07-20 09:45:32.833 3084 3084 D NfcService: NfcServiceHandler - handleMessage(MSG_APPLY_SCREEN_STATE)
07-20 09:45:32.833 416 416 D StNfcHal: HAL st21nfc: StNfc_hal_write
07-20 09:45:32.833 416 3750 D StNfcHal: Tx 20 09 01 03
07-20 09:45:32.834 416 3751 W StNfcHal: ! i2cWrite!!, errno is 'I/O error'
Anything weird up there? I just wonder what this excessive delay is.
Full log:
07-20 09:45:32.384 1917 1917 I Light : enable: handle:4, en:0
07-20 09:45:32.384 2283 2283 V HeadsUpManager: releaseAllImmediately
07-20 09:45:32.385 434 434 D SurfaceFlinger: Set power mode=0, type=0 flinger=0x6f9d255000
07-20 09:45:32.385 2121 2144 I DisplayManagerService: Display device changed state: "Built-in Screen", OFF
07-20 09:45:32.386 410 14713 I hwcomposer: [HWC] Display(0) SetPowerMode(0)
07-20 09:45:32.387 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.387 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.387 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.389 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.389 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.389 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.392 2283 2283 D StatusBar: disable<e i a s b H R c s > disable2<q i n >
07-20 09:45:32.392 2283 2283 D StatusBar: disable<e i a s b H R c s > disable2<q i n >
07-20 09:45:32.393 2121 2206 I InputReader: Reconfiguring input devices. changes=0x00000004
07-20 09:45:32.605 1654 1654 D GED Service: signo=49, event_notify=00000000
07-20 09:45:32.606 1933 2008 I 1933 2008 [sunwave-ca-device] : (730) uevent: got screen OFF event.'SCREEN_STATUS=OFF'.
07-20 09:45:32.606 1933 2148 I 1933 2148 [sunwave-hal] : (797) 'screenOnOffMonitoringThread' screen_on = 0
07-20 09:45:32.676 434 434 D SurfaceFlinger: Finished set power mode=0, type=0
07-20 09:45:32.676 2121 2251 D SurfaceControl: Excessive delay in setPowerMode()
07-20 09:45:32.677 428 454 I vendor.mediatek.hardware.power@2.0-impl: setInteractive Disable All 13 1281
07-20 09:45:32.679 1868 1895 E : flp_screen_monitor_thread: Screen off
07-20 09:45:32.680 1868 1901 D : mnld_main_thread: flp2mnl_hdlr msg
07-20 09:45:32.681 1868 1901 D flpint : mtk_flp2mnl_process: mtk_flp2mnl_process, recv prmsg, type:502, len:1 status:2
07-20 09:45:32.681 1868 1901 D flpint : mtk_flp2mnl_process: free screen dbg
07-20 09:45:32.681 1868 1901 D : mnld_main_thread: gfc2mnl_hdlr msg
07-20 09:45:32.681 1868 1901 D : mtk_gfc_ofl2mnl_process: free screen dbg
07-20 09:45:32.682 2283 2283 D StatusBarKeyguardViewManager: reset() is called, mShowing = true ,mOccluded = falsehideBouncerWhenShowing = true
07-20 09:45:32.682 2283 2283 D StatusBarKeyguardViewManager: showBouncerOrKeyguard() is called.
07-20 09:45:32.683 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.683 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.683 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.684 2283 2283 D StatusBarKeyguardViewManager: needsFullscreenBouncer() is false,show "Notification Keyguard" view.
07-20 09:45:32.685 2283 2283 V HeadsUpManager: releaseAllImmediately
07-20 09:45:32.691 2121 2217 E WifiVendorHal: getWifiLinkLayerStats(l.937) failed {.code = ERROR_NOT_SUPPORTED, .description = }
07-20 09:45:32.692 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.692 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.692 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.693 2121 2217 D WifiConnectivityManager: handleScreenStateChanged: screenOn=false
07-20 09:45:32.693 2121 2217 D WifiConnectivityManager: startConnectivityScan: screenOn=false wifiState=connected scanImmediately=false wifiEnabled=true wifiConnectivityManagerEnabled=true
07-20 09:45:32.698 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.698 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.698 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.701 2283 2283 D StatusBar: disable<e i a s b H R c s > disable2<q i n >
07-20 09:45:32.703 2283 2283 D FaceUnlockUtil: showUnLockScreenAgain mFaceUnlockStatus = 17 unlockingAllowed = true
07-20 09:45:32.702 2283 2283 D StatusBar: disable<e i a s b H R c s > disable2<q i n >
07-20 09:45:32.705 2392 2392 I wpa_supplicant: wpa_driver_nl80211_driver_cmd: wlan0 recv cmd SETSUSPENDMODE 1
07-20 09:45:32.709 2264 2264 I GoogleInputMethodService: GoogleInputMethodService.onStartInput():1808
07-20 09:45:32.710 2264 2264 W SessionManager: SessionManager.beginSession():53 Try to begin an already begun session [INPUT_SESSION], end it first
07-20 09:45:32.711 2392 2392 I wpa_supplicant: wpa_driver_nl80211_driver_cmd: ret = 0 used = 17 total = 512
07-20 09:45:32.713 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.713 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.713 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.717 2264 2264 I GoogleInputMethodService: GoogleInputMethodService.onStartInputView():1924
07-20 09:45:32.725 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.725 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.725 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.727 2283 2283 V KeyguardSecurityView: showPrimarySecurityScreen(securityMode=Password)
07-20 09:45:32.732 2283 2283 V HeadsUpManager: releaseAllImmediately
07-20 09:45:32.736 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.736 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.736 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.738 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 0, simState = ABSENT
07-20 09:45:32.738 2283 2283 D KeyguardSecurityModel: isPinPukOrMeRequiredOfSubId() - phoneId = 1, simState = READY
07-20 09:45:32.738 2283 2283 D AntiTheftManager: getCurrentAntiTheftMode() is called.
07-20 09:45:32.740 2283 2283 D StatusBar: disable<e i a s b H R c s > disable2<q i n >
07-20 09:45:32.725 2283 2283 D FaceUnlockUtil: showUnLockScreenAgain mFaceUnlockStatus = 17 unlockingAllowed = true
07-20 09:45:32.741 2283 2283 D FaceUnlockUtil: updateMsgIcon message =
07-20 09:45:32.740 2283 2283 D StatusBar: disable<e i a s b H R c s > disable2<q i n >
07-20 09:45:32.746 2283 2283 I vol.Events: writeEvent dismiss_dialog screen_off
07-20 09:45:32.746 2283 2283 W IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
07-20 09:45:32.747 2283 2283 W IInputConnectionWrapper: getSelectedText on inactive InputConnection
07-20 09:45:32.748 2283 2283 W IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
07-20 09:45:32.749 2264 2264 I KeyboardViewUtil: KeyboardViewUtil.getKeyboardHeightRatio():182 systemKeyboardHeightRatio:1.000000; userKeyboardHeightRatio:1.050000.
07-20 09:45:32.750 2264 2264 I AndroidIME: AbstractIme.onActivate():84 PasswordIme.onActivate() : EditorInfo = Package = com.android.systemui : Type = Password : Learning = Disable : Suggestion = Hide : AutoCorrection = Disable : Microphone = Hide : NoPersonalizedLearning = Disable : AutoStartVoiceInput = Disable, IncognitoMode = false
07-20 09:45:32.751 2264 2264 E putmethod.lati: Invalid ID 0x00000000.
07-20 09:45:32.751 2264 2264 E putmethod.lati: Invalid ID 0x00000000.
07-20 09:45:32.752 2264 2264 W Keyboard: Keyboard.getKeyboardViewHelper():613 null helper is returned: keyboardDef=ktu{className=.latin.keyboard.LatinPasswordKeyboard, id=keyboard_password, initialStates=0, keyboardViewDefs=[kus{direction=null, id=default_keyboard_view, isScalable=true, layoutId=keyboard_latin_10_10_9_9_body, type=BODY, touchable=true}, kus{direction=null, id=default_keyboard_view, isScalable=false, layoutId=keyboard_inline_suggestion, type=FLOATING_CANDIDATES, touchable=false}], keyTextSizeRatio=1.0, persistentStates=0, persistentStatesPrefKey=null, popupBubbleLayoutId=popup_bubble_material, recentKeyLayoutId=#0x0, recentKeyPopupLayoutId=#0x0, recentKeyType=null, rememberRecentKey=NONE, sessionStates=3, stringId=keyboard_en}, type=HEADER, helpersCreated=[null, eeg@5582808, eeg@ebaba1],
07-20 09:45:32.755 2264 2264 E putmethod.lati: Invalid ID 0x00000000.
07-20 09:45:32.755 2264 2264 E putmethod.lati: Invalid ID 0x00000000.
07-20 09:45:32.756 2264 2264 W Keyboard: Keyboard.getKeyboardViewHelper():613 null helper is returned: keyboardDef=ktu{className=.latin.keyboard.LatinPasswordKeyboard, id=keyboard_password, initialStates=0, keyboardViewDefs=[kus{direction=null, id=default_keyboard_view, isScalable=true, layoutId=keyboard_latin_10_10_9_9_body, type=BODY, touchable=true}, kus{direction=null, id=default_keyboard_view, isScalable=false, layoutId=keyboard_inline_suggestion, type=FLOATING_CANDIDATES, touchable=false}], keyTextSizeRatio=1.0, persistentStates=0, persistentStatesPrefKey=null, popupBubbleLayoutId=popup_bubble_material, recentKeyLayoutId=#0x0, recentKeyPopupLayoutId=#0x0, recentKeyType=null, rememberRecentKey=NONE, sessionStates=3, stringId=keyboard_en}, type=HEADER, helpersCreated=[null, eeg@5582808, eeg@ebaba1],
07-20 09:45:32.757 2264 2264 W KeyboardModeManager: KeyboardModeManager.setInputView():302 setInputView() : inputView = com.google.android.apps.inputmethod.libs.framework.core.InputView{1ccf7cd V.E...... .......D 0,0-1080,2106}
07-20 09:45:32.758 2264 2264 I ConversationToQueryExtension: ConversationToQueryExtension.isEnabledForHostApp():254 Conv2Query not enabled due to current app [com.android.systemui] not in whitelist
07-20 09:45:32.758 2264 2264 I ConversationToQueryExtension: ConversationToQueryExtension.onActivate():164 onActivate() : Disabled by unsupported host app
07-20 09:45:32.759 2264 2264 I CurrentMicStatusHolder: CurrentMicStatusHolder.onStartInputView():79 Current Mic status = {MicIconHidden-PasswordOrNumberOrDateInputType,}
07-20 09:45:32.759 2264 16619 I FederatedC2QExtension: FederatedC2QExtension.setupModelDownloading():391 Already registered manifest.
07-20 09:45:32.759 2264 2264 I VoiceImeExtension: VoiceImeExtension.shouldStartVoiceInputAutomatically():343 No private IME option set to start voice input.
07-20 09:45:32.761 2264 2264 V PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@9e979fa, this = DecorView@cef4bab[InputMethod]
07-20 09:45:32.761 2283 2283 D sunjin : [NavigationBarView]updateNavButtonIcons: mVertical - false
07-20 09:45:32.762 2264 2264 I GoogleInputMethodService: GoogleInputMethodService.onFinishInputView():2135
07-20 09:45:32.762 2264 2264 I AndroidIME: AbstractIme.onDeactivate():161 PasswordIme.onDeactivate()
07-20 09:45:32.764 2264 2264 V PhoneWindow: DecorView setVisiblity: visibility = 8, Parent = android.view.ViewRootImpl@9e979fa, this = DecorView@cef4bab[InputMethod]
07-20 09:45:32.770 2283 2283 D sunjin : [NavigationBarView]updateNavButtonIcons: mVertical - false
07-20 09:45:32.773 2264 2264 E putmethod.lati: Invalid ID 0x00000000.
07-20 09:45:32.774 2264 2264 E putmethod.lati: Invalid ID 0x00000000.
07-20 09:45:32.774 2264 2264 W Keyboard: Keyboard.getKeyboardViewHelper():613 null helper is returned: keyboardDef=ktu{className=.latin.keyboard.LatinPasswordKeyboard, id=keyboard_password, initialStates=0, keyboardViewDefs=[kus{direction=null, id=default_keyboard_view, isScalable=true, layoutId=keyboard_latin_10_10_9_9_body, type=BODY, touchable=true}, kus{direction=null, id=default_keyboard_view, isScalable=false, layoutId=keyboard_inline_suggestion, type=FLOATING_CANDIDATES, touchable=false}], keyTextSizeRatio=1.0, persistentStates=0, persistentStatesPrefKey=null, popupBubbleLayoutId=popup_bubble_material, recentKeyLayoutId=#0x0, recentKeyPopupLayoutId=#0x0, recentKeyType=null, rememberRecentKey=NONE, sessionStates=3, stringId=keyboard_en}, type=HEADER, helpersCreated=[null, eeg@5582808, eeg@ebaba1],
07-20 09:45:32.776 2264 2264 I DeviceStatusMonitor: DeviceStatusMonitor$1.onReceive():51 onReceive() : Action = android.intent.action.SCREEN_OFF
07-20 09:45:32.776 2264 2264 I InputBundle: InputBundle.consumeEvent():956 Skip consuming an event as imeStatus is 0
07-20 09:45:32.777 2264 2264 I DeviceStatusMonitor: DeviceStatusMonitor.updateCountryInfo():111 updateCountryInfo(), notifyAnyway = false
07-20 09:45:32.794 3281 3281 I PublicSearchService: Creating pss binder().
07-20 09:45:32.797 3281 3300 I PublicSearchService: Calling beginBinderSession().
07-20 09:45:32.797 3281 3300 I PublicSearchService: beginBinderSession(): calling binder
07-20 09:45:32.798 3281 3300 V AIEngines: #process
07-20 09:45:32.798 3281 4384 V AIEngines: #processSync
07-20 09:45:32.799 3281 4384 V AIEngines: #process: skip check - hasSuggestion? false, selectedengines []
07-20 09:45:32.799 3281 4384 V AIEngines: #process: done
07-20 09:45:32.826 2283 2283 D sunjin : [NavigationBarView]updateNavButtonIcons: mVertical - false
07-20 09:45:32.832 3084 3084 D NfcService: BroadcastReceiver - SCREEN_STATE_OFF_LOCKED
07-20 09:45:32.833 3084 3084 D NfcService: NfcServiceHandler - handleMessage(MSG_APPLY_SCREEN_STATE)
07-20 09:45:32.833 416 416 D StNfcHal: HAL st21nfc: StNfc_hal_write
07-20 09:45:32.833 416 3750 D StNfcHal: Tx 20 09 01 03
07-20 09:45:32.834 416 3751 W StNfcHal: ! i2cWrite!!, errno is 'I/O error'
07-20 09:45:32.839 416 3751 D StNfcHal: Rx 40 09 01 00
07-20 09:45:32.840 416 416 D StNfcHal: HAL st21nfc: StNfc_hal_write
07-20 09:45:32.840 416 3750 D StNfcHal: Tx 20 02 04 01 02 01 00
07-20 09:45:32.841 416 3751 D StNfcHal: Rx 40 02 02 00 00
07-20 09:45:32.863 3056 3056 E HwDetectorWithState: a: 2
07-20 09:45:32.863 3056 3056 E HotwordState: FASE: true, SHwR: false, ACR: true, HR: false, ACbSS: false, ACbHE: false, SO:false, ARS: false
07-20 09:45:32.864 3056 4276 I SodaHwDetectionManager: #stopHotwordDetectionInternal
07-20 09:45:32.891 2817 4980 I NearbyDiscovery: FastPairHandler: Received action android.intent.action.SCREEN_OFF [CONTEXT service_id=49 ]
07-20 09:45:32.892 2817 4980 I NearbyDiscovery: FastPairScanner2: Stopping scan [CONTEXT service_id=49 ]
I did some further testing (compared a lot of dumpsys and settings listings) and I think the only possible fix would be to let the server be installed and running as the inconsistency seems to only occur when it stops (only one process allowed to use that surface based display power setting feature?). Maybe extracting the "turning display off" into its own service could make sense too. If we run into permisson problems we could potentially just put the server into a detached adb-session and connect to that the second time we run scrcpy. Would that be possible and how much effort would it involve?
Environment
Describe the bug I am building a small open source convergence solution using my phone as communication hub (like Franz or Rambox) getting notifications via kdeconnect and then answering and viewing messages on a phone sitting on the top of my screen. Using --turn-screen-off works sometimes, sometimes it only turns the screen black and keeps the backlight on - it does always still show the desktop. I see the same behavior using ctrl-o and (even when using ctrl-shift-o before disconnecting). When I disconnect the phone or terminate scrcpy it breaks the capability of my phone to ever switch off the display again (using only ctrl-o and not --turn-screen-off) until I reboot the phone - I wonder if #1143 is related.
Can I see somewhere what exactly is done to switch off the screen (eventually as shell commands run via adb, but I assume it's somehow done in scrcpy-server), so I can debug things more step by step? My system also uses a clean-up hook - so, I could do some resetting if I knew what was happening. However, I would actually even like to make sure that turning the screen off works all the time.
On errors, please provide the output of the console (and
adb logcat
if relevant). console: [server] INFO: Device screen turned off (at start)I am actually not sure what I should provide here best as phone starts misbehaving after disconnect. When the error occurred (did not switch off even before), I managed to capture the attached logcat.txt log when just terminating scrcpy. Screen cannot turn off now anymore. Scrcpy was stated this way:
scrcpy -m 1920 -w --turn-screen-off
logcat output is too long, can't upload - here is it in my drive: https://drive.google.com/file/d/1dRZt1_T0Yd1H3izHs9I9m2t-onD363-O/view