Android Question Capture hardware button press using an intent

Kevin Golding

Member
Licensed User
Longtime User
I'm trying to capture a hardware SOS button to start a b4a app. I've attached the adb USB debugger to the device and got the following when I pressed the button:

B4X:
02-05 17:42:57.972   944  1046 D SOS     : android.intent.action.SOS.down

I've created a new b4a app and have tried using a Service, Activity & Receiver to capture the button unsuccessfully, and I'm seeking advice on what else to try, please.

B4X:
AddServiceText(SOSService,
<intent-filter>
    <action android:name="android.intent.action.SOS.down" />
</intent-filter>)

AddReceiverText(SOSIntent,
<intent-filter>
    <action android:name="android.intent.action.SOS.down" />
</intent-filter>)

AddActivityText(SOSActivity,
<intent-filter>
    <action android:name="android.intent.action.SOS.down" />
</intent-filter>)
 

Attachments

  • SOS_2025-02-05_1829.zip
    11.4 KB · Views: 32

Kevin Golding

Member
Licensed User
Longtime User
It's a Ruggear 360, and it has a built-in app "LWP". I have requested more information from the manufacturer.

I have captured the log below, which includes the line
B4X:
02-07 10:17:23.459   940   979 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.SOS.down flg=0x10000030 (has extras) } to b4a.example/.sosintent
which makes me think my app isn't configured correctly?

B4X:
02-07 10:17:23.399   940  1047 D SideKey : currentApp = com.ruggear.mandowndetection
02-07 10:17:23.400   940  1047 D SideKey : SOSKeyDown OK
02-07 10:17:23.402   940  1047 E ActivityManager: Sending non-protected broadcast com.kodiak.intent.action.KEYCODE_SOS from system 940:system/1000 pkg android
02-07 10:17:23.402   940  1047 E ActivityManager: java.lang.Throwable
02-07 10:17:23.402   940  1047 E ActivityManager:       at com.android.server.am.ActivityManagerService.checkBroadcastFromSystem(ActivityManagerService.java:14977)
02-07 10:17:23.402   940  1047 E ActivityManager:       at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:15618)
02-07 10:17:23.402   940  1047 E ActivityManager:       at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:14994)
02-07 10:17:23.402   940  1047 E ActivityManager:       at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:15777)
02-07 10:17:23.402   940  1047 E ActivityManager:       at android.app.ContextImpl.sendBroadcastAsUser(ContextImpl.java:1225)
02-07 10:17:23.402   940  1047 E ActivityManager:       at com.android.server.policy.PhoneWindowManager.interceptKeyBeforeQueueing(PhoneWindowManager.java:4065)
02-07 10:17:23.402   940  1047 E ActivityManager:       at com.android.server.wm.InputManagerCallback.interceptKeyBeforeQueueing(InputManagerCallback.java:164)
02-07 10:17:23.402   940  1047 E ActivityManager:       at com.android.server.input.InputManagerService.interceptKeyBeforeQueueing(InputManagerService.java:1827)
02-07 10:17:23.407   940  1047 I DropBoxManagerService: add tag=system_server_wtf isTagEnabled=true flags=0x2
02-07 10:17:23.451   940  1047 W AES     : Exception Log handling...
02-07 10:17:23.456   940  1047 D AES     : ExceptionLog: notify aed, process:system_server pid:940 cause:system_server_wtf
02-07 10:17:23.456   940  1047 W AES     : skip for Exp level 0
02-07 10:17:23.457   940  1047 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1046 com.android.server.policy.PhoneWindowManager.interceptKeyBeforeQueueing:4072 com.android.server.wm.InputManagerCallback.interceptKeyBeforeQueueing:164 com.android.server.input.InputManagerService.interceptKeyBeforeQueueing:1827 <bottom of call stack>
02-07 10:17:23.458   940  1047 D SOS     : android.intent.action.SOS.down
02-07 10:17:23.459   940  1047 W InputDispatcher: Excessive delay in interceptKeyBeforeQueueing; took 60 ms
02-07 10:17:23.459   940   979 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.SOS.down flg=0x10000030 (has extras) } to b4a.example/.sosintent
02-07 10:17:23.578   940  1047 D SideKey : currentApp = com.ruggear.mandowndetection
02-07 10:17:23.579   940  1047 D SideKey : SOSKeyUp OK
02-07 10:17:23.581   940  1047 E ActivityManager: Sending non-protected broadcast com.kodiak.intent.action.KEYCODE_SOS from system 940:system/1000 pkg android
02-07 10:17:23.581   940  1047 E ActivityManager: java.lang.Throwable
02-07 10:17:23.581   940  1047 E ActivityManager:       at com.android.server.am.ActivityManagerService.checkBroadcastFromSystem(ActivityManagerService.java:14977)
02-07 10:17:23.581   940  1047 E ActivityManager:       at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:15618)
02-07 10:17:23.581   940  1047 E ActivityManager:       at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:14994)
02-07 10:17:23.581   940  1047 E ActivityManager:       at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:15777)
02-07 10:17:23.581   940  1047 E ActivityManager:       at android.app.ContextImpl.sendBroadcastAsUser(ContextImpl.java:1225)
02-07 10:17:23.581   940  1047 E ActivityManager:       at com.android.server.policy.PhoneWindowManager.interceptKeyBeforeQueueing(PhoneWindowManager.java:4085)
02-07 10:17:23.581   940  1047 E ActivityManager:       at com.android.server.wm.InputManagerCallback.interceptKeyBeforeQueueing(InputManagerCallback.java:164)
02-07 10:17:23.581   940  1047 E ActivityManager:       at com.android.server.input.InputManagerService.interceptKeyBeforeQueueing(InputManagerService.java:1827)
02-07 10:17:23.585   940  1047 I DropBoxManagerService: add tag=system_server_wtf isTagEnabled=true flags=0x2
02-07 10:17:23.665   940  1047 W AES     : Exception Log handling...
02-07 10:17:23.670   940  1047 D AES     : ExceptionLog: notify aed, process:system_server pid:940 cause:system_server_wtf
02-07 10:17:23.670   940  1047 W AES     : skip for Exp level 0
02-07 10:17:23.671   940  1047 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1046 com.android.server.policy.PhoneWindowManager.interceptKeyBeforeQueueing:4093 com.android.server.wm.InputManagerCallback.interceptKeyBeforeQueueing:164 com.android.server.input.InputManagerService.interceptKeyBeforeQueueing:1827 <bottom of call stack>
02-07 10:17:23.672   940  1047 D SOS     : android.intent.action.SOS.up
02-07 10:17:23.672   940  1047 W InputDispatcher: Excessive delay in interceptKeyBeforeQueueing; took 95 ms
^C
 
Upvote 0

Kevin Golding

Member
Licensed User
Longtime User
The manufacturer has sent this information:

B4X:
Please check from below about the boardcast intent:
Press: android.intent.action.SOS.down
Release: android.intent.action.SOS.up
Key String: KEYCODE_SOS
Key Value: 1079

If I use a foreground service, should the app be able to see the keypress and/or intent?
 
Upvote 0
Top