mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-07-03 21:21:12 +08:00
Show workaround for background service execution
This commit is contained in:
parent
951234f647
commit
c0a0467501
@ -48,8 +48,8 @@ import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class MitmAddon {
|
||||
public static final long PACKAGE_VERSION_CODE = 13;
|
||||
public static final String PACKAGE_VERSION_NAME = "v0.13";
|
||||
public static final long PACKAGE_VERSION_CODE = 14;
|
||||
public static final String PACKAGE_VERSION_NAME = "v0.14";
|
||||
public static final String REPOSITORY = "https://github.com/emanuele-f/PCAPdroid-mitm";
|
||||
private static final String TAG = "MitmAddon";
|
||||
private final Context mContext;
|
||||
|
||||
@ -42,6 +42,7 @@ import com.emanuelef.remote_capture.R;
|
||||
import com.emanuelef.remote_capture.Utils;
|
||||
import com.emanuelef.remote_capture.interfaces.MitmListener;
|
||||
import com.emanuelef.remote_capture.MitmAddon;
|
||||
import com.pcapdroid.mitm.MitmAPI;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@ -76,12 +77,7 @@ public class InstallCertificate extends StepFragment implements MitmListener {
|
||||
gotoStep(R.id.navto_done);
|
||||
})
|
||||
.show());
|
||||
|
||||
mAddon = new MitmAddon(requireContext(), this);
|
||||
if(!mAddon.connect(0)) {
|
||||
Toast.makeText(requireContext(), "addon connect failed", Toast.LENGTH_LONG).show();
|
||||
certFail();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -92,7 +88,29 @@ public class InstallCertificate extends StepFragment implements MitmListener {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
if(Utils.isCAInstalled(mCaCert))
|
||||
if(!Utils.isCAInstalled(mCaCert)) {
|
||||
if(!mAddon.isConnected()) {
|
||||
if (!mAddon.connect(0)) {
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setTitle(R.string.error)
|
||||
.setMessage(R.string.mitm_addon_autostart_workaround)
|
||||
.setNegativeButton(R.string.no, (dialogInterface, i) -> {
|
||||
Toast.makeText(requireContext(), "addon connect failed", Toast.LENGTH_LONG).show();
|
||||
certFail();
|
||||
})
|
||||
.setPositiveButton(R.string.yes, (d, whichButton) -> {
|
||||
Context ctx = requireContext();
|
||||
Intent launchIntent = ctx.getPackageManager().getLaunchIntentForPackage(MitmAPI.PACKAGE_NAME);
|
||||
if (launchIntent != null)
|
||||
Utils.startActivity(ctx, launchIntent);
|
||||
else {
|
||||
Toast.makeText(requireContext(), "addon connect failed", Toast.LENGTH_LONG).show();
|
||||
certFail();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
} else
|
||||
certOk();
|
||||
|
||||
super.onResume();
|
||||
|
||||
@ -269,7 +269,7 @@
|
||||
<string name="tls_decryption_starting">TLS decryption is starting…</string>
|
||||
<string name="tls_decryption_running">TLS decryption is running</string>
|
||||
<string name="traffic_inspection">Traffic inspection</string>
|
||||
<string name="mitm_start_failed">Could not start the mitm service. Reinstall the mitm addon and retry</string>
|
||||
<string name="mitm_start_failed">Could not start the mitm service. Try to open the mitm addon app manually and retry</string>
|
||||
<string name="mitm_setup_wizard">Mitm setup wizard</string>
|
||||
<string name="install_action">Install</string>
|
||||
<string name="export_action">Export</string>
|
||||
@ -460,4 +460,5 @@
|
||||
<string name="write_ext_storage_failed">Write to external storage failed. Check the app log for details</string>
|
||||
<string name="username">Username</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="mitm_addon_autostart_workaround">Connection to the mitm addon failed. As a workaround, you can try to open the mitm addon app and then go back to PCAPdroid without closing it. Do you want to open it now?</string>
|
||||
</resources>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user