-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement service notification and wakelocks, fix gyro-less case #45
implement service notification and wakelocks, fix gyro-less case #45
Conversation
Pressing the notification creates a new activity, hence the need to save settings when starting.
Sensor event handler and send both modify member variables, and run asynchronously. Both blocks need synchronization as result. Gyro-less data is mostly useless, but it's not necessary to crash on such devices in any case.
Prevents service from dying along with the app on close, or on lack of memory for the app.
b9c801b
to
6898a3c
Compare
First test didnt work, nothing is received in FreePIE, will have to debug and see whats going on |
Hmm, onServiceConnected never fires which sets udpSenderService |
If startService()'s commented out, does it connect then? |
I cant try at work since its a bank and we cant connect our phones to the dev-env :D |
It worked fine as-is on my 4.1.2 device. Docs say it's possible to both bind to and start a service. But who knows. |
I have a HTC m8 with Android 4.4.4 |
Only whitespace remained to be committed, there's nothing left to be added. There should be some indication as to why the service isn't starting. Keep in mind that commenting out startService() won't make it work fully, only provide insight as to why it won't start. It needs to be there for the service not to die when the app exits/hits oom. |
Try changing getBaseContext() to "this" on the added line. It's useless for me to do it, as it works either way on my 4.1.2 device.
|
Don't create array values in each iteration of the sensor event loop. This puts unnecessary GC pressure and so CPU load. Reuse initialized values held in member variables instead.
Java contains condition variable primitive in the "Object" base class. CyclicBarrier isn't suited for this.
Registering an event handler from a running application makes that event handler go stale and presumably crash when a service calls it after the app doesn't exist anymore. Switch to polling for debug events. This also simplifies logic where the service had to keep track of the handler and whether to generate the events.
@AndersMalmgren please include project files for Android Studio, import changes directory structure and that breaks Git workflow of committing all the time. The last commit changes the way service's started (getBaseContext() -> this) and it might fix it for you. |
Tested-by: @KyokushinPL Reported-by: @KyokushinPL
Now it works! :D synchronized (this_) {
this_.wait();
Send();
} What was wrong with using cyclic barrier? |
@AndersMalmgren is there anything against a third flag in datagrams for accelerometer output? We'd need integration on the phone due to sparsity of updates over the wire. I'd also like to shorten the very long list of device ids. |
I do not follow you, if you are doing it on the phone what do you need a new flag for? |
To avoid breaking old clients with no accelerometer data. opentrack can use data when it's available. What's status on merging? Should we fork the app? The changes make the app usable to begin with. |
Ok so we had a byte telling which sensors are supported in raw mode? |
There's room for 8 bits so there's no need to break the protocol any further. |
I don't think I understand what you wanna do, but I'm running a high fever so my brain is not what it should be :) |
@AndersMalmgren and how your brain? ;) fever gone? Can we back to 'work' ;) and pull changes? |
implement service notification and wakelocks, fix gyro-less case
Its merged, but we still need to discuss the changes for devices thats missing raw sensors (I thought that opentrack onlt used the orientation data btw) |
It only uses orientation data, yes. In case of gyro lackage zeros are returned. I haven't done the change to push position data over the wire yet. |
If you do please do it in a branch since I'm not 100 sure how you will do it :) |
position data? A IMU cant be used for position only rotation, the acc is way to inaccurate for it edit: Now I understand what you ment with integrating the acc on the device, bu the result will be way to inaccurate for any kind of usage, you need militray grade senors for inertial navigation :D |
It's doable using a spring to push the value gradually toward zero. That's how it was done in opentrack for Rift DK1. For a case of @KyokushinPL sitting with phone on his head the spring does the trick since he spends most of the time near zero anyway. |
I guess best approuch is just a new flag called Translation or something? |
Yeah, position it at the end so old receiver can ignore the data without changes. Remains to be seen how much error there is. A day always has too few hours to do all the stuff though. |
Will the spring code be in Opentrack/FreePIE or in the App? |
Needs to be in the app to integrate as quickly as possible. Does the app introduce heavy load when running for you too? Even on slower settings 30-50% of one core is used no matter what. |
Around 8% |
@AndersMalmgren Could you compile app and sign it? We would like to put it to opentrack soon as possible and give to users updated solution. |
You dont wanna wait for the acc stuff? |
It's gonna take a while given it's some actual math usage, more than calling an API as per before previous changes. It's also not guaranteed to work out. We'd like to release opentrack 2.3 finally and having a signed build of the .apk sure helps. cheers due to xmas! |
I'm out of town for xmas, but will remote and fix |
@AndersMalmgren Merry Xmas from octopus team ;) |
@AndersMalmgren the octopus approves. Cheers, and happy winter solstice. |
There you go guys Happy Xmas! If any of you C++ pros wanna give me the perfect xmas present it would be to implement support for decrypted TrackIR titles :D |
You can use the same .dll that we do. The way to give it pad keys is described in freetrack protocol. The memory mapping's in the header and you can use it from p/invoke. And the scramble keys are in the .csv file. |
The code is not in the opentrack repo? |
Here's the data structures used by the code: https://github.com/opentrack/opentrack/blob/unstable/freetrackclient/fttypes.h Keep in mind that as per C memory layout FTData is embedded inside FTHeap. There are no pointers used -- after all, memory can't be shared across processed like that. Use this logic to transmit game id along with the padding key embedded in the .csv file https://github.com/opentrack/opentrack/blob/unstable/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp. Keep in mind the "correct()" function misnomer. It runs first to verify whether protocol prerequisites are in place, but here is misused as initialization code. |
runOnUiThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
if (udpSenderService != null && udpSenderService.isRunning()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a mistake here. Please add checking chkDebug.isChecked()
before allocating data with new
. It runs on UI thread anyway so it can do with no locks.
No description provided.