mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-07-03 21:21:12 +08:00
Fix PCAP dialog shown on resume
This commit is contained in:
parent
46889738c7
commit
916e5cf89b
@ -1330,6 +1330,7 @@ public class CaptureService extends VpnService implements Runnable {
|
||||
|
||||
private void updateServiceStatus(ServiceStatus cur_status) {
|
||||
// notify the observers
|
||||
// NOTE: new subscribers will receive the STOPPED status right after their registration
|
||||
serviceStatus.postValue(cur_status);
|
||||
|
||||
if(cur_status == ServiceStatus.STARTED) {
|
||||
|
||||
@ -93,6 +93,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
private NavigationView mNavView;
|
||||
private CaptureHelper mCapHelper;
|
||||
|
||||
// helps detecting duplicate state reporting of STOPPED in MutableLiveData
|
||||
private boolean mWasStarted = false;
|
||||
|
||||
private static final String TAG = "Main";
|
||||
|
||||
private static final int POS_STATUS = 0;
|
||||
@ -158,9 +161,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
CaptureService.observeStatus(this, serviceStatus -> {
|
||||
Log.d(TAG, "Service status: " + serviceStatus.name());
|
||||
|
||||
if (serviceStatus == CaptureService.ServiceStatus.STARTED)
|
||||
if (serviceStatus == CaptureService.ServiceStatus.STARTED) {
|
||||
appStateRunning();
|
||||
else /* STOPPED */ {
|
||||
mWasStarted = true;
|
||||
} else if(mWasStarted) { /* STARTED -> STOPPED */
|
||||
// The service may still be active (on premature native termination)
|
||||
if (CaptureService.isServiceActive())
|
||||
CaptureService.stopService();
|
||||
@ -179,7 +183,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
startExportSslkeylogfile();
|
||||
|
||||
appStateReady();
|
||||
}
|
||||
mWasStarted = false;
|
||||
} else /* STOPPED -> STOPPED */
|
||||
appStateReady();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user