Finally found solution via editing
/data/data/com.android.providers.settings/databases/settings.db file via sqlite3. Just
adb pull that file to your computer, if you use stock recovery you must mount userdata partition manually, in that case see Android ADB Shell Recovery Mounting for hints. Also you can't just pull the file directly but copy it inside
adb shell to your sdcard or some intermediary filesystem. Eg.
busybox cp sett* /sdcard
To get rid of the initial setup:
update global set value=1 where name='device_provisioned';
update secure set value=1 where name='user_setup_complete';
insert into secure (name,value) VALUES ('device_provisioned','1');
Yes, the device_provisioned must be present in both tables. However on the stock JB there was no global table, so you don't need to take care of it and the secure table is missing some records we update here so these need to be inserted instead. On stock JB before editing the settings.db run
PRAGMA wal_checkpoint and
PRAGMA journal_mode = DELETE described here: https://stackoverflow.com/a/21258892/881375 otherwise updates on existing rows won't take effect because android will rollback on reboot. For CyanOgenMod 11 just delete the settings.db-journal file and it should be OK.
It was neccessary after pushing the settings.db file back to folder on device to
chmod 660 settings.db
chown system:system settings.db
in this order, because chmod may set the owner and group back to root
USB OTG mouse is still not working sadly, so i guess i must get access for adb anyway.
To enable USB debugging (ADB):
setprop persist.service.adb.enable 1 ('setprop persist.sys.usb.config mtp,adb' if needed)
update secure set value=5037 where name='adb_port';
update global set value=1 where name='adb_enabled';
After booting dialog to confirm PC's fingerprint appears. To avoid this get your adbkey.pub (on linux may be located at ~/.android):
adb push adbkey.pub /data/misc/adb/adbkey.pub
cat adbkey.pub >> adb_keys
After all of this you can
input tap|swipe|text anything to control your phone and get access for bluetooth or OTG mouse/keyboard etc. I hope this helps.
The fingerprint injection is needed for Android 4.2.2+.
Thanks to xda-developers and android issues with adb security at code.google.com.