allow Bluetooth swap to work when there is no available internet

#1393
This commit is contained in:
Hans-Christoph Steiner 2018-04-10 22:48:53 +02:00
parent 615e559ce1
commit 9cb53e93d0
2 changed files with 7 additions and 2 deletions

View File

@ -47,6 +47,7 @@ import org.fdroid.fdroid.data.Repo;
import org.fdroid.fdroid.data.RepoProvider; import org.fdroid.fdroid.data.RepoProvider;
import org.fdroid.fdroid.data.Schema; import org.fdroid.fdroid.data.Schema;
import org.fdroid.fdroid.installer.InstallManagerService; import org.fdroid.fdroid.installer.InstallManagerService;
import org.fdroid.fdroid.net.BluetoothDownloader;
import org.fdroid.fdroid.net.ConnectivityMonitorService; import org.fdroid.fdroid.net.ConnectivityMonitorService;
import org.fdroid.fdroid.views.main.MainActivity; import org.fdroid.fdroid.views.main.MainActivity;
@ -332,7 +333,7 @@ public class UpdateService extends IntentService {
boolean forcedUpdate = false; boolean forcedUpdate = false;
String address = null; String address = null;
if (intent != null) { if (intent != null) {
address = intent.getStringExtra(EXTRA_ADDRESS); address = intent.getStringExtra(EXTRA_ADDRESS); // TODO switch to Intent.setData()
manualUpdate = intent.getBooleanExtra(EXTRA_MANUAL_UPDATE, false); manualUpdate = intent.getBooleanExtra(EXTRA_MANUAL_UPDATE, false);
forcedUpdate = intent.getBooleanExtra(EXTRA_FORCED_UPDATE, false); forcedUpdate = intent.getBooleanExtra(EXTRA_FORCED_UPDATE, false);
} }
@ -340,7 +341,9 @@ public class UpdateService extends IntentService {
try { try {
// See if it's time to actually do anything yet... // See if it's time to actually do anything yet...
int netState = ConnectivityMonitorService.getNetworkState(this); int netState = ConnectivityMonitorService.getNetworkState(this);
if (netState == ConnectivityMonitorService.FLAG_NET_UNAVAILABLE) { if (address != null && address.startsWith(BluetoothDownloader.SCHEME)) {
Utils.debugLog(TAG, "skipping internet check, this is bluetooth");
} else if (netState == ConnectivityMonitorService.FLAG_NET_UNAVAILABLE) {
Utils.debugLog(TAG, "No internet, cannot update"); Utils.debugLog(TAG, "No internet, cannot update");
if (manualUpdate) { if (manualUpdate) {
sendNoInternetToast(); sendNoInternetToast();

View File

@ -24,6 +24,8 @@ public class BluetoothDownloader extends Downloader {
private static final String TAG = "BluetoothDownloader"; private static final String TAG = "BluetoothDownloader";
public static final String SCHEME = "bluetooth";
private final BluetoothConnection connection; private final BluetoothConnection connection;
private FileDetails fileDetails; private FileDetails fileDetails;
private final String sourcePath; private final String sourcePath;