Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8874167 authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

1200: rename everything to AdvancedPrivacy

parent a0ee04ea
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
PrivacyCentralApp
 No newline at end of file
AdvancedPrivacy
+5 −5
Original line number Diff line number Diff line
# PrivacyCentral Development Guide
# AdvancedPrivacy Development Guide
This guide contains development related information to help a developer in getting better understanding of project structure.

## Architecture
The architecture of PrivacyCentralApp is based on [clean architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html). For presentation layer, we use  [Model-View-Intent](http://hannesdorfmann.com/android/model-view-intent/) design pattern which is a unidirectional reactive flow pattern. We use it in conjunction to ViewModel to make our features lifecycle aware. Our android app is having single activity multiple fragments.
The architecture of AdvancedPrivacy is based on [clean architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html). For presentation layer, we use  [Model-View-Intent](http://hannesdorfmann.com/android/model-view-intent/) design pattern which is a unidirectional reactive flow pattern. We use it in conjunction to ViewModel to make our features lifecycle aware. Our android app is having single activity multiple fragments.

### Clean Architecture
Clean architecture is the building block of PrivacyCentralApp. This architecture is based on the following principles:
Clean architecture is the building block of AdvancedPrivacy. This architecture is based on the following principles:
1. **Independent of Frameworks**. The architecture does not depend on the existence of some library of feature laden software. This allows you to use such frameworks as tools, rather than having to cram your system into their limited constraints.
2. **Testable**. The business rules can be tested without the UI, Database, Web Server, or any other external element.
3. **Independent of UI**. The UI can change easily, without changing the rest of the system. A Web UI could be replaced with a console UI, for example, without changing the business rules.
@@ -19,7 +19,7 @@ Clean architecture is the building block of PrivacyCentralApp. This architecture
<img src="art/AbstractMVI.png" width="500" height="333">

MVI is used at the presentation layer of clean architecture. It is very much similar to [Redux](https://redux.js.org/) in terms of implementation and working. It has three main components.
- **View**: This is where activities, fragments and other android components live. It is responsible for publishing user intent/actions to the model and rendering the state returned by the model. In PrivacyCentralApp, it is just an interface which is implemented by android components.
- **View**: This is where activities, fragments and other android components live. It is responsible for publishing user intent/actions to the model and rendering the state returned by the model. In AdvancedPrivacy, it is just an interface which is implemented by android components.
- **Intent**: In context of our app, we call them actions. These are simple data classes having any extra payload like inputs, ids etc.
- **Model (data layer at presentation level)**: This is responsible for processing the actions, communicating with domain use-cases and mutating the state of the model. It acts as a Store from redux but for our use case, we call it a **Feature**.

@@ -33,7 +33,7 @@ Elements of a feature:
2. **State**: Simple POJO (kotlin data class) representing various UI states of the application.
3. **SingleEventProducer**: This is a function which is invoked by the reducer to publish single events (that can/should only be consumed once like displaying toast, snackbar message or sending an analytics event). This function takes action, effect, current state as input and it returns a `SingleEvent`. By default this function is null for any Feature.

### Architecture Overview of PrivacyCentral App
### Architecture Overview of AdvancedPrivacy App

![](art/privacycentral-arch.png)

+15 −4
Original line number Diff line number Diff line
@@ -101,7 +101,6 @@ modules must be build and deployed in the following order:
  - ./gradlew :privacymodule-api:assembleRelease
  - ./gradlew --console=verbose publishToMavenLocal // To make it available locally for dev.
  - ./gradlew --console=verbose publish // To publish it on gitlab for release.
- [privacymodule-e](../../../e_privacycentral_privacymodulese)
- [privacymodule-tor](../../../e_privacycentral_privacymoduletor)
- [app]

@@ -117,6 +116,18 @@ For building from CLI, you can execute this command:
You can build the apk locally by using above instructions or you can download the latest stable apk from `master` branch pipeline.

### To run apk on /e/OS devices

If you are running your tests on a `/test` build, the debug buildtype already sign it with the appropriate key, and without the persistant flag, to allow further updates.
But the first time, to replace the AdvancedPrivacy app, embeded in the test build, you have to use the following commands: 

    ```shell
    adb root && adb remount
    adb push your_advanced_privacy_debug_build.apk /system/priv-app/AdvancedPrivacy/AdvancedPrivacy.apk
    adb shell kill -9 $(adb shell pidof -s foundation.e.advancedprivacy)
    ```

#### AdvancedPrivacy requiement against the system

AdvancedPrivacy needs to be installed as system app and whitelisting in order to grant some system specific permissions. Follow these steps to make it work properly on /e/OS

1. From `Developer options`, enable `Android debugging` and `Rooted debugging`
@@ -135,13 +146,13 @@ AdvancedPrivacy needs to be installed as system app and whitelisting in order to
    ```

1. Push permissions whitelist.
    - it requires the whitelisting [privapp-permissions-foundation.e.privacycentralapp.xml](privapp-permissions-foundation.e.privacycentralapp.xml) file that can be found in the project repository.
    - it requires the whitelisting [privapp-permissions-foundation.e.advancedprivacy.xml](privapp-permissions-foundation.e.advancedprivacy.xml) file that can be found in the project repository.
    - then use the following command
        ```bash
        adb push privapp-permissions-foundation.e.privacycentralapp.xml /system/etc/permissions/
        adb push privapp-permissions-foundation.e.advancedprivacy.xml /system/etc/permissions/
        ```

1. Allow the fake location service to run in background. Add <allow-in-power-save package="foundation.e.privacycentralapp.e" /> in the file /system/etc/permissions/platform.xml .
1. Allow the fake location service to run in background. Add <allow-in-power-save package="foundation.e.advancedprivacy" /> in the file /system/etc/permissions/platform.xml .
   
1. Reboot the device
    ```shell
+8 −8
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="foundation.e.privacycentralapp"
    package="foundation.e.advancedprivacy"
    >

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
@@ -40,15 +40,15 @@
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:name=".PrivacyCentralApplication"
        android:name="foundation.e.advancedprivacy.AdvancedPrivacyApplication"
        android:persistent="${persistent}"
        android:supportsRtl="true"
        android:theme="@style/Theme.PrivacyCentralApp"
        android:theme="@style/Theme.AdvancedPrivacy"
        android:windowSoftInputMode="adjustResize"
        tools:replace="android:icon,android:label,android:theme"
        >
        <receiver
            android:name=".common.BootCompletedReceiver"
            android:name="foundation.e.advancedprivacy.common.BootCompletedReceiver"
            android:exported="true"
            >
            <intent-filter>
@@ -59,7 +59,7 @@

        <receiver
            android:exported="true"
            android:name=".Widget"
            android:name="foundation.e.advancedprivacy.Widget"
            >
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
@@ -70,14 +70,14 @@
                android:resource="@xml/widget_info"
                />
        </receiver>
        <receiver android:name=".widget.WidgetCommandReceiver"
        <receiver android:name="foundation.e.advancedprivacy.widget.WidgetCommandReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="toggle_privacy" />
            </intent-filter>
        </receiver>

        <activity android:name=".main.MainActivity"
        <activity android:name="foundation.e.advancedprivacy.main.MainActivity"
            android:launchMode="singleTask"
            android:exported="true"
            >
@@ -87,7 +87,7 @@
            </intent-filter>
        </activity>
        <activity
            android:name=".common.WarningDialog"
            android:name="foundation.e.advancedprivacy.common.WarningDialog"
            android:noHistory="true"
            android:excludeFromRecents="true"
            android:launchMode="singleInstance"
+2 −2
Original line number Diff line number Diff line
@@ -15,13 +15,13 @@
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.privacycentralapp
package foundation.e.advancedprivacy

import android.app.Application
import com.mapbox.mapboxsdk.Mapbox
import foundation.e.lib.telemetry.Telemetry

class PrivacyCentralApplication : Application() {
class AdvancedPrivacyApplication : Application() {

    // Initialize the dependency container.
    val dependencyContainer: DependencyContainer by lazy { DependencyContainer(this) }
Loading