Implementation Plan – Standalone OpenVPN Integration

The goal is to remove the dependency on the external “OpenVPN for Android” app and integrate the VPN connection logic directly into the current application.

User Review Required

IMPORTANT

Library Dependency: We will use the ics-openvpn library (via JitPack). This is a large library that includes native code. The build time will increase, and the APK size will grow significantly (approx +10-15MB).

WARNING

Manifest Merging: The ics-openvpn library has its own 

AndroidManifest.xml. We need to ensure our minSdk and other attributes are compatible. The current minSdk is 23, which is good.

Proposed Changes

Build Configuration

[MODIFY] build.gradle

  • Add ics-openvpn dependency.
  • Enable multiDex (likely needed due to library size).

[MODIFY] settings.gradle

  • Add jitpack.io repository if not present (usually in project-level, but settings.gradle is common in newer Android).

Core Logic

[MODIFY] MainActivity.java

  • Remove check_openvpn_installed logic.
  • Remove launch_openvpn intent logic.
  • Remove “Install OpenVPN” UI prompts.
  • Implement startVpnInternal():
    • Parse the downloaded .ovpn file using ics-openvpn‘s VpnProfile parser.
    • Add the profile to ProfileManager.
    • Start the VPN service using VPNLaunchHelper or direct Service intent.
  • Implement IOpenVPNStatusCallback to update UI (Connected/Connecting/Failed) directly from the internal service.

[MODIFY] AndroidManifest.xml

  • Add VpnService declaration (if not automatically merged).
  • Add BIND_VPN_SERVICE permission.

UI Changes

[MODIFY] activity_main.xml

  • (Optional) Remove the “Install OpenVPN” button/banner since it’s no longer needed.

Verification Plan

Automated Tests

  • None available for VPN connectivity in this environment.

Manual Verification

  • Build Check: Ensure Gradle syncs and builds (I will rely on code correctness as I cannot run Gradle).
  • Code Review: Verify that MainActivity correctly imports the new classes and calls the internal service instead of startActivity.

上面是第一次的 plan, 但其實會出錯, 因為,

 @build.gradle  > Could not resolve all files for configuration ':app:debugCompileClasspath'.
   > Could not find com.github.schwabe:ics-openvpn:0.7.9.
     Required by:
         project :app

第2次 plan 如下:

Implementation Plan – Integrate Local OpenVPN Library

The goal is to remove the dependency on the external “OpenVPN for Android” app and the remote ics-openvpn artifact, instead using the local vpnLib module directly.

User Review Required

IMPORTANT

I will be modifying the build files to switch from a remote dependency to a local module. This assumes vpnLib is a complete and working copy of the OpenVPN library.

Proposed Changes

Build Configuration

[MODIFY] settings.gradle

  • Ensure :vpnLib is included in the project.

[MODIFY] app/build.gradle

  • Remove implementation 'com.github.schwabe:ics-openvpn:0.7.9' (or similar).
  • Add implementation project(':vpnLib').

Code Integration

[MODIFY] MainActivity.java

  • Ensure imports point to the local library packages (likely de.blinkt.openvpn...).
  • Verify startVpnInternal and stopVpn use the local service correctly.

Verification Plan

Automated Tests

  • Run ./gradlew assembleDebug to verify the build succeeds with the local dependency.

Manual Verification

  • The user will need to run the app and verify that clicking “Connect” starts the VPN process without prompting to install an external app.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *