WIP
This commit is contained in:
parent
cb73e6352c
commit
92430e163e
@ -1,26 +1,37 @@
|
|||||||
package org.fdroid.fdroid.net;
|
package org.fdroid.fdroid.net;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class DownloaderFactory {
|
public class DownloaderFactory {
|
||||||
|
|
||||||
public static Downloader create(String url, Context context)
|
public static Downloader create(String url, Context context) throws IOException {
|
||||||
throws IOException {
|
Uri uri = Uri.parse(url);
|
||||||
if (isOnionAddress(url)) {
|
if (isBluetoothAddress(uri)) {
|
||||||
|
return new BluetoothDownloader(null, uri.getPath(), context);
|
||||||
|
} else if (isOnionAddress(url)) {
|
||||||
return new TorHttpDownloader(url, context);
|
return new TorHttpDownloader(url, context);
|
||||||
|
} else {
|
||||||
|
return new HttpDownloader(url, context);
|
||||||
}
|
}
|
||||||
return new HttpDownloader(url, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Downloader create(String url, File destFile)
|
public static Downloader create(String url, File destFile) throws IOException {
|
||||||
throws IOException {
|
Uri uri = Uri.parse(url);
|
||||||
if (isOnionAddress(url)) {
|
if (isBluetoothAddress(uri)) {
|
||||||
|
return new BluetoothDownloader(null, uri.getPath(), destFile);
|
||||||
|
} else if (isOnionAddress(url)) {
|
||||||
return new TorHttpDownloader(url, destFile);
|
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) {
|
private static boolean isOnionAddress(String url) {
|
||||||
|
@ -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
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user