enviroCar / enviroCar-app

enviroCar Android Application
https://envirocar.org
GNU General Public License v3.0
87 stars 153 forks source link

New lpt Integration and some Bug fixes #994

Closed prvn2004 closed 4 months ago

prvn2004 commented 9 months ago

GSoC 2023 — End Term Report Project: Integrating LocationPrivacyToolkit in Envirocar App

Check Detailed Log at bottom of document for detailed Info for work done.

Most of code changes are in this Pull Request : https://github.com/enviroCar/enviroCar-app/pull/994

  1. Project Goals: The primary goal of the project was to integrate the LocationPrivacyToolkit (LPT) into the Envirocar App. Enhance user privacy by allowing them to configure location settings and permissions. Ensure the smooth functioning of location-related features in the app.

  2. What I Did: Explored the LPT codebase to understand its functionality and methods. Added LPT as a module in the Envirocar app. Worked on setting accuracy and interval preferences in the privacy configuration. Integrated LPT’s LocationPrivacyActivity into the app. Changing LPT theme for matching the app’s theme. Tested track recording functionality with LPT. Enhanced LPT to provide users with more flexibility in configuring accuracy and intervals. Added a dialog notification in case location access was blocked. Researched methods for integrating remote LPT changes into the local repository. Solved dependency resolution errors related to LPT integration. Resolved internal processor duplicate errors in the toolkit. Integrating the Changed LPT again and testing New methods. Worked on many bugs. (See Detailed Log)

  3. Current State: The new LPT is successfully integrated into the Envirocar app. Users can configure accuracy, intervals, and location access preferences, along with Dialog notifications warn users about location access issues. Track recording works seamlessly with LPT.

  4. What’s Left to Do: Improve map-related features and reliability.

  5. Merged Code Upstream: Successfully integrated LPT as a module in the Envirocar app. Resolved various dependency and duplicate class issues during integration.

  6. Challenges and Learnings: Overcame dependency conflicts and duplicate class issues. Improved understanding of Android app development and integration. Gained experience in handling real-world bugs and debugging. Learned to collaborate with project mentors effectively. Conclusion: The project has made significant progress in integrating the LocationPrivacyToolkit into the Envirocar App, enhancing user privacy and configuration options. Several bugs have been addressed, and the project is in a stable state. Future work will focus on further improvements and bug fixes. Acknowledgments: I would like to express my gratitude to my mentor, Benjamin Pross, for his guidance and support throughout this project. I also thank the GSoC community for this valuable learning experience.

Detailed Log : Preparing code in android studio and searching for location instances in the app and core modules to work on. And figuring out things and preparing new docs. Output: I found a few files containing code related to location and setting files containing code for fragments and activity and how they work together.

To ensure everything works, it is essential to understand the code for the location toolkit and attempt to implement a method from the tool into the app. Output: Figuring out code and having a little more understanding of code.

Implement a test-setting preference and use the functions of locationPrivacyConfig in a new fragment. Inputs: I created a new XML file named "location_privacy_preferences" with code for two preferences. Then, I added fragment code in the "SettingActivity" to get and set the privacy configuration. Problem: I need help accessing the privacy configuration. I will investigate and resolve the issue. Output: I couldn't solve the above problem and will try to work on it again the next day, but I created a few files, and most of the code seems correct.

I am trying to complete the work of 24 April of making test-setting preferences and using functions of locationPrivacyConfig in a new fragment. Inputs: Replaced default setting fragment in SettingActivity with new fragment for testing. Problems: I have finished creating the XML file for the settings preference screen and added code to retrieve preferences from the default and store them in the privacy config of the location privacy toolkit. However, I am still determining whether it works correctly, and I will attempt to determine this tomorrow. Output: Obtaining distance in Logcat, using code from AccuracyProcessorTest.kt, and setting accuracy and interval works correctly. The following code was added to SettingActivity.java code added in SettingActivity.java

I created a few query questions for the next steps and had an online meeting with Benjamin Pross at 3:40 pm. He gave me some advice and a file to read, and we had to use the location privacy toolkit there. File : enviroCar-app/LocationProvider.java at master · enviroCar/enviroCar-app Input: Just a meeting only. Output: I have received a new file to work on. What next: To improve the previous code for settings, we must treat it as an absolute file instead of a test. Additionally, we should enhance the code to make it more readable and aesthetically pleasing. Please review the contents of the new file named LocationProvider.java for further guidance.

Accuracy and interval preferences work correctly and can be set and retrieved from the location privacy configuration. Worked on code and fixed a bug in the setter for context and preference changes. Output: Everything is working correctly. This includes setting the accuracy and interval in location privacy configuration and retrieving them using the methods described in LPC. Next: study the code for LocationProvider.java and determine what to do with it.

Was trying to build the project for the last 3 days and after hours of work. It is working now. Inputs: I changed the JDK version from 17 to 11 for the Butterknife library issue. And for the Android test library problem, I modified the code of the files where the problem was arising. And the rest is working fine for now. I also wrote a blog post 1. File : Cause: superclass access check failed: class butterknife. Compiler.ButterKnifeProcessor$RScanner (in unnamed module @0x5e33c4db) cannot access class com.sun.tools.javac.tree.TreeScanner (in module jdk. compiler) because module jdk. the compiler does not export com.sun.tools.javac.tree to unnamed module @0x5e33c4db error1 Output: The build is successful, and the app is launching on the phone. What next: Add the updated location privacy toolkit in the envirocar app as a module and check for errors.

Added the Location privacy toolkit in the Envirocar android app as a module, successfully working. Input: Added LocationPrivacyToolkit in the Envirocar Android app as a module. And made some errors but solved them. Used LocationActivity class from the toolkit in the app by importing it as a class. Output: Everything is working fine; the setting screen worked fine. Problems: The issue in some builds, as a compiled version of both modules, was not matching, so it was proposing an error, but I solved it by changing compiled version of the envirocar app. There was an error in importing the class, as the build was not recognizing the path of activity. I solved it by adding view binding in the envirocar app repository. Next: Create a design in Figma for the setting screen and discuss with Mr. Pross where to put that screen and improve blog 1.

I added the LocationPrivacyActivity from the toolkit to the othersFragment. Input: I added the LocationPrivacyActivity from the toolkit to the OthersFragment of the app. I created a section named "Location toolkit," which, when clicked, opens the activity. I also changed the theme of the activity to match the Enivrocar app theme. I added the necessary color to the color XML file, and everything works fine for setting location-related configurations. Output: User can now set their location privacy configuration succefully. Problem: The only problem I encountered was working with the LPT Activity XML file, but I resolved it. Next: Check for any bugs in the configuration of the Privacy Toolkit and learn how to use it in the app.

I changed branches and checked that track recording works correctly with LPT. Input: I changed the branch from "master" to "LocationPrivacyToolkit" and merged all the changes from the previous branch. This process took 1-2 days. I also verified and debugged the Track recording functionality to ensure it works correctly with LPT and that all configurations function properly. Output: Track recording is now possible and working correctly. Problem: Doesn’t know what to do next and where to proceed. Next, have a meeting with Benjamin to discuss the next steps and determine if any changes are necessary.

I ran some tests on TrackRecording and read more of TrackRecord's code (Trying to understand the architecture. better write documentation for it.) Input: I ran some debugging tests on track recording to see if track recording is working fine and debugging using logs and UI usage. Output: Everything has been working fine till now in App. Next: I had a meeting with Mr. Pross on June 13th. We discussed what to do next since the location toolkit is working correctly. He directed me to test two other configurations. I also asked if we could make some changes to LPT, as it currently provides limited flexibility to users. I plan to edit LPT to make the configuration more flexible and provide more options. Work on checking the other 2 configurations and produce some report of testing of LPT in the track recording and go through it for how it can be improved. And I was testing everything out of them. Make sure you test all aspects of implementation. Work on changing the LPT for better flexibility. Edited Location Privacy Toolkit to provide users more flexibility, read more code and observed app behavior, and tested auto-deletion configuration. Input: I edited the LPT and made changes in intervals of range of accuracy and intervals. And tested the Autodeletion configuration by logging the last stored location and tracking the location in track recording. Output: Users now have more interval in accuracy and interval. And auto-deletion configuration is working fine. Problems: Identified a potential bug that could be solved next week. Next: Whenever a user blocks access to a location using LPT, the Track recording receives their last known location. If auto-deletion is enabled and the last known location is deleted, a null is sent to the Track recording. In this case, we can ask the user to grant access to real-time location data, explaining that their access is blocked and affecting the service. Have a meeting with Mr. Pross and discuss if we could show a dialog notification to turn on the access to the location in LPT.

