Give Samuel heart attack by removing Dagger
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -51,7 +51,7 @@ public class LogExporterPreference extends Preference {
|
||||
}
|
||||
|
||||
private void exportLog() {
|
||||
Application.getComponent().getAsyncWorker().supplyAsync(() -> {
|
||||
Application.getAsyncWorker().supplyAsync(() -> {
|
||||
final File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
final File file = new File(path, "wireguard-log.txt");
|
||||
if (!path.isDirectory() && !path.mkdirs())
|
||||
|
||||
@@ -13,10 +13,7 @@ import android.system.OsConstants;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.wireguard.android.Application;
|
||||
import com.wireguard.android.Application.ApplicationComponent;
|
||||
import com.wireguard.android.R;
|
||||
import com.wireguard.android.util.AsyncWorker;
|
||||
import com.wireguard.android.util.ToolsInstaller;
|
||||
|
||||
/**
|
||||
* Preference implementing a button that asynchronously runs {@code ToolsInstaller} and displays the
|
||||
@@ -24,16 +21,10 @@ import com.wireguard.android.util.ToolsInstaller;
|
||||
*/
|
||||
|
||||
public class ToolsInstallerPreference extends Preference {
|
||||
private final AsyncWorker asyncWorker;
|
||||
private final ToolsInstaller toolsInstaller;
|
||||
private State state = State.INITIAL;
|
||||
|
||||
@SuppressWarnings({"SameParameterValue", "WeakerAccess"})
|
||||
public ToolsInstallerPreference(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
final ApplicationComponent applicationComponent = Application.getComponent();
|
||||
asyncWorker = applicationComponent.getAsyncWorker();
|
||||
toolsInstaller = applicationComponent.getToolsInstaller();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +40,7 @@ public class ToolsInstallerPreference extends Preference {
|
||||
@Override
|
||||
public void onAttached() {
|
||||
super.onAttached();
|
||||
asyncWorker.supplyAsync(toolsInstaller::areInstalled).whenComplete(this::onCheckResult);
|
||||
Application.getAsyncWorker().supplyAsync(Application.getToolsInstaller()::areInstalled).whenComplete(this::onCheckResult);
|
||||
}
|
||||
|
||||
private void onCheckResult(final Integer result, final Throwable throwable) {
|
||||
@@ -60,7 +51,7 @@ public class ToolsInstallerPreference extends Preference {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
setState(workingState());
|
||||
asyncWorker.supplyAsync(toolsInstaller::install).whenComplete(this::onInstallResult);
|
||||
Application.getAsyncWorker().supplyAsync(Application.getToolsInstaller()::install).whenComplete(this::onInstallResult);
|
||||
}
|
||||
|
||||
private void onInstallResult(final Integer result, final Throwable throwable) {
|
||||
@@ -86,13 +77,13 @@ public class ToolsInstallerPreference extends Preference {
|
||||
}
|
||||
|
||||
private State initialState() {
|
||||
return toolsInstaller.willInstallAsMagiskModule(false) ? State.INITIAL_MAGISK : State.INITIAL_SYSTEM;
|
||||
return Application.getToolsInstaller().willInstallAsMagiskModule(false) ? State.INITIAL_MAGISK : State.INITIAL_SYSTEM;
|
||||
}
|
||||
private State workingState() {
|
||||
return toolsInstaller.willInstallAsMagiskModule(false) ? State.WORKING_MAGISK : State.WORKING_SYSTEM;
|
||||
return Application.getToolsInstaller().willInstallAsMagiskModule(false) ? State.WORKING_MAGISK : State.WORKING_SYSTEM;
|
||||
}
|
||||
private State successState() {
|
||||
return toolsInstaller.willInstallAsMagiskModule(false) ? State.SUCCESS_MAGISK : State.SUCCESS_SYSTEM;
|
||||
return Application.getToolsInstaller().willInstallAsMagiskModule(false) ? State.SUCCESS_MAGISK : State.SUCCESS_SYSTEM;
|
||||
}
|
||||
|
||||
private enum State {
|
||||
|
||||
@@ -16,28 +16,23 @@ import com.wireguard.android.BuildConfig;
|
||||
import com.wireguard.android.R;
|
||||
import com.wireguard.android.backend.GoBackend;
|
||||
import com.wireguard.android.backend.WgQuickBackend;
|
||||
import com.wireguard.android.util.RootShell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java9.util.concurrent.CompletionStage;
|
||||
|
||||
public class VersionPreference extends Preference {
|
||||
private String versionSummary;
|
||||
|
||||
public VersionPreference(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
if (Application.getComponent().getBackendType() == GoBackend.class) {
|
||||
if (Application.getBackendType() == GoBackend.class) {
|
||||
versionSummary = getContext().getString(R.string.version_userspace_summary, GoBackend.getVersion());
|
||||
} else if (Application.getComponent().getBackendType() == WgQuickBackend.class) {
|
||||
} else if (Application.getBackendType() == WgQuickBackend.class) {
|
||||
versionSummary = getContext().getString(R.string.version_kernel_summary_checking);
|
||||
Application.getComponent().getAsyncWorker().supplyAsync(() -> {
|
||||
Application.getAsyncWorker().supplyAsync(() -> {
|
||||
final List<String> output = new ArrayList<>();
|
||||
if (Application.getComponent().getRootShell()
|
||||
if (Application.getRootShell()
|
||||
.run(output, "cat /sys/module/wireguard/version") != 0 || output.isEmpty())
|
||||
throw new RuntimeException("Unable to determine kernel module version");
|
||||
return output.get(0);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ZipExporterPreference extends Preference {
|
||||
}
|
||||
|
||||
private void exportZip() {
|
||||
final List<Tunnel> tunnels = new ArrayList<>(Application.getComponent().getTunnelManager().getTunnels());
|
||||
final List<Tunnel> tunnels = new ArrayList<>(Application.getTunnelManager().getTunnels());
|
||||
final List<CompletableFuture<Config>> futureConfigs = new ArrayList<>(tunnels.size());
|
||||
for (final Tunnel tunnel : tunnels)
|
||||
futureConfigs.add(tunnel.getConfigAsync().toCompletableFuture());
|
||||
@@ -67,7 +67,7 @@ public class ZipExporterPreference extends Preference {
|
||||
return;
|
||||
}
|
||||
CompletableFuture.allOf(futureConfigs.toArray(new CompletableFuture[futureConfigs.size()]))
|
||||
.whenComplete((ignored1, exception) -> Application.getComponent().getAsyncWorker().supplyAsync(() -> {
|
||||
.whenComplete((ignored1, exception) -> Application.getAsyncWorker().supplyAsync(() -> {
|
||||
if (exception != null)
|
||||
throw exception;
|
||||
final File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
|
||||
Reference in New Issue
Block a user