Skip to content

Commit

Permalink
Wifi autoconnect (#18)
Browse files Browse the repository at this point in the history
* Updated bromite base version, added new build scripts

* Sync dependencies on fresh checkout for bromite

* Add initial WifiAutoConnect patch

* Remove unnecessary patch

* Add wifi autoconnect to patch list

* Fix import of wifi_autoconnect package

* Add downloader script for wifi_autoconnect

* Remove gateway from patch

* Fix syntax error in new strings

* Fix wifi autoconnect aar metadata

* Build APK for trichrome

* Fix java syntax errors

* Fix more syntax errors

* Fix naming for button label

* Add agregore deps to trichrome template

* Dont accidentally overwrite loadable_modules

* Use public APK for build

* Add null check for wifiAutoConnect methods

* Default to Android 10 (sdk 29) as min version

* Account for menu not being open

* Show wifi state using toast

* Fix up toast import

* Fix method name for toast

* Use latest daemon, specify default port

* Don't try to change menu item text and just use toast
  • Loading branch information
RangerMauve authored May 15, 2022
1 parent 0c906a9 commit 8a33f55
Show file tree
Hide file tree
Showing 7 changed files with 738 additions and 6 deletions.
1 change: 1 addition & 0 deletions agregore_patch_order.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0001-AG-Rebrand-to-Agregore.patch
0001-AG-IPFS-Daemon.patch
0001-AG-Handle-IPFS-and-IPNS-URLs.patch
0001-AG-Wifi-Auto-Connect.patch
2 changes: 1 addition & 1 deletion daemon_tag.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
zeroconf-fix-2
v1.0.4
76 changes: 76 additions & 0 deletions download_wifi_autoconnect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env python3

'''
This script will trigger a new build of the browser
'''

import os
import argparse
import requests

from _load_vars import load_vars

parser = argparse.ArgumentParser(
description='Download the WifiAutoConnect AAR file'
)

tag_file_path = os.path.normpath(os.path.join(
os.path.realpath(__file__),
"../wifi_auto_connect_tag.txt"
))

DEFAULT_VERSION = ""

with open(tag_file_path, "r", encoding="utf8") as tag_file:
DEFAULT_VERSION = tag_file.read().strip()

DEFAULT_REPO = 'RangerMauve/WifiAutoConnect-Android'
DEFAULT_BINARY_NAME = 'WifiAutoConnect.aar'

parser.add_argument(
'--version',
default=DEFAULT_VERSION,
help="What version tag to use for the library"
)

parser.add_argument(
'--repo',
default=DEFAULT_REPO,
help="Name of the github repo to download from"
)

parser.add_argument(
'--binary_name',
default=DEFAULT_BINARY_NAME,
help="Name of the aar file to download from the release"
)

args = load_vars(parser)

chromium = args["chromium"]
env = args["env"]

version = args["version"]
repo = args["repo"]
binary_name = args["binary_name"]

url = f"https://github.com/{repo}/releases/download/{version}/{binary_name}"

# TODO: Reuse script for downloading

print(f"Downloading {url}")

response = requests.get(url, allow_redirects=True, stream=True)

# Raise an exception if we get a 404
response.raise_for_status()

download_location = os.path.join(
chromium,
"third_party/wifi_autoconnect/WifiAutoConnect.aar"
)

with open(download_location, 'wb') as file:
file.write(response.content)

print("Done!")
42 changes: 37 additions & 5 deletions patches/0001-AG-IPFS-Daemon.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ Subject: [PATCH] AG IPFS Daemon
chrome/android/java/AndroidManifest.xml | 11 +
.../java/AndroidManifest_trichrome_chrome.xml | 2 +-
.../values/channel_constants.xml | 1 +
.../mauve/agregore/mobile/IPFSService.java | 152 +++++++++++++
.../mauve/agregore/mobile/IPFSService.java | 153 +++++++++++++
.../mauve/agregore/mobile/IPFSStarter.java | 94 ++++++++
.../chrome/browser/app/ChromeActivity.java | 13 ++
chrome/android/trichrome.gni | 12 +-
third_party/agregore-ipfs-daemon/BUILD.gn | 9 +
third_party/agregore-ipfs-daemon/LICENSE | 201 ++++++++++++++++++
third_party/agregore-ipfs-daemon/OWNERS | 2 +
.../agregore-ipfs-daemon/README.chromium | 3 +
.../agregore-ipfs-daemon.info | 17 ++
third_party/agregore-ipfs-daemon/cipd.yaml | 4 +
.../arcore-android-sdk-client/proguard.txt | 2 +-
17 files changed, 526 insertions(+), 2 deletions(-)
18 files changed, 538 insertions(+), 3 deletions(-)
create mode 100644 chrome/android/java/src/moe/mauve/agregore/mobile/IPFSService.java
create mode 100644 chrome/android/java/src/moe/mauve/agregore/mobile/IPFSStarter.java
create mode 100644 third_party/agregore-ipfs-daemon/BUILD.gn
Expand Down Expand Up @@ -144,7 +145,7 @@ new file mode 100644
index 0000000000..a3efe3a500
--- /dev/null
+++ b/chrome/android/java/src/moe/mauve/agregore/mobile/IPFSService.java
@@ -0,0 +1,152 @@
@@ -0,0 +1,153 @@
+package moe.mauve.agregore.mobile;
+
+import android.os.Messenger;
Expand Down Expand Up @@ -172,6 +173,7 @@ index 0000000000..a3efe3a500
+
+public class IPFSService extends Service implements Handler.Callback {
+ public static String TAG = "IPFSService";
+ public static String GATEWAY_PORT = "8080";
+
+ /**
+ * Commands for the service to send over the Messenger
Expand Down Expand Up @@ -266,7 +268,7 @@ index 0000000000..a3efe3a500
+ String interfaces = getInterfaces();
+ Log.i(TAG, repoLocation);
+ Log.i(TAG, interfaces);
+ Gateway.run(repoLocation, interfaces);
+ Gateway.run(repoLocation, GATEWAY_PORT, interfaces);
+ }
+
+ public void stopProcess() {
Expand Down Expand Up @@ -442,6 +444,36 @@ index 98043ddb5c..aa0f279dff 100644
super.onDestroy();
}

diff --git a/chrome/android/trichrome.gni b/chrome/android/trichrome.gni
index c3b67bc38a..cf70acfc80 100644
--- a/chrome/android/trichrome.gni
+++ b/chrome/android/trichrome.gni
@@ -126,6 +126,16 @@ template("trichrome_library_apk_tmpl") {
"//third_party/icu:icu_assets",
]

+ # Agregore resources
+ deps += [ "//third_party/agregore-ipfs-daemon:agregore_ipfs_daemon_java" ]
+ if (!defined(loadable_modules)) {
+ loadable_modules = []
+ }
+ _agregore_ipfs_daemon_dir = get_label_info(
+ "//third_party/agregore-ipfs-daemon:agregore_ipfs_daemon_java($default_toolchain)",
+ "target_out_dir") + "/agregore_ipfs_daemon_java/jni"
+ loadable_modules += [ "$_agregore_ipfs_daemon_dir/armeabi-v7a/libgojni.so" ]
+
# Flag whether additional deps and libs should be included for each ABI.
_include_primary_support = false
_include_secondary_support = false
@@ -159,7 +169,7 @@ template("trichrome_library_apk_tmpl") {
"//chrome/android:chrome_public_v8_assets",
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
- loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
+ loadable_modules += [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
}
if (_include_secondary_support) {
_trampoline =
diff --git a/third_party/agregore-ipfs-daemon/BUILD.gn b/third_party/agregore-ipfs-daemon/BUILD.gn
new file mode 100644
index 0000000000..abdac2b60b
Expand Down Expand Up @@ -726,5 +758,5 @@ index 761eb9511d..009269c15b 100644
\ No newline at end of file
+}
--
2.32.0
2.34.1

Loading

0 comments on commit 8a33f55

Please sign in to comment.