-
Notifications
You must be signed in to change notification settings - Fork 34
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
Repackaging AWARE features as cordova plugins #501
Comments
The high level goal is that we want to modify the AWARE code as little as possible so that we can pull updates from them as they occur. This implies that the ideal structure will involve a wrapper that represents the cordova bits. First, let us consider the anatomy of an AWARE plugin. It looks like:
So probably the easiest approach is to continue using the ContentProvider architecture for AWARE. In terms of syncing, you can choose to sync to an AWARE server and then merge the data on the server side, or you can write a new SyncAdapter that syncs the data to an e-mission server. Note that every sensor in AWARE has its own sync adapter. But the base class appears to be But that decision is independent of pluginizing the sensor. IMHO, the easiest way to pluginize this code is to leave it untouched and to write a wrapper that inherits from |
You could also choose to do this in two steps:
That will also get you familiar with cordova and reduce the unknown factor. |
There are many examples of cordova plugins on the internet. Including the Cordova battery plugin https://github.com/apache/cordova-plugin-battery-status that you can look at for an example of the the cordova plugin interface. This defines an externally callable method called "start" which sets up the listeners. In your case, that would call I think cordova also has a user guide or some kind of similar documentation. |
You mentioned that each e-mission plugin only runs after the user consents. So in the repackaging, do I need to check for user contents as well? |
It is up to you. You are building your own version of the app and can do whatever you want. Theoretically, you can call So it is possible using the e-mission plugin to skip the consent. I just chose to believe that most people will be careful of consent and gave them the tools to handle it properly. e.g. the So basically if I didn't have the method, then people would have to build it in and everybody is lazy. I made it easier (the default) to start tracking only after consent, and harder to remove it (have to edit onboarding). |
@ariasfelipe also wrote a shake detection plugin that used local processing on the phone to detect shakes. This is a much more scalable solution because otherwise the volume of accelerometer data is too high. He demoed it, but I am not sure how well it works in the real world. |
@xubowenhaoren if you just want an example of wrapping native code in a plugin, I would not recommend the shake detect code, since it is much more complex than you need. The shake detect code does allow the user to configure the prompt that is displayed when the shake is detected. What kind of local processing are you planning to do, and what do you want as the resulting output? |
I want the output to match current AWARE standards, making a functionally equivalent migration. Therefore, I would likely need to follow AWARE's approach of wrapping data. Here is one of their data providers. |
with the approach outlined in #501 (comment) you will continue to use the AWARE data format. In fact, you will continue to use their local storage and their server (at least in step 1). So I am not sure what this comment means. Note that in #501 (comment), I am talking about wrapping code, not data Update 1:You don't care about the AWARE implementation details. Once the AWARE services are launched in the background, they will continue to do their stuff in their way. If that changes in the new rewrite, you are not affected. All you need to do is to wrap the code and launch the aware services properly from the Update 2:In other words, remember all the lectures on software modularity :) focus on the interface and not the implementation. |
Thanks for the clarification. It seems like you've made structural changes to the e-mission-docs and I cannot find your notes on how to add a new plugin to a client. The closest I could find is this deployment guide. |
@xubowenhaoren I don't think I ever had notes on how to add a new plugin to a client. Apache Cordova is standard, well-documented technology, and I don't want to duplicate their documentation. I have added links to the Apache Cordova documentation on creating and managing plugins |
Now, looking back at what you initially suggested last time and what I've done at this point, I'm afraid that my approach has been somewhat misdirected. What I've done is that I tried to copy over AWARE codes, change them to override e-mission methods and fix any dependency issues along the way. With that said, there are certainly AWARE modules (e.g. SSL certificate helpers) that I don't know how to handle yet. I think this is NOT what you meant by "creating wrappers" to codes (not data). |
About the user consent: before we start collectin the user data, we would ask the participant to sign a consent form. This is done before the participants install their apps, and it's very unlikely that the consent criteria need to change during the study. So we don't need to handle consents in this repackaging of the app. |
I suggest that you create a cordova plugin with the following interface. in
in
|
AWARE clients read aware-core status and modify aware-core settings via a central |
Yes. In that case, you would want to do something like in
in
|
I believe that this is the main AWARE service which launches all the other services depending on the settings. |
Hi, I realize that the whole |
searching for "plugin.xml maven", I find the cordova plugin documentation
|
Thanks! But here we have a follow-up problem. Since now we import |
With the FQN, so you would do something like
|
Another follow-up: in line 119, you are linking the project source codes and res files in the |
No. Those are only for source code that will be compiled as part of the plugin, not complied libraries. |
Hello, I wish to add a (placeholder) UI page that will eventually be replaced by the functional Aware UI. Where can I add this page as a fragment on the current e-mission UI? Is it the main.js? |
Probably the easiest is to add a new tab. You can look at examples of current tabs or the angular router documentation. |
<!-- Diary Tab -->
<ion-tab title="Diary" icon="ion-map" href="#/root/main/diary">
<ion-nav-view name="main-diary"></ion-nav-view>
</ion-tab> In the Diary Tab above, what does the |
@xubowenhaoren this is not e-mission specific, this is standard angular-ui-router syntax. There are hundreds of tutorials on angular-ui-router. Please check them out. |
To check if I get this right: The Take the
The As a self-answer to my earlier question , Please address any mistakes or missing pieces. |
We found that during the Cordova call to the native Aware plugin, the Authority it got was However, if you look into the We think that the authority mismatch can be a problem; however, one native Android app that we've worked on, has the package name "com.aware.plugin.cmu.sup". |
Yes, so this mismatch is the reason that the sync adapter is not launching the sync service correctly. If you look at the implementation of So as far as I can figure out,
So I am not sure how it returns Are you sure you are printing the correct authority? You are printing the authority in the plugin code, and not in the broadcaster code which is where the ContentResolver is really called from. Add new logging statements to print the authority right in the
|
JitPack finally fetched my up-to-date commit. Here are the latest syncing logs:
Two points that we can make:
I will revisit the native app and observe its syncing logs tomorrow. |
@xubowenhaoren That is what I said earlier #501 (comment)
Have you checked the steps in
|
Here are the syncing logs from a native AWARE Android client:
|
Hmm, I think I added logs in |
Did you? Can you double check, maybe change the log message to say "inside I only see the provider from
|
If you add the other providers and still can't figure it out, maybe ask the AWARE team how they ensure provider match up? |
That might be acceptable. You can see that native Aware is also calling the sync from |
I've added the "inside |
native Aware is also calling the sync from the same three places (Aware.java, sensor, applications). Not clear which one results in the |
You are right; I shouldn't rely on the logcat orders. Let me attach the latest logs here and ask the AWARE team.
|
I see the account information and provider information for both Aware and Aware Applications
But not for Aware Sensor.
Do you have log statements there too? Why are they not getting printed out? Is that related to
|
Great catch! I added the missing log statement. Currently waiting for JitPack to re-package. |
After adding the log statement, here are the results for the emission plugin:
Here are the results for the native client:
We notice that the even in the native client, the account information doesn't print with |
@xubowenhaoren fair enough. Any response from the AWARE team? |
Not yet. We may need to look at this by ourselves during the meeting. |
There is an even simpler and more obvious check for the account that is used. I am not sure whether you have already tried it. The method signature of
So you can add log statements into the AWARE |
Here are the successful sync messages in the native client:
|
The key to solve the syncing problem is to add the account/provider/authority configuration in your app
|
I tried to automate the provider/authority configuration via While Cordova is able to inject the strings into
|
You also have to set the application ID in https://developer.android.com/studio/build/application-id It looks like it is required, so I am not sure why it is not set in the cordova app. Are there multiple |
Yes the native app is doing this:
But so is Cordova. This is my auto generated
Since the Cordova app already sets the |
Not sure what
to ensure that everything works? We can debug the |
Yes, the hardcode approach works. Here is my latest I will now temporarily shift gears to work on the UI and add more features to the plugin. |
I would just document (for now) that anybody else who wants to use the plugin needs to change the hardcoded value to their own hardcoded app package. We can debug it later. |
Hello, the following issue appeared after I upgrade emission to SDK 29. Feature-wise, the buttons don't interact with the plugin any more. If you wish to recreate the issue, you can use my fork here https://github.com/xubowenhaoren/e-mission-phone/tree/aware
|
@xubowenhaoren you need to remove the dependency on |
Thanks, everything is working again. |
Hello,
After a lengthy trial-and-error of integrating emission into AWARE, we find out that it would be more flexible to merge the AWARE sync adapters and sensors to emission directly. What suggestions do you have for us to get started on the migration?
The text was updated successfully, but these errors were encountered: