Allow bluetooth:// URLs to be parsed by java.net.URL.
Sets a stream handler in FDroidApp which understands bluetooth:// URLs and returns a non-functioning URL handler for such URLs. The reason it is non-funcitoning is because the openConnection() function is not being used by the BluetoothDownloader at this point. In the absense of this, a MalformedURLException is thrown. The bluetooth stuff is still broken, but it is not broken in this way any more.
This commit is contained in:
parent
6bfd76caf2
commit
930c906460
@ -33,6 +33,7 @@ import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache;
|
||||
@ -50,9 +51,14 @@ import org.fdroid.fdroid.net.IconDownloader;
|
||||
import org.fdroid.fdroid.net.WifiStateChangeService;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
import java.security.Security;
|
||||
import java.util.Locale;
|
||||
|
||||
import sun.net.www.protocol.bluetooth.Handler;
|
||||
|
||||
public class FDroidApp extends Application {
|
||||
|
||||
// for the local repo on this device, all static since there is only one
|
||||
@ -173,6 +179,16 @@ public class FDroidApp extends Application {
|
||||
}
|
||||
});
|
||||
|
||||
// This is added so that the bluetooth:// scheme we use for URLs the BluetoothDownloader
|
||||
// understands is not treated as invalid by the java.net.URL class. The actual Handler does
|
||||
// nothing, but its presence is enough.
|
||||
URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
|
||||
@Override
|
||||
public URLStreamHandler createURLStreamHandler(String protocol) {
|
||||
return TextUtils.equals(protocol, "bluetooth") ? new Handler() : null;
|
||||
}
|
||||
});
|
||||
|
||||
// Clear cached apk files. We used to just remove them after they'd
|
||||
// been installed, but this causes problems for proprietary gapps
|
||||
// users since the introduction of verification (on pre-4.2 Android),
|
||||
|
@ -70,7 +70,7 @@ public class RepoUpdater {
|
||||
|
||||
public List<Apk> getApks() { return apks; }
|
||||
|
||||
protected URL getIndexAddress() throws MalformedURLException {
|
||||
private URL getIndexAddress() throws MalformedURLException {
|
||||
String urlString = repo.address + "/index.jar";
|
||||
try {
|
||||
String versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
|
||||
|
@ -63,6 +63,7 @@ import java.util.TimerTask;
|
||||
*
|
||||
* TODO: Show "Waiting for other device to finish setting up swap" when only F-Droid shown in swap
|
||||
* TODO: Handle "not connected to wifi" more gracefully. For example, Bonjour discovery falls over.
|
||||
* TODO: When unable to reach the swap repo, but viewing apps to swap, show relevant feedback when attempting to download and install.
|
||||
* TODO: Remove peers from list of peers when no longer "visible".
|
||||
* TODO: Feedback for "Setting up (wifi|bluetooth)" in start swap view is not as immediate as I had hoped.
|
||||
* TODO: Turn off bluetooth after cancelling/timing out if we turned it on.
|
||||
@ -70,7 +71,7 @@ import java.util.TimerTask;
|
||||
*
|
||||
* TODO: Starting wifi after cancelling swap and beginning again doesn't work properly
|
||||
* TODO: Scan QR hangs when updating repoo. Swapper was 2.3.3 and Swappee was 5.0
|
||||
*
|
||||
* TODO: Showing the progress bar during install doesn't work when the view is inflated again, or when the adapter is scrolled off screen and back again.
|
||||
*/
|
||||
public class SwapService extends Service {
|
||||
|
||||
|
17
F-Droid/src/sun/net/www/protocol/bluetooth/Handler.java
Normal file
17
F-Droid/src/sun/net/www/protocol/bluetooth/Handler.java
Normal file
@ -0,0 +1,17 @@
|
||||
package sun.net.www.protocol.bluetooth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
|
||||
/**
|
||||
* This class is added so that the bluetooth:// scheme we use for the {@link org.fdroid.fdroid.net.BluetoothDownloader}
|
||||
* is not treated as invalid by the {@link URL} class.
|
||||
*/
|
||||
public class Handler extends URLStreamHandler {
|
||||
@Override
|
||||
protected URLConnection openConnection(URL u) throws IOException {
|
||||
throw new UnsupportedOperationException("openConnection() not supported on bluetooth:// URLs");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user