summaryrefslogtreecommitdiff
path: root/README.md
blob: 83f0cf7b4b6717dde3bfeb111bd53046479bbd37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# AdvancedPrivacy
An app to let you control and protect your privacy.

Forked from https://github.com/LedgerProject/e_privacycentralapp.

This fork implements advanced location privacy features to eliminate
user-space detection vectors.

# Features
The following features are currently part of AdvancedPrivacy app.
1. Centralized overview dashboard.
2. Fake location.
3. Hiding IP address.
4. Manage granular permissions.
5. Control trackers across apps.

# Technologies
- Kotlin as main language
- Kotlin coroutines and flow for asynchronous code
- AndroidX (core-ktx, fragment-ktx, and lifecycle etc.)
- Google Material Design component for UI elements
- Timber for logging
- Room for database (may use datastore too)
- Hilt for DI
- MapBox for map support
- LeakCanary for keeping an eye on memory leaks.
- Junit for unit testing
- Espresso for integration testing.
- 

# Flavours
This app comes in two flavours, one for /e/OS and second one for other android (where app doesn't have system access). For more information refer to [Architecture Guide](DEVELOPMENT.md)

# Testing
Need to write test and add code coverage.

# Development

## Setup
You can use any latest stable version of android studio to be able to build this app.

## Supported Versions
- Minimum SDK: 24 (Android N)
- Compile SDK: 30 (Android R)
- Target SDK: 30 (Android R)

## API Keys
This project uses [Sentry](https://sentry.io) for telemetry and crash reports,  [Mapbox](https://docs.mapbox.com/android/maps/guides/install/) sdk for displaying maps. To download and use the mapbox sdk, you need to supply API key and secret and set them as follows:

### For local build
You can set them in local.properties
```
MAPBOX_KEY=<insert mapbox public key>
SENTRY_DSN=<insert sentry dsn>
```
**IMP: Never add this file to version control.**

### For CI build
When building in CI environment, we don't have local.properties file. So the following environment variables must be set:
```
export MAPBOX_KEY=<insert mapbox public key>
export SENTRY_DSN=<insert sentry dsn>
```

## Code Style and Quality
This project uses [ktlint](https://github.com/pinterest/ktlint), provided via the [spotless](https://github.com/diffplug/spotless) gradle plugin. To maintain the same code style, all the codestyle configuration has been bundled into the project.

To check for any codestyle related error, `./gradlew spotlessCheck`. Use `./gradlew spotlessApply` to autoformat in order to fix any code quality related issues.

### Setting up pre-commit hooks
To strictly enforce the code quality, this project has a pre-commit hook which is triggered everytime before you commit any changes (only applies to *.kt, *.gradle, *.md and *.gitignore). You must setup the pre-commit hook before doing any changes to the project. For that, this project has a script which can executed as follows:
```bash
./hooks/pre-commit
```

## Build dependencies

TrackerFilter won't work unless your rom was build with this specific netd project:

[android_system_netd](../../../e_privacycentral_android_system_netd)

To create an /e/ build with this specific project, follow the documentation to create an usual /e/ build for your device https://doc.e.foundation/devices until `repo sync`

After `repo sync` all the sources, replace
```
system/netd
```

with this repo [android_system_netd](../../../e_privacycentral_android_system_netd)

then run the build as usual

This won't include advanced privacy, you still need to build the app.


This app requires different modules that must be built indivually and pushed to a local maven repository or our gitlab

modules must be build and deployed in the following order:

- privacymodule-api : 
  - ./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-tor](../../../e_privacycentral_privacymoduletor)
- [app]

## Build
If you'd like to build AdvancedPrivacy locally, you should be able to just clone and build with no issues.

For building from CLI, you can execute use `./gradlew assemble<Flavor><Debug|Release>` command:

Example for eOs debug version
```bash
./gradlew assembleEDebug
```

## How to use AdvancedPrivacy apk
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`
1. Sign the apk with platform certificate. You can use this command to do that

    ```shell
    apksigner sign --key platform.pk8 --cert platform.x509.pem AdvancedPrivacy.apk app-e-release-unsigned.apk
    ```

    If you are running your tests on an `/test` build, you can find keys at https://gitlab.e.foundation/e/os/android_build/-/tree/v1-q/target/product/security
1. Install apk as system app and push permissions whitelist with following commands:
    ```shell
    adb root && adb remount
    adb shell mkdir system/priv-app/AdvancedPrivacy
    adb push AdvancedPrivacy.apk system/priv-app/AdvancedPrivacy
    ```

1. Push permissions whitelist.
    - 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.advancedprivacy.xml /system/etc/permissions/
        ```

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
    adb reboot
    ```

### To run apk on stock android devices
You can simply install the apk. Keep in that mind all features won't be available on stock android devices.

> Voila !!!, AdvancedPrivacy is installed successfully in your device.

# Distribution
This project can be distributed as prebuilt apk with /e/OS or it can be published on other app stores for non /e/OS devices.

# For developers and contributers
Please refer to [Development Guide](DEVELOPMENT.md) for detailed instructions about project structure, architecture, design patterns and testing guide.

# License
```
Copyright (C) 2021 ECORP

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program.  If not, see https://www.gnu.org/licenses/.
```