Skip to content

Commit

Permalink
Merge pull request #5 from efryntov/main
Browse files Browse the repository at this point in the history
Android native module ConduitModule
  • Loading branch information
tmgrask authored Sep 23, 2024
2 parents 2b6f524 + 955bba8 commit 8777c41
Show file tree
Hide file tree
Showing 46 changed files with 3,460 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
android/app/libs/*.* filter=lfs diff=lfs merge=lfs -text
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ expo-env.d.ts

# git hash version file
src/git-hash.ts


# tunnel core config files
psiphon_config
embedded_server_entries
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# Conduit App

Conduit InProxy runner targetting iOS and Android

## Git LFS Usage

This project uses Git LFS (Large File Storage) to manage large files such as the tunnel core libraries. Please follow the instructions below to ensure you are set up correctly:

### For All Users

1. **Install Git LFS**:
Ensure Git LFS is installed by running:
```bash
git lfs install
```

### For Existing Users (Already Cloned the Repository)

1. **Pull LFS-managed files**:
If you already have the project cloned, run the following command to pull the latest LFS-tracked files:
```bash
git lfs pull
```

### For New Users (Cloning the Repository)

When cloning the repository for the first time, Git LFS will automatically handle the LFS files as part of the clone process:
```bash
git clone <repository-url>
```

### Additional Information

- Git LFS will manage files such as `.aar` libraries, as specified in the `.gitattributes` file.
- Ensure Git LFS is installed to avoid issues with large files.

For more details, visit the [Git LFS documentation](https://git-lfs.github.com/).
36 changes: 36 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ android {
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
}
}

// Enable AIDL generation for the Conduit module
buildFeatures {
aidl true
}
}

// Apply static values from `gradle.properties` to the `android.packagingOptions`
Expand All @@ -165,8 +170,39 @@ android {
}
}
}
// Configure a flatDir repository to resolve Psiphon tunnel-core library
repositories {
flatDir {
dirs "libs"
}
}

dependencies {
// start Conduit module dependencies
// Psiphon lib
implementation (name: 'ca.psiphon', ext: 'aar')

// Autovalue
compileOnly "com.google.auto.value:auto-value-annotations:1.10.4"
annotationProcessor "com.google.auto.value:auto-value:1.10.4"
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.9'

// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.1'

// Worker API
implementation 'androidx.work:work-runtime:2.9.1'
implementation 'androidx.work:work-rxjava2:2.9.1'

// Tests dependencies
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-inline:3.9.0'
testImplementation 'org.robolectric:robolectric:4.11.1'

// end Psiphon dependencies

// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

Expand Down
3 changes: 3 additions & 0 deletions android/app/libs/ca.psiphon.aar
Git LFS file not shown
27 changes: 27 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- Required for the Conduit service -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<!-- Declare use of custom permission for 'service starting' broadcast verification -->
<uses-permission android:name="ca.psiphon.conduit.nativemodule.SERVICE_STARTING_BROADCAST_PERMISSION" />
<!-- Define custom permission for 'service starting' broadcast verification -->
<permission android:name="ca.psiphon.conduit.nativemodule.SERVICE_STARTING_BROADCAST_PERMISSION" android:protectionLevel="signature" />
<!-- End Conduit service requirements -->
<queries>
<intent>
<action android:name="android.intent.action.VIEW"/>
Expand All @@ -29,5 +38,23 @@
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>

<!-- TunnelIntentsProxy activity-alias for handling intents from the Conduit service securely -->
<activity-alias android:name=".TunnelIntentsProxy" android:targetActivity=".MainActivity"/>
<!-- Conduit service -->
<!-- TODO: consider using foregroundServiceType="specialUse"? -->
<service
android:name=".nativemodule.ConduitService"
android:exported="false"
android:foregroundServiceType= "dataSync"
android:label="@string/app_name"
android:process=":ConduitService" />

<!-- Conduit logging content provider -->
<provider
android:name=".nativemodule.logging.LoggingContentProvider"
android:authorities="${applicationId}.log"
android:exported="false"
android:process=":LoggingContentProvider" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ca.psiphon.conduit.nativemodule;

import android.os.Bundle;

interface IConduitClientCallback {
void onProxyStateUpdated(in Bundle proxyStateBundle);
void onProxyActivityStatsUpdated(in Bundle proxyActivityStatsBundle);
void ping();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ca.psiphon.conduit.nativemodule;

import ca.psiphon.conduit.nativemodule.IConduitClientCallback;

interface IConduitService {
void registerClient(IConduitClientCallback client);
void unregisterClient(IConduitClientCallback client);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ca.psiphon.conduit

import android.app.Application
import android.content.res.Configuration
import ca.psiphon.conduit.nativemodule.ConduitPackage

import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
Expand All @@ -21,9 +22,10 @@ class MainApplication : Application(), ReactApplication {
this,
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return PackageList(this).packages
// Add ConduitPackage to the list of packages, since it's not auto-linked.
val packages = PackageList(this).packages.toMutableList()
packages.add(ConduitPackage()) // Add this line
return packages
}

override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
Expand Down
Loading

0 comments on commit 8777c41

Please sign in to comment.