question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Restarts always on connecting/disconnecting a keyboard

See original GitHub issue

Home Assistant Android version: 2022.6.0-full Android version: 12 Phone model: Galaxy S10 Home Assistant version: Coer 2022.6.6 Supervisor 2022.05.3 OS 8.2

Last working Home Assistant release (if known):

Description of problem: When I connect or disconnect a BT keyboard to my phone with the companion app on the screen, the companion app always restarts.

Traceback (if applicable, to get the logs you may refer to: https://companion.home-assistant.io/docs/troubleshooting/faqs/#android-crash-logs):


Screenshot of problem:

Additional information:

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jpelgromcommented, Jun 20, 2022

I don’t think this is a device specific issue, when plugging in a USB dongle with a keyboard the activity also restarts for me on a Google Pixel 4a. It is a documented configuration change, and by default this will cause the activity to restart. The ‘issue’ is just more apparent with Home Assistant because the frontend is reloaded.

This config change is only overruled in onboarding (keyboardHidden in manifest).

Relevant log:

2022-06-20 15:40:28.704 1204-3777/? I/android.hardware.usb.aidl-service: port0
2022-06-20 15:40:28.706 1204-3777/? I/android.hardware.usb.aidl-service: 0:port0 connected:0 canChangeMode:1 canChagedata:0 canChangePower:0 usbDataEnabled:1
2022-06-20 15:40:28.706 1204-3777/? I/android.hardware.usb.aidl-service: ContaminantDetectionStatus:2 ContaminantProtectionStatus:0
2022-06-20 15:40:28.706 1204-3777/? I/android.hardware.usb.aidl-service: powerTransferLimited:0
(...)
2022-06-20 15:40:29.169 1949-2555/? D/EventHub: No input device configuration file found for device 'Logitech USB Receiver'.
2022-06-20 15:40:29.175 1949-2555/? I/EventHub: usingClockIoctl=true
2022-06-20 15:40:29.175 1949-2555/? I/EventHub: New device: id=33, fd=554, path='/dev/input/event6', name='Logitech USB Receiver', classes=KEYBOARD | ALPHAKEY | EXTERNAL, configuration='', keyLayout='/system/usr/keylayout/Generic.kl', keyCharacterMap='/system/usr/keychars/Generic.kcm', builtinKeyboard=false, 
2022-06-20 15:40:29.175 1949-2555/? I/InputReader: Device added: id=33, eventHubId=33, name='Logitech USB Receiver', descriptor='6dc166bb9105a09b4af455800f7b9eafa8e88f88',sources=0x00000101
(...)
2022-06-20 15:40:29.177 1949-2554/? I/ActivityTaskManager: Config changes=30 {1.0 204mcc16mnc [en_US,nl_NL] ldltr sw411dp w411dp h815dp 420dpi nrml long hdr widecg port finger qwerty/v/v -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 2340) mAppBounds=Rect(0, 136 - 1080, 2277) mMaxBounds=Rect(0, 0 - 1080, 2340) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.6734 fontWeightAdjustment=0}
(...)
2022-06-20 15:40:29.207 1949-2555/? D/EventHub: No input device configuration file found for device 'Logitech USB Receiver'.
2022-06-20 15:40:29.211 1949-2555/? W/EventHub: Unable to disable kernel key repeat for /dev/input/event7: Function not implemented
2022-06-20 15:40:29.211 1949-2555/? I/EventHub: usingClockIoctl=true
2022-06-20 15:40:29.211 1949-2555/? I/EventHub: New device: id=34, fd=577, path='/dev/input/event7', name='Logitech USB Receiver', classes=KEYBOARD | CURSOR | DPAD | JOYSTICK | EXTERNAL, configuration='', keyLayout='/system/usr/keylayout/Generic.kl', keyCharacterMap='/system/usr/keychars/Generic.kcm', builtinKeyboard=false, 
(...)
2022-06-20 15:40:29.212 1949-2554/? I/WindowManager: Override config changes=30 {1.0 204mcc16mnc [en_US,nl_NL] ldltr sw411dp w411dp h815dp 420dpi nrml long hdr widecg port finger qwerty/v/v -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 2340) mAppBounds=Rect(0, 136 - 1080, 2277) mMaxBounds=Rect(0, 0 - 1080, 2340) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.6734 fontWeightAdjustment=0} for displayId=0
(...)
2022-06-20 15:40:29.224 1949-2555/? I/InputReader: Device added: id=34, eventHubId=34, name='Logitech USB Receiver', descriptor='ba865588b7fa5b43a560ab5d830fab516a90bbb0',sources=0x01002313
(...)
2022-06-20 15:40:29.288 7442-26942/io.homeassistant.companion.android.debug V/FA: Activity paused, time: 307212278
2022-06-20 15:40:29.290 7442-26941/io.homeassistant.companion.android.debug V/FA: onActivityCreated
(...)
2022-06-20 15:40:29.330 7442-7442/io.homeassistant.companion.android.debug I/System.out: recordForce value 6
2022-06-20 15:40:29.331 7442-7442/io.homeassistant.companion.android.debug D/WebviewActivity: Current webview package com.google.android.webview and version 102.0.5005.125
2022-06-20 15:40:29.335 7442-26942/io.homeassistant.companion.android.debug V/FA: Activity resumed, time: 307212363