I added a dialog notification if access is blocked to the notification in the track recording screen and changed the text of the upload track dialog notification. Input: I had a meeting with Mr. Pross to discuss making the dialog notification and created a function to check the access value from LPT and show a notification if true. I changed the code and text for the upload track dialog notification. Output: The user will now see a dialog notification while track recording and location access are turned off in LPT. Users will now see a notification warning about their data when it will be processed, and how to delete it while uploading a track. Next: The dialog notification when uploading the track is shown only for 1-2 seconds; in that time, the user cannot read long warning text, and there is no option for canceling the track uploading if the user wants. Should we make a confirm button before uploading the track and give the user some time to read the warning? Have a meeting with Mr. Pross and discuss what to do next and that all things till now are completed, And create a pull request for current changes.

Research methods for getting Changes of LPT from the remote repository directly into the local repository. and worked on migration of New LPT changes. Input: I researched methods to integrate remote LPT directly into the Envirocar app and Worked on Migration from Old LPT to newly changed LPT. Output: Found two methods for Integrating LPT in the Envirocar app :

One way could be if SIMPORT people could create a new repository containing only the LPT submodule. We can create a submodule repo in the Envirocar app. And if they can't do that, one way is to pull the LPT repo by yourself, init a submodule repo in the LPT submodule and push it to the newly created remote repo. And then use that remote repo in the envirocar app as a submodule. The catch here will be that every time, anyone has to clone the LPT repo and init submodule in it and pull changes from the main repo and then push the changes to a repo that we created newly. Problem: I get a dependency resolution error when using the new LPT. The error is due to duplicate classes in multiple LPT and Envirocar app module dependencies. Dependency giving error : maplibre1 = 'org.maplibre.gl:android-sdk:10.0.2' maplibre2 = 'org.maplibre.gl:android-sdk-turf:5.9.0' maplibre3 = 'org.maplibre.gl:android-plugin-annotation-v9:1.0.0' in LPT module gradle file and Mapbox SDK dependency in the Envirocar app gradle file. Error Description : Duplicate class dependency resolution error. Next: Meet with Mr. Pross and discuss how to solve the dependency conflict issue and discuss new changes in LPT. Next: Meet with Mr. Pross and discuss how to solve the dependency conflict issue and the new changes in the new LPT.

Solved the dependency resolution error and correctly integrated the new LPT in Envirocar App. Solved Duplicate Internal processor error in Toolkit. Input: I did research and analyzed the Dependency conflict by looking at the Dependency tree and solving the issue by removing the Mapbox SDK library from the Envirocar app and adding three map libre modules present in LPT. and also adding the missing core module as an extra—and analyzed code that was giving internal processor duplicate error and removing all the internal processor before adding them again due to reinitialization of LPT. I have identified a few potential bugs in LPT and Envirocar apps. Output: new LPT is integrated successfully, Internal processors are not duplicating, and everything works fine in LPT other than some potential bugs. Problems: When there are no locations in history, and we click the delete history icon, then we get a crash due to a null return; The track recording counter shows time late while it is already started counting. MOM from the meeting: Work on fixing bugs. And confirm button, bro. Next from Mr. Pross: He will be testing the app to see if it works fine. And then, suggest anything, and we can work on sharing the location feature in Envirocar App.

Delete Location button Error: when there is no location on the map, and we use the delete functionality, it gives a null location error. Error : Delete button error Return the 0L value if the value is invalid and the problem is solved. Check gist for more Info.

bluetooth error : I discovered that when permission for nearby devices is not given, Bluetooth is on, and we open the app, a crash occurs. One way to fix it is by asking for nearby devices' permission at the start of the app. Fix for the error: Add nearly devices permission at the start of the application. MOM with MR. Pross: Working on a Bluetooth bug. There needs to be more info about the map in the location history and exclusion zone. Work on this and check if it is possible to change the map with a more reliable map. Making settings in LPT more convenient to users. Solved the lower sdk version error of Location privacy Toolkit ; In lower sdk;s there is no option for asking for background location permission, in code there was an todo task which was giving error on runtime. Removing it will solve the error and in lower sdks backgorund access will be shown as ‘no’ in the UI. Files Included : Location privacy config Activity (line 92 - 103)

Error log : Process: org.envirocar.app, PID: 18845 kotlin.NotImplementedError: An operation is not implemented: VERSION.SDK_INT < Q at de.fh.muenster.locationprivacytoolkit.ui.LocationPrivacyConfigActivity.onCreate(LocationPrivacyConfigActivity.kt:95)