S pen progress
Hello
@s3xxt0y
I am not sure where to post this(please let me know if I better post it somewhere else), but through some experimentation on the spen on the original and current rom, using getevent and logcats, I feel like I found some info, especially exciting regarding the bluetooth, I am not sure it is any useful but I am going to post them for reference, hopefully someone could use them or maybe develop an AOSP bluetooth spen remote app. I know I am going to pay/donate for it
now before I mention all this, there is a couple of apps
SPenCommand or
GMD Spen Gestures that do some of the non-bluetooth work. I am using the GMD app, using which you can create actions when the spen is attached or detached, with which I could simulate the Spen menu in Samsung roms, I bound it to a custom shortcut menu I made with
Xposed Edge app that has all the features of the spen menu. and I even used
tasker to detect if screen is off, to call a note taking app
Squid instead of this menu when it wakes up, simulating the screen off memo.
please forgive my brightscreen and bad video setup but I made a video showing this
Check SPen GMD.zip (attached) for the video
Now to the S Pen buttons, I am going to attach the actual file that has the stuff I captured (Buttons.zip), but here I am going to summarize what I think is happening
Code:
All from the same input device "sec_e-pen", using getevent and doing the following things I get:
[B]Spen Out [/B]
EV_SW 0013 00000001
[B]Spen In [/B]
EV_SW 0013 00000000
_____________________________________
[B]Hover [/B]
EV_KEY BTN_DIGI DOWN digitizer starts sensing the spen
EV_ABS ABS_DISTANCE 00000078 (reports spen distance from screen)
EV_ABS ABS_X 000013a6 (reports spen mouse coordinates)
EV_ABS ABS_Y 00001544 (reports spen mouse coordinates)
EV_KEY BTN_DIGI UP
[U][I][B]((ADDED Nov 10 not in txt file))
[/B][/I][/U][B]Hover and S Button Click [/B]
EV_KEY BTN_DIGI DOWN digitizer starts sensing the spen
EV_ABS ABS_DISTANCE 00000078 (reports spen distance from screen)
EV_ABS ABS_X 000013a6 (reports spen mouse coordinates)
EV_ABS ABS_Y 00001544 (reports spen mouse coordinates)
EV_KEY BTN_STYLUS DOWN (spen button click regardless of it touching)
EV_KEY BTN_STYLUS UP
EV_KEY BTN_DIGI UP
[B]Hover then Spen Touch Screen [/B]
EV_KEY BTN_DIGI DOWN (same as above)
EV_ABS ABS_X 000013a6
EV_ABS ABS_Y 00001544
EV_ABS ABS_DISTANCE 00000078 (distance start getting smaller)
EV_ABS ABS_DISTANCE 0000000a
EV_KEY BTN_TOUCH DOWN (spen touching screen)
EV_ABS ABS_PRESSURE 00000a79 (pressure sensitivity)
EV_ABS ABS_DISTANCE 00000000
EV_ABS ABS_TILT_X 00000002
EV_ABS ABS_TILT_Y 00000001
EV_KEY BTN_TOUCH UP (spen away from screen)
EV_ABS ABS_DISTANCE 00000001
EV_ABS ABS_DISTANCE 00000038
EV_KEY BTN_DIGI UP
Note: every now and then there is EV_SYN SYN_REPORT 00000000 (not sure what does it exactly means)
Now for the exciting part here is a logcat of bluetooth button press in original samsung rom
Code:
11-03 09:02:16.104 8083 8094 D [AirCmd]_BleSpenDriver: GattCallback : onCharacteristicChanged : 68:A8:E1:E3:0D:27 / UUID_BUTTON_EVENT, PERM=0, RAWDATA : [1]DESC_CNT=2 [ DESC : UUID_CHARACTERISTIC_CONFIG, [1 0]] [ DESC : UNDEFINED:00002901-0000-1000-8000-00805f9b34fb, [nodata]]
11-03 09:02:16.104 8083 8094 D [AirCmd]_BleSpenDriver: GattCallback : Button:1
11-03 09:02:16.403 8083 8083 D [AirCmd]_BleSpenClickGestureDetector: sendBleSpenClickEvent : single clicked
11-03 09:02:16.403 8083 8083 D [AirCmd]_RemoteSpenMainController: SpenEventListener : button clicked
11-03 09:02:16.404 8083 8083 D [AirCmd]_ScreenOffAndLockStateActionInvoker: ScreenOffAndLockStateActionInvoker invokeAction : isInteractive is true
11-03 09:02:16.404 8083 8083 D [AirCmd]_ScreenOffAndLockStateActionInvoker: ScreenOffAndLockStateActionInvoker invokeAction : mIsSatisfySpenUnlockCondition is false
11-03 09:02:16.404 8083 8083 D [AirCmd]_ScreenOffAndLockStateActionInvoker: ScreenOffAndLockStateActionInvoker invokeAction : screenOffReason is 3
11-03 09:02:16.405 8083 8083 D [AirCmd]_ScreenOffAndLockStateActionInvoker: ScreenOffAndLockStateActionInvoker invokeAction : Single, double click case
11-03 09:02:16.406 8083 8083 D [AirCmd]_CameraAvailabilityMonitor: isCameraPreviewOn : mIsCameraPreviewOn is false
11-03 09:02:16.409 8083 8083 D [AirCmd]_CameraAvailabilityMonitor: isCameraPreviewOn : mIsCameraPreviewOn is false
11-03 09:02:16.414 8083 8083 D [AirCmd]_MediaControlStateMonitor: getActivePackageName : noti count=5, session count=0
11-03 09:02:16.414 8083 8083 D [AirCmd]_PenActionRule: getAction : get default action data from remote action because pen action data is null.
11-03 09:02:16.414 8083 8083 D [AirCmd]_RemoteSpenMainController: invokeAction : no action present
11-03 09:02:16.414 8083 8083 D AC:AirCommand: onBleFloatingIconAnimationStart hasAction : false, isShowGuidePanel false
11-03 09:02:16.414 8083 8083 I AC:AirCommand_SAUtils: insertEventLog... screenID:105, eventID:1052, detail:com.sec.android.app.launcher_com.android.launcher3.Launcher_none, value:null
11-03 09:02:16.415 8083 8083 D SamsungAnalytics111040: user do not agree
11-03 09:02:16.416 8083 8083 V AC:AirCommand: play : 0x11
11-03 09:02:16.416 8083 8083 D AC:AirCommand: showBleFbShakeAnimator
Long Press
Code:
11-03 10:53:06.258 8083 16804 D [AirCmd]_BleSpenDriver: GattCallback : onCharacteristicChanged : 68:A8:E1:E3:0D:27 / UUID_BUTTON_EVENT, PERM=0, RAWDATA : [2]DESC_CNT=2 [ DESC : UUID_CHARACTERISTIC_CONFIG, [1 0]] [ DESC : UNDEFINED:00002901-0000-1000-8000-00805f9b34fb, [nodata]]
11-03 10:53:06.258 8083 16804 D [AirCmd]_BleSpenDriver: GattCallback : Button:2
11-03 10:53:06.259 8083 8083 D [AirCmd]_RemoteSpenMainController: SpenEventListener : button long clicked
11-03 10:53:06.316 4865 6567 W ActivityManager: Slow operation: 54ms so far, now at getContentProviderImpl: after updateOomAdj
11-03 10:53:06.316 4865 6567 W ActivityManager: Slow operation: 54ms so far, now at getContentProviderImpl: done!
11-03 10:53:06.323 8083 8083 D [AirCmd]_ScreenOffAndLockStateActionInvoker: ScreenOffAndLockStateActionInvoker invokeAction : isInteractive is true
11-03 10:53:06.324 8083 8083 D [AirCmd]_ScreenOffAndLockStateActionInvoker: ScreenOffAndLockStateActionInvoker invokeAction : mIsSatisfySpenUnlockCondition is false
11-03 10:53:06.324 8083 8083 D [AirCmd]_ScreenOffAndLockStateActionInvoker: ScreenOffAndLockStateActionInvoker invokeAction : screenOffReason is 3
11-03 10:53:06.325 8083 8083 D [AirCmd]_ScreenOffAndLockStateActionInvoker: ScreenOffAndLockStateActionInvoker invokeAction : Long click case
11-03 10:53:06.332 8083 8083 D [AirCmd]_CameraAvailabilityMonitor: isCameraPreviewOn : mIsCameraPreviewOn is false
11-03 10:53:06.337 8083 8083 D [AirCmd]_CameraAvailabilityMonitor: isCameraPreviewOn : mIsCameraPreviewOn is false
11-03 10:53:06.345 8083 8083 D [AirCmd]_MediaControlStateMonitor: getActivePackageName : noti count=3, session count=1
11-03 10:53:06.346 8083 8083 D [AirCmd]_RemoteSpenMainController: showGuidePanel : rule is not proper type. ruleType=BASE
11-03 10:53:06.346 8083 8083 D [AirCmd]_PenActionInvoker: invokeAction : AppLaunchActionData
so I on your the AOSP AICP ROM, I did install two apps,
LightBlue and
nRF Connect that utilize the same BLE technology as the S Pen, I was excited that it was that simple it connected to it, you can read different services, I could find one that said Button State, and it turns out that if subscribing to the service using GATT server, you can stay connected to the device and wait for the specific service changes. (not my level though)
I was able to pair the device, read some information below is a screenshot
and specifically this service that screenshoted below has the name Button State, if service is subscribed to, (clicking the button) when clicking the button will give 01, if click and hold gives 02. screenshot below
I was sad to discover than neither of the apps does connect to tasker, nor easy to make them run & connect to spen by default on boot.
but nevertheless, I believe the info above is the key, a person that has some knowledge in Android app making and BLE libraries, has the will, and the time to invest can be a hero in this forum and maybe potential for some business, these would be the event triggers to create shortcuts, this will make the bluetooth in the spen functional in AOSP or maybe even allow to generalize it to any device e.g. people can hook up tasker to their smartwatches or so.
and I will go back to my daydreaming