When plugging in the dongle I also see multiple android.intent.action.BATTERY_CHANGED broadcasts in the logs and WorkManager starting and a few hundred ms later cancelling the SensorWorker job, perhaps this is also causing the stack trace you’re seeing @dshokouhi ?

2022-06-20 15:40:29.451 7442-7483/io.homeassistant.companion.android.debug I/WM-WorkerWrapper: Work [ id=f0d4f857-17e6-4365-a618-c30de0a36ca6, tags={ io.homeassistant.companion.android.sensors.SensorWorker } ] was cancelled
    java.util.concurrent.CancellationException: Task was cancelled.
        at androidx.work.impl.utils.futures.AbstractFuture.cancellationExceptionWithCause(AbstractFuture.java:1184)
        at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:514)
        at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
        at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:311)
        at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
        at java.lang.Thread.run(Thread.java:1012)
0reactions
dshokouhicommented, Jun 20, 2022

perhaps this is also causing the stack trace you’re seeing @dshokouhi ?

I believe the cancellation is caused by the restarted activity because we can see the webview package log statement again shortly after the log I mentioned which is just before the cancellation.

I needed all three of keyboard|keyboardHidden|navigation. The documentation says the navigation config “Should never normally happen”, but it actually happened with keyboard connection.

Awesome thank you for testing that! Please feel free to submit the PR so we can get that corrected 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

What to Do If Your Keyboard Keeps Disconnecting on ...
What to Do If Your Keyboard Keeps Disconnecting on Windows · 1. Restart the System · 2. Check the USB Port · 3....
Read more >
Keyboard Keeps Disconnecting And Reconnecting? Here's ...
In most cases, the keyboard keeps disconnecting due to issues with the components (cables, ports, internal keyboard parts, etc.).
Read more >
restart and no connection anymore with mouse and keyboard
Try the following: The keyboard may not be properly connected to the USB port. Try disconnecting and reconnecting the keyboard to the USB...
Read more >
Fix: Keyboard Keeps Disconnecting and Reconnecting in ...
Fix: Keyboard Keeps Disconnecting and Reconnecting in Windows 10 [MiniTool Tips] ; Method 1: Turn off Power-Saving Option · expand the Keyboards ......
Read more >
Keyboard keeps disconnecting in Windows 11/10 [Fixed]
Why does my keyboard keeps disconnecting? · Misconfigured settings · Power supply issues · Wireless or Bluetooth connection problems · Outdated ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found