From 92430e163e1777bbee9447e59fab5ea8dbe0d165 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Thu, 14 May 2015 18:40:25 +1000 Subject: [PATCH] WIP --- .../fdroid/fdroid/net/DownloaderFactory.java | 27 +++++++++++++------ bluetooth-notes.txt | 21 --------------- 2 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 bluetooth-notes.txt diff --git a/F-Droid/src/org/fdroid/fdroid/net/DownloaderFactory.java b/F-Droid/src/org/fdroid/fdroid/net/DownloaderFactory.java index a6cae1438..59192b932 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/DownloaderFactory.java +++ b/F-Droid/src/org/fdroid/fdroid/net/DownloaderFactory.java @@ -1,26 +1,37 @@ package org.fdroid.fdroid.net; import android.content.Context; +import android.net.Uri; import java.io.File; import java.io.IOException; public class DownloaderFactory { - public static Downloader create(String url, Context context) - throws IOException { - if (isOnionAddress(url)) { + public static Downloader create(String url, Context context) throws IOException { + Uri uri = Uri.parse(url); + if (isBluetoothAddress(uri)) { + return new BluetoothDownloader(null, uri.getPath(), context); + } else if (isOnionAddress(url)) { return new TorHttpDownloader(url, context); + } else { + return new HttpDownloader(url, context); } - return new HttpDownloader(url, context); } - public static Downloader create(String url, File destFile) - throws IOException { - if (isOnionAddress(url)) { + public static Downloader create(String url, File destFile) throws IOException { + Uri uri = Uri.parse(url); + if (isBluetoothAddress(uri)) { + return new BluetoothDownloader(null, uri.getPath(), destFile); + } else if (isOnionAddress(url)) { return new TorHttpDownloader(url, destFile); + } else { + return new HttpDownloader(url, destFile); } - return new HttpDownloader(url, destFile); + } + + private static boolean isBluetoothAddress(Uri uri) { + return "bluetooth".equalsIgnoreCase(uri.getScheme()); } private static boolean isOnionAddress(String url) { diff --git a/bluetooth-notes.txt b/bluetooth-notes.txt deleted file mode 100644 index 918d0ca13..000000000 --- a/bluetooth-notes.txt +++ /dev/null @@ -1,21 +0,0 @@ -One is server, the other is the client (always the case with Bluetooth). - -When does the pairing happen? I can think of a few times: - -Use case 1 - - * Swapper decides to use bluetooth to send apps to others. - * Selects "Use bluetooth instead" on the "join wifi" screen. - * Starts a bluetooth server - + Make itself discoverable - + Opens a bluetooth server socket - + Waits for incoming client connections. - - * Swapee opens swap workflow - * Selects the bluetooth option - * Is asked to pair with nearby bluetooth devices, using the F-Droid UUID to make sure it doesn't connect to, e.g. bluetooth headphones. - * Stays connected in the background - * Adds the repo as per usual (with a url such as bluetooth://device-mac-address) - * When repo updates, it uses the open connection to get data - * If the connection has closed, attempts to reconnect - * Same when downloading files -