Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
109.62k stars 10.53k forks source link

App closes with warning when allowing/denying access to phone data #1914

Open reilg opened 3 years ago

reilg commented 3 years ago

Before anything, Incredible app! Thank you so much for providing it for free.

Environment

A little background

My phone screen is unusable not physically broken but it's unusable because it just keeps on flash when I try to turn it on. The phone is otherwise functioning. So I pretty much use this app so I can see my phone screen.

Describe the bug

When the phone is first plugged in, it shows prompts me to allow the laptop access to data. image

Whether I click allow or deny, the app always closes with a warning:

INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
/usr/share/scrcpy/scrcpy-server: 1 file pushed. 2.8 MB/s (24773 bytes in 0.008s)
INFO: Initial texture: 528x1080
[server] INFO: Device screen turned off
WARN: Device disconnected

This only happens on the connection though. If I run the command again, I don't get the prompt and I can use the app just fine.

If I detach/reattach the cable or if I restart the laptop, I get the prompt and the issue happens again.

Command used to run scrcpy (in case relevant)

scrcpy -m 1080 --window-height 750 -S

Things I've tried

  1. Used a different port
  2. Used a different cable
  3. Reinstalled scrcpy

ADB logcat

11-18 15:04:58.708  3872  5962 D SurfaceControl: reparent is called, sc=Surface(name=AppWindowToken{82ea122 token=Token{2596eed ActivityRecord{1d8f904 u0 com.samsung.android.MtpApplication/.USBConnection t298}}})/@0x11c96ff, newParentHandle=android.os.BinderProxy@2dcabf4, transaction=android.view.SurfaceControl$Transaction@711bf1d
11-18 15:04:58.716  3316  3354 E Layer   : $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
11-18 15:04:58.716  3316  3354 E Layer   : Abnormal Layer [Screenshot Parent]
11-18 15:04:58.721  3872  5962 I WindowManager: Cancelling animation restarting=true, leash=null, surface=Surface(name=Dim Layer for - Task=298)/@0x47866f7, parent=Surface(name=Task=298)/@0xad4964
11-18 15:04:58.721  3872  5962 I WindowManager: Reparenting to leash, surface=Surface(name=Dim Layer for - Task=298)/@0x47866f7
11-18 15:04:58.723  3872  5258 D SamsungAlarmManager: Cancel Alarm calling from uid:10080 pid :7537 / op:PendingIntent{129360: PendingIntentRecord{99d0396 com.facebook.services broadcastIntent}}
11-18 15:04:58.724  3316  3316 I SurfaceFlinger: id=242 createSurf (5920x5920),2 flag=4, Surface(name=Dim Layer for - Task=298)/@0x47866f7 - animation-leash#0
11-18 15:04:58.724  3872  5962 D SurfaceControl: reparent is called, sc=Surface(name=Dim Layer for - Task=298)/@0x47866f7, newParentHandle=android.os.BinderProxy@d103019, transaction=android.view.SurfaceControl$Transaction@25d5882
11-18 15:04:58.725  3316  3354 D Layer   : [AppWindowToken{82ea122 token=Token{2596eed ActivityRecord{1d8f904 u0 com.samsung.android.MtpApplication/.USBConnection t298}}}#0]::reparent oldParent:[Task=298#0], newParent:[Surface(name=AppWindowToken{82ea122 token=Token{2596eed ActivityRecord{1d8f904 u0 com.samsung.android.MtpApplication/.USBConnection t298}}})/@0x11c96ff - animation-leash#0]
11-18 15:04:58.726  4481  4826 D ForegroundUtils: could not check pending caller
11-18 15:04:58.727 16953 16953 D ViewRootImpl@20b3016[USBConnection]: setWindowStopped(true) old=false
11-18 15:04:58.727  3316  3354 D Layer   : [Dim Layer for - Task=298#0]::reparent oldParent:[Task=298#0], newParent:[Surface(name=Dim Layer for - Task=298)/@0x47866f7 - animation-leash#0]
11-18 15:04:58.727  3872  3872 D FreeformController: Fail to invalid task id :  -1
11-18 15:04:58.728  3872  3908 D CodecSolution: isMaxAspectPackageEx: com.android.settings : true(2)
11-18 15:04:58.729 16953 16953 D MTPUSBConnection: on destroy
11-18 15:04:58.730 16953 16953 I MTPUSBConnection: Inside MtpGSIMLogging
11-18 15:04:58.731  3872  5554 D GamePkgDataHelper: getSosPolicy(). com.android.settings
11-18 15:04:58.731 16953 16953 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1067 android.content.ContextWrapper.sendBroadcast:449 com.samsung.android.MtpApplication.USBConnection.MtpGSIMLogging:432 com.samsung.android.MtpApplication.USBConnection.onDestroy:85 android.app.Activity.performDestroy:7684 
11-18 15:04:58.731  8500 11427 I DeviceIndex: Skipping: device index is not enabled
11-18 15:04:58.731  8500  8500 E AccessibilityManager: semUpdateAssitantMenu invoking from manager:
11-18 15:04:58.733  8500  8500 D SamsungAnalytics200001: [DLCBinder] already send register request
11-18 15:04:58.736  3872  5554 D GameManagerService: identifyGamePackage. com.android.settings, mCurrentUserId: 0, callerUserId: 0
11-18 15:04:58.736  3872  5554 D GamePkgDataHelper: getGamePkgData(). com.android.settings
11-18 15:04:58.737 16953 16953 D MTPRx   : inside changeChargingMode : set USB MODE sec_charging
11-18 15:04:58.738  8500  8500 D Settings_Utils: Package not found : com.sec.knox.kccagent
11-18 15:04:58.739  8500  8500 D Settings_Utils: Package not found : com.sec.knox.kccagent
11-18 15:04:58.739 16953 16953 W Settings: Setting adb_enabled has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
11-18 15:04:58.744  3872  5962 D UsbDeviceManager: setCurrentFunctions(sec_charging,adb)
11-18 15:04:58.745  3872  5962 D SecContentProvider: query(), uri = 17 selection = isUsbDebuggingEnabled
11-18 15:04:58.745  3872  5962 D SecContentProvider: called from android.uid.system:1000
11-18 15:04:58.745  3872  5962 D RestrictionPolicy: isUsbDebuggingEnabled : true
11-18 15:04:58.745  3872  5962 D UsbDeviceManager: policy : adb, restrict(allow) = true
11-18 15:04:58.746  3872  5962 D UsbDeviceManager: setCurrentFunctions - validateDeviceRestriction : sec_charging,adb
11-18 15:04:58.746  3872  3915 D UsbDeviceManager: handleMessage -> MSG_SET_CURRENT_FUNCTION
11-18 15:04:58.746  3872  3915 D UsbDeviceManager: setEnabledFunctions functions=sec_charging,adb, forceRestart=false, usbDataUnlocked=false, mCurrentFunctions=mtp,adb
11-18 15:04:58.746  3872  5962 D GameManagerService: identifyGamePackage. com.android.settings, mCurrentUserId: 0, callerUserId: 0
11-18 15:04:58.746  3872  3915 D UsbDeviceManager: updateUsbNotification(false) : mConnected = true, mConfigured = true, mCurrentFunctions = 5, mHostConnected = false, mSourcePower = false, mSinkPower = true, mUsbCharging = true, mUseUsbNotification = true
11-18 15:04:58.746  3872  5962 D GamePkgDataHelper: getGamePkgData(). com.android.settings
11-18 15:04:58.746  8500 17087 W TileUtils: Found com.android.settings.Settings$NotificationAppListActivity for intent Intent { act=com.android.settings.action.SETTINGS pkg=com.android.settings } missing metadata com.android.settings.category
11-18 15:04:58.746  3872  3915 D UsbDeviceManager: updateUsbNotification, set mCurrentFunctionsForNoti : mtp
11-18 15:04:58.746  3872  3915 D DexObserverFW: isDexModeOn() : false
rom1v commented 3 years ago

That's "expected": when you enable/disable this option (MTP), it reconfigures USB and the USB device gets a different vid:pid. As a consequence, all USB connections (adb uses USB) gets disconnected.

Btw, this is not specific to scrcpy, you can reproduce the problem with adb alone: run some adb command which does not return immediately (adb shell or adb logcat), then enable/disable MTP: it will immediately close the running command.

rom1v commented 3 years ago

Whether I click allow or deny, the app always closes with a warning

That's not expected though, one of them should not reconfigure USB. There is probably a setting somewhere on your phone to disable/force the default option.

reilg commented 3 years ago

That's not expected though, one of them should not reconfigure USB. There is probably a setting somewhere on your phone to disable/force the default option.

Ahh thanks. I'll look into that. We can probably close this as a non-issue then.

rom1v commented 3 years ago

(Also, what if you press BACK instead of clicking on one of the two buttons?)