[LG G7 ThinQ  Guides, News, & Discussion] dbolivar:
Okay guys, I'm starting this thread to join forces on finally taking control of the Google Assistant key on the G7. I've read several posts here on XDA and elsewhere about this, and it seems LG has taken a great effort in NOT allowing a simple remap of this key (other phones have been offering some flexibility lately). The best workaround I've found (and personally used) is to use something like Automate or Tasker to catch when Google Assistant is launched, kill it and open something else. Not very clean and there's some delay, but it sort of works.

But now that I have rooted my phone, I decided to investigate it deeper. What I've found:

The keycode of this button is 165.

It is intercepted by WindowManager, LGPhoneWindowManager and HotKeyController.

Finally, the following package/class is invoked: com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity

When we disable this button on the settings, it is still intercepted by the same processes, but HotKeyController and LGPhoneWindowManager flag the key as "disabled" and do nothing.

Since this keycode is being intercepted, other applications (such as KeyEvent) can't detect it.

These are the relevant logcat entries for when the button is enabled:

05-27 22:13:18.614 4175 4568 D InputReader: Key event: device=10 type=0x0001 value=0x00000001 when=28854380687000
05-27 22:13:18.615 4175 4568 D WindowManager: interceptKeyTq keycode=165 down=true injected=false mDisplayState=2 interactive=true keyguardActive=false flags=0x8 policyFlags=22000000
05-27 22:13:19.074 4175 4248 D LGPhoneWindowManager: hotKeyRelease count= : 1
05-27 22:13:19.075 4175 4248 D LGPhoneWindowManager: hotKeyActions : mode=11, interactive=true, type=1
05-27 22:13:19.075 4175 4248 D HotKeyController: launch Assist: 1
05-27 22:13:19.077 4175 4248 I HotKeyController: don't show Guide Dialog by HotKeyController.
05-27 22:13:19.128 4715 4734 V AssistManager: Voice open
05-27 22:13:19.136 24832 24845 I AssistStructure: Flattened final assist data: 11288 bytes, containing 1 windows, 111 views
05-27 22:13:19.198 4175 5072 I ActivityManager: START u0 {flg=0x10008000 cmp=com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity (has extras)} from uid 10185

And these are the logcat entries for when the button is disabled:

05-29 12:43:46.816 4126 4557 D WindowManager: interceptKeyTq keycode=165 down=true injected=false mDisplayState=2 interactive=true keyguardActive=false flags=0x8 policyFlags=22000000
05-29 12:43:46.837 4126 4557 D HotKeyController: AI key setting disabled
05-29 12:43:46.838 4126 4557 I LGPhoneWindowManager: hotkey disabled
05-29 12:43:46.964 4126 4557 D InputReader: Key event: device=10 type=0x0001 value=0x00000000 when=11419706112000
05-29 12:43:46.966 4126 4557 D WindowManager: interceptKeyTq keycode=165 down=false injected=false mDisplayState=2 interactive=true keyguardActive=false flags=0x8 policyFlags=22000000
05-29 12:43:46.974 4126 4557 D HotKeyController: AI key setting disabled
05-29 12:43:46.974 4126 4557 I LGPhoneWindowManager: hotkey disabled

Any suggestions on where to go from here? Some ideas: somehow detect this button by monitoring logcat (probably not very efficient); spoof com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity with something else (don't know if it's possible).