mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-06-19 21:05:25 +08:00
Fix inaccurate firewall grace period
The timeout did not take into account the time spent during the device deep sleep Fixes #390
This commit is contained in:
parent
69f06c2586
commit
fb7adf4307
@ -109,7 +109,7 @@ public class MitmReceiver implements Runnable, ConnectionsListener, MitmListener
|
||||
type = _type;
|
||||
msg = _msg;
|
||||
port = _port;
|
||||
pendingSince = SystemClock.uptimeMillis();
|
||||
pendingSince = SystemClock.elapsedRealtime();
|
||||
when = _now;
|
||||
}
|
||||
}
|
||||
@ -331,7 +331,7 @@ public class MitmReceiver implements Runnable, ConnectionsListener, MitmListener
|
||||
private synchronized void addPendingMessage(PendingMessage pending) {
|
||||
// Purge unresolved connections (should not happen, just in case)
|
||||
if(mPendingMessages.size() > 32) {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
long now = SystemClock.elapsedRealtime();
|
||||
|
||||
for(int i = mPendingMessages.size()-1; i>=0; i--) {
|
||||
ArrayList<PendingMessage> pp = mPendingMessages.valueAt(i);
|
||||
|
||||
@ -290,7 +290,7 @@ public class AboutActivity extends BaseActivity implements MenuProvider {
|
||||
return;
|
||||
}
|
||||
int timeout_ms = Integer.parseInt(timeout_s) * 1000;
|
||||
long deadline = SystemClock.uptimeMillis() + timeout_ms;
|
||||
long deadline = SystemClock.elapsedRealtime() + timeout_ms;
|
||||
Log.d(TAG, "QR request_id=" + qr_req_id + ", timeout=" + timeout_ms + " ms");
|
||||
|
||||
// Step 2: generate QR code
|
||||
@ -357,7 +357,7 @@ public class AboutActivity extends BaseActivity implements MenuProvider {
|
||||
View qrLoading = dialog.findViewById(R.id.qr_code_loading);
|
||||
View qrInfo = dialog.findViewById(R.id.qr_info_text);
|
||||
|
||||
mQrStartTime = SystemClock.uptimeMillis();
|
||||
mQrStartTime = SystemClock.elapsedRealtime();
|
||||
mQrDeadline = deadline;
|
||||
updateQrProgress(dialog);
|
||||
|
||||
@ -373,7 +373,7 @@ public class AboutActivity extends BaseActivity implements MenuProvider {
|
||||
return;
|
||||
|
||||
long interval = mQrDeadline - mQrStartTime;
|
||||
int progress = Math.min((int)((SystemClock.uptimeMillis() - mQrStartTime) * 100 / interval), 100);
|
||||
int progress = Math.min((int)((SystemClock.elapsedRealtime() - mQrStartTime) * 100 / interval), 100);
|
||||
qrProgress.setProgress(100 - progress);
|
||||
|
||||
mHandler.postDelayed(() -> updateQrProgress(dialog), 1000);
|
||||
|
||||
@ -22,13 +22,13 @@ public class Blocklist extends MatchList {
|
||||
}
|
||||
|
||||
public synchronized boolean unblockAppForMinutes(int uid, int minutes) {
|
||||
Long old_val = mUidToGrace.put(uid, SystemClock.uptimeMillis() + (minutes * 60_000L));
|
||||
Long old_val = mUidToGrace.put(uid, SystemClock.elapsedRealtime() + (minutes * 60_000L));
|
||||
Log.i(TAG, "Grace app: " + uid + " for " + minutes + " minutes (old: " + old_val + ")");
|
||||
return (old_val == null);
|
||||
}
|
||||
|
||||
public synchronized boolean checkGracePeriods() {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
long now = SystemClock.elapsedRealtime();
|
||||
boolean changed = false;
|
||||
Iterator<Map.Entry<Integer,Long>> iter = mUidToGrace.entrySet().iterator();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user