Offset 1, 107 lines modifiedOffset 1, 150 lines modified
  
1 package·com.android.server.wifi;1 package·com.android.server.wifi;
  
2 import·java.util.Collection; 
3 import·java.util.function.Supplier;2 import·java.util.function.Supplier;
4 import·java.util.Comparator;3 import·java.util.Comparator;
5 import·java.util.ArrayList;4 import·java.util.ArrayList;
 5 import·android.net.wifi.ScanResult;
 6 import·java.util.List;
6 import·java.util.stream.Collector;7 import·java.util.stream.Collector;
7 import·java.util.stream.Collectors;8 import·java.util.stream.Collectors;
8 import·java.util.function.Function;9 import·java.util.function.Function;
9 import·java.util.Set;10 import·java.util.Collections;
10 import·java.util.function.Consumer;11 import·java.util.function.Consumer;
11 import·java.io.FileDescriptor;12 import·java.io.FileDescriptor;
12 import·java.util.Iterator;13 import·java.util.Iterator;
13 import·java.util.function.Predicate; 
14 import·java.util.stream.Stream;14 import·java.util.stream.Stream;
15 import·java.io.PrintWriter;15 import·java.io.PrintWriter;
16 import·android.util.Log;16 import·android.util.Log;
 17 import·java.util.function.Predicate;
17 import·android.util.ArrayMap;18 import·android.util.ArrayMap;
18 import·java.util.concurrent.TimeUnit;19 import·java.util.concurrent.TimeUnit;
 20 import·java.util.Collection;
 21 import·android.util.ArraySet;
 22 import·java.util.Arrays;
19 import·com.android.wifi.x.android.util.LocalLog;23 import·com.android.wifi.x.android.util.LocalLog;
20 import·android.content.Context;24 import·android.content.Context;
21 import·java.util.Calendar;25 import·java.util.Calendar;
22 import·java.util.Map;26 import·java.util.Map;
 27 import·java.util.Set;
  
23 public·class·BssidBlocklistMonitor28 public·class·BssidBlocklistMonitor
24 {29 {
25 ····private·static·final·long·ABNORMAL_DISCONNECT_RESET_TIME_MS·=·0L;30 ····private·static·final·long·ABNORMAL_DISCONNECT_RESET_TIME_MS·=·0L;
26 ····private·static·final·String·FAILURE_BSSID_BLOCKED_BY_FRAMEWORK_REASON_STRING·=·"BlockedByFramework"; 
27 ····private·static·final·int[]·FAILURE_COUNT_DISABLE_THRESHOLD;31 ····private·static·final·int[]·FAILURE_COUNT_DISABLE_THRESHOLD;
28 ····private·static·final·String[]·FAILURE_REASON_STRINGS;32 ····private·static·final·String[]·FAILURE_REASON_STRINGS;
29 ····public·static·final·int·NUMBER_REASON_CODES·=·9;33 ····public·static·final·int·INVALID_REASON·=·255;
 34 ····private·static·final·Set·LOW_RSSI_SENSITIVE_FAILURES;
 35 ····private·static·final·int·MIN_RSSI_DIFF_TO_UNBLOCK_BSSID·=·5;
 36 ····public·static·final·int·NUMBER_REASON_CODES·=·12;
30 ····public·static·final·int·REASON_ABNORMAL_DISCONNECT·=·8;37 ····public·static·final·int·REASON_ABNORMAL_DISCONNECT·=·8;
31 ····public·static·final·int·REASON_AP_UNABLE_TO_HANDLE_NEW_STA·=·0;38 ····public·static·final·int·REASON_AP_UNABLE_TO_HANDLE_NEW_STA·=·0;
32 ····public·static·final·int·REASON_ASSOCIATION_REJECTION·=·4;39 ····public·static·final·int·REASON_ASSOCIATION_REJECTION·=·4;
33 ····public·static·final·int·REASON_ASSOCIATION_TIMEOUT·=·5;40 ····public·static·final·int·REASON_ASSOCIATION_TIMEOUT·=·5;
34 ····public·static·final·int·REASON_AUTHENTICATION_FAILURE·=·6;41 ····public·static·final·int·REASON_AUTHENTICATION_FAILURE·=·6;
35 ····public·static·final·int·REASON_DHCP_FAILURE·=·7;42 ····public·static·final·int·REASON_DHCP_FAILURE·=·7;
36 ····public·static·final·int·REASON_EAP_FAILURE·=·3;43 ····public·static·final·int·REASON_EAP_FAILURE·=·3;
 44 ····public·static·final·int·REASON_FRAMEWORK_DISCONNECT_CONNECTED_SCORE·=·11;
 45 ····public·static·final·int·REASON_FRAMEWORK_DISCONNECT_FAST_RECONNECT·=·10;
 46 ····public·static·final·int·REASON_FRAMEWORK_DISCONNECT_MBO_OCE·=·9;
37 ····public·static·final·int·REASON_NETWORK_VALIDATION_FAILURE·=·1;47 ····public·static·final·int·REASON_NETWORK_VALIDATION_FAILURE·=·1;
38 ····public·static·final·int·REASON_WRONG_PASSWORD·=·2;48 ····public·static·final·int·REASON_WRONG_PASSWORD·=·2;
39 ····private·static·final·String·TAG·=·"BssidBlocklistMonitor";49 ····private·static·final·String·TAG·=·"BssidBlocklistMonitor";
40 ····private·BssidBlocklistMonitor$BssidStatusHistoryLogger·mBssidStatusHistoryLogger;50 ····private·BssidBlocklistMonitor$BssidStatusHistoryLogger·mBssidStatusHistoryLogger;
41 ····private·Map·mBssidStatusMap;51 ····private·Map·mBssidStatusMap;
42 ····private·final·Calendar·mCalendar;52 ····private·final·Calendar·mCalendar;
43 ····private·final·Clock·mClock;53 ····private·final·Clock·mClock;
44 ····private·final·WifiConnectivityHelper·mConnectivityHelper;54 ····private·final·WifiConnectivityHelper·mConnectivityHelper;
45 ····private·final·Context·mContext;55 ····private·final·Context·mContext;
46 ····private·boolean·mFailureCountDisableThresholdArrayInitialized;56 ····private·boolean·mFailureCountDisableThresholdArrayInitialized;
47 ····private·final·LocalLog·mLocalLog;57 ····private·final·LocalLog·mLocalLog;
 58 ····private·final·ScoringParams·mScoringParams;
48 ····private·final·WifiLastResortWatchdog·mWifiLastResortWatchdog;59 ····private·final·WifiLastResortWatchdog·mWifiLastResortWatchdog;
49 ····private·final·WifiScoreCard·mWifiScoreCard;60 ····private·final·WifiScoreCard·mWifiScoreCard;
50 ····61 ····
51 ····static·{62 ····static·{
52 ········FAILURE_COUNT_DISABLE_THRESHOLD·=·new·int[9];63 ········FAILURE_COUNT_DISABLE_THRESHOLD·=·new·int[12];
53 ········FAILURE_REASON_STRINGS·=·new·String[]·{·"REASON_AP_UNABLE_TO_HANDLE_NEW_STA",·"REASON_NETWORK_VALIDATION_FAILURE",·"REASON_WRONG_PASSWORD",·"REASON_EAP_FAILURE",·"REASON_ASSOCIATION_REJECTION",·"REASON_ASSOCIATION_TIMEOUT",·"REASON_AUTHENTICATION_FAILURE",·"REASON_DHCP_FAILURE",·"REASON_ABNORMAL_DISCONNECT"·};64 ········FAILURE_REASON_STRINGS·=·new·String[]·{·"REASON_AP_UNABLE_TO_HANDLE_NEW_STA",·"REASON_NETWORK_VALIDATION_FAILURE",·"REASON_WRONG_PASSWORD",·"REASON_EAP_FAILURE",·"REASON_ASSOCIATION_REJECTION",·"REASON_ASSOCIATION_TIMEOUT",·"REASON_AUTHENTICATION_FAILURE",·"REASON_DHCP_FAILURE",·"REASON_ABNORMAL_DISCONNECT",·"REASON_FRAMEWORK_DISCONNECT_MBO_OCE",·"REASON_FRAMEWORK_DISCONNECT_FAST_RECONNECT",·"REASON_FRAMEWORK_DISCONNECT_CONNECTED_SCORE"·};
 65 ········final·int·n·=·8;
 66 ········final·Integer[]·array·=·new·Integer[n];
 67 ········final·int·n2·=·1;
 68 ········array[0]·=·n2;
 69 ········final·int·n3·=·3;
 70 ········array[n2]·=·n3;
 71 ········final·int·n4·=·4;
 72 ········array[2]·=·n4;
 73 ········final·int·n5·=·5;
 74 ········array[n3]·=·n5;
 75 ········final·int·n6·=·6;
 76 ········array[n4]·=·n6;
 77 ········final·int·n7·=·7;
 78 ········array[n5]·=·n7;
 79 ········array[n6]·=·n;
 80 ········array[n7]·=·11;
 81 ········LOW_RSSI_SENSITIVE_FAILURES·=·(Set)new·ArraySet((Collection)Arrays.asList(array));
54 ····}82 ····}
55 ····83 ····
56 ····BssidBlocklistMonitor(final·Context·mContext,·final·WifiConnectivityHelper·mConnectivityHelper,·final·WifiLastResortWatchdog·mWifiLastResortWatchdog,·final·Clock·mClock,·final·LocalLog·mLocalLog,·final·WifiScoreCard·mWifiScoreCard)·{84 ····BssidBlocklistMonitor(final·Context·mContext,·final·WifiConnectivityHelper·mConnectivityHelper,·final·WifiLastResortWatchdog·mWifiLastResortWatchdog,·final·Clock·mClock,·final·LocalLog·mLocalLog,·final·WifiScoreCard·mWifiScoreCard,·final·ScoringParams·mScoringParams)·{
57 ········this.mFailureCountDisableThresholdArrayInitialized·=·false;85 ········this.mFailureCountDisableThresholdArrayInitialized·=·false;
58 ········this.mBssidStatusMap·=·(Map)new·ArrayMap();86 ········this.mBssidStatusMap·=·(Map)new·ArrayMap();
59 ········this.mBssidStatusHistoryLogger·=·new·BssidBlocklistMonitor$BssidStatusHistoryLogger(this,·30);87 ········this.mBssidStatusHistoryLogger·=·new·BssidBlocklistMonitor$BssidStatusHistoryLogger(this,·30);
60 ········this.mContext·=·mContext;88 ········this.mContext·=·mContext;
61 ········this.mConnectivityHelper·=·mConnectivityHelper;89 ········this.mConnectivityHelper·=·mConnectivityHelper;
62 ········this.mWifiLastResortWatchdog·=·mWifiLastResortWatchdog;90 ········this.mWifiLastResortWatchdog·=·mWifiLastResortWatchdog;
63 ········this.mClock·=·mClock;91 ········this.mClock·=·mClock;
64 ········this.mLocalLog·=·mLocalLog;92 ········this.mLocalLog·=·mLocalLog;
65 ········this.mCalendar·=·Calendar.getInstance();93 ········this.mCalendar·=·Calendar.getInstance();
66 ········this.mWifiScoreCard·=·mWifiScoreCard;94 ········this.mWifiScoreCard·=·mWifiScoreCard;
 95 ········this.mScoringParams·=·mScoringParams;
67 ····}96 ····}
68 ····97 ····
69 ····private·void·addToBlocklist(final·BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus,·final·long·n,·final·String·s)·{98 ····private·void·addToBlocklist(final·BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus,·final·long·n,·final·int·n2,·final·int·n3)·{
70 ········bssidBlocklistMonitor$BssidStatus.addToBlocklist(n,·s);99 ········bssidBlocklistMonitor$BssidStatus.setAsBlocked(n,·n2,·n3);
71 ········final·StringBuilder·sb·=·new·StringBuilder();100 ········final·StringBuilder·sb·=·new·StringBuilder();
72 ········sb.append("BssidBlocklistMonitor·addToBlocklist:·bssid=");101 ········sb.append("BssidBlocklistMonitor·addToBlocklist:·bssid=");
73 ········sb.append(bssidBlocklistMonitor$BssidStatus.bssid);102 ········sb.append(bssidBlocklistMonitor$BssidStatus.bssid);
74 ········sb.append(",·ssid=");103 ········sb.append(",·ssid=");
75 ········sb.append(bssidBlocklistMonitor$BssidStatus.ssid);104 ········sb.append(bssidBlocklistMonitor$BssidStatus.ssid);
76 ········sb.append(",·durationMs=");105 ········sb.append(",·durationMs=");
77 ········sb.append(n);106 ········sb.append(n);
78 ········sb.append(",·reason=");107 ········sb.append(",·reason=");
79 ········sb.append(s);108 ········sb.append(this.getFailureReasonString(n2));
 109 ········sb.append(",·rssi=");
 110 ········sb.append(n3);
80 ········this.localLog(sb.toString());111 ········this.localLog(sb.toString());
81 ····}112 ····}
82 ····113 ····
 114 ····private·int·getBaseBlockDurationForReason(final·int·n)·{
 115 ········if·(n·!=·11)·{
 116 ············return·this.mContext.getResources().getInteger(2131034118);
 117 ········}
 118 ········return·this.mContext.getResources().getInteger(2131034119);
 119 ····}
 120 ····
83 ····private·long·getBlocklistDurationWithExponentialBackoff(int·n,·final·int·n2)·{121 ····private·long·getBlocklistDurationWithExponentialBackoff(int·n,·final·int·n2)·{
84 ········final·int·min·=·Math.min(n,·this.mContext.getResources().getInteger(2131034122));122 ········final·int·min·=·Math.min(n,·this.mContext.getResources().getInteger(2131034122));
85 ········n·=·1;123 ········n·=·1;
86 ········if·(min·<·n)·{124 ········if·(min·<·n)·{
87 ············return·n2;125 ············return·n2;
88 ········}126 ········}
89 ········return·(long)(Math.pow(2.0,·min)·*·n2);127 ········return·(long)(Math.pow(2.0,·min)·*·n2);
90 ····}128 ····}
91 ····129 ····
92 ····private·String·getFailureReasonString(final·int·n)·{130 ····private·String·getFailureReasonString(final·int·n)·{
93 ········final·String[]·failure_REASON_STRINGS·=·BssidBlocklistMonitor.FAILURE_REASON_STRINGS;131 ········if·(n·==·-1)·{
94 ········if·(n·>=·failure_REASON_STRINGS.length)·{132 ············return·"INVALID_REASON";
95 ············return·"REASON_UNKNOWN";133 ········}
 134 ········if·(n·>=·0)·{
 135 ············final·String[]·failure_REASON_STRINGS·=·BssidBlocklistMonitor.FAILURE_REASON_STRINGS;
 136 ············if·(n·<·failure_REASON_STRINGS.length)·{
 137 ················return·failure_REASON_STRINGS[n];
 138 ············}
96 ········}139 ········}
97 ········return·failure_REASON_STRINGS[n];140 ········return·"REASON_UNKNOWN";
98 ····}141 ····}
99 ····142 ····
100 ····private·int·getFailureThresholdForReason(final·int·n)·{143 ····private·int·getFailureThresholdForReason(final·int·n)·{
101 ········if·(this.mFailureCountDisableThresholdArrayInitialized)·{144 ········if·(this.mFailureCountDisableThresholdArrayInitialized)·{
102 ············return·BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[n];145 ············return·BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[n];
103 ········}146 ········}
104 ········BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[0]·=·this.mContext.getResources().getInteger(2131034114);147 ········BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[0]·=·this.mContext.getResources().getInteger(2131034114);
Offset 116, 14 lines modifiedOffset 159, 21 lines modified
116 ········BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[6]·=·this.mContext.getResources().getInteger(2131034117);159 ········BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[6]·=·this.mContext.getResources().getInteger(2131034117);
117 ········BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[7]·=·this.mContext.getResources().getInteger(2131034120);160 ········BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[7]·=·this.mContext.getResources().getInteger(2131034120);
118 ········BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[8]·=·this.mContext.getResources().getInteger(2131034113);161 ········BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[8]·=·this.mContext.getResources().getInteger(2131034113);
119 ········this.mFailureCountDisableThresholdArrayInitialized·=·(mFailureCountDisableThresholdArrayInitialized·!=·0);162 ········this.mFailureCountDisableThresholdArrayInitialized·=·(mFailureCountDisableThresholdArrayInitialized·!=·0);
120 ········return·BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[n];163 ········return·BssidBlocklistMonitor.FAILURE_COUNT_DISABLE_THRESHOLD[n];
121 ····}164 ····}
122 ····165 ····
 166 ····private·int·getNumBlockedBssidsForSsid(final·String·s)·{
 167 ········if·(s·==·null)·{
 168 ············return·0;
 169 ········}
 170 ········return·(int)this.mBssidStatusMap.values().stream().filter((Predicate)new·-$$Lambda$BssidBlocklistMonitor$Ncn6tOVItshIBiKzZ-r2SnBwnfw(s)).count();
 171 ····}
 172 ····
123 ····private·BssidBlocklistMonitor$BssidStatus·getOrCreateBssidStatus(final·String·s,·final·String·s2)·{173 ····private·BssidBlocklistMonitor$BssidStatus·getOrCreateBssidStatus(final·String·s,·final·String·s2)·{
124 ········BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus·=·(BssidBlocklistMonitor$BssidStatus)this.mBssidStatusMap.get(s);174 ········BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus·=·(BssidBlocklistMonitor$BssidStatus)this.mBssidStatusMap.get(s);
125 ········if·(bssidBlocklistMonitor$BssidStatus·==·null·||·!s2.equals(bssidBlocklistMonitor$BssidStatus.ssid))·{175 ········if·(bssidBlocklistMonitor$BssidStatus·==·null·||·!s2.equals(bssidBlocklistMonitor$BssidStatus.ssid))·{
126 ············if·(bssidBlocklistMonitor$BssidStatus·!=·null)·{176 ············if·(bssidBlocklistMonitor$BssidStatus·!=·null)·{
127 ················final·StringBuilder·sb·=·new·StringBuilder();177 ················final·StringBuilder·sb·=·new·StringBuilder();
128 ················sb.append("getOrCreateBssidStatus:·BSSID=");178 ················sb.append("getOrCreateBssidStatus:·BSSID=");
129 ················sb.append(s);179 ················sb.append(s);
Offset 135, 41 lines modifiedOffset 185, 37 lines modified
135 ············}185 ············}
136 ············bssidBlocklistMonitor$BssidStatus·=·new·BssidBlocklistMonitor$BssidStatus(this,·s,·s2);186 ············bssidBlocklistMonitor$BssidStatus·=·new·BssidBlocklistMonitor$BssidStatus(this,·s,·s2);
137 ············this.mBssidStatusMap.put(s,·bssidBlocklistMonitor$BssidStatus);187 ············this.mBssidStatusMap.put(s,·bssidBlocklistMonitor$BssidStatus);
138 ········}188 ········}
139 ········return·bssidBlocklistMonitor$BssidStatus;189 ········return·bssidBlocklistMonitor$BssidStatus;
140 ····}190 ····}
141 ····191 ····
142 ····private·boolean·handleBssidConnectionFailureInternal(final·String·s,·final·String·s2,·final·int·n,·final·boolean·b)·{192 ····private·boolean·handleBssidConnectionFailureInternal(final·String·s,·final·String·s2,·final·int·n,·final·int·n2)·{
143 ········final·BssidBlocklistMonitor$BssidStatus·incrementFailureCountForBssid·=·this.incrementFailureCountForBssid(s,·s2,·n);193 ········final·BssidBlocklistMonitor$BssidStatus·incrementFailureCountForBssid·=·this.incrementFailureCountForBssid(s,·s2,·n);
144 ········final·int·failureThresholdForReason·=·this.getFailureThresholdForReason(n);194 ········final·int·failureThresholdForReason·=·this.getFailureThresholdForReason(n);
145 ········final·int·bssidBlocklistStreak·=·this.mWifiScoreCard.getBssidBlocklistStreak(s2,·s,·n);195 ········final·int·bssidBlocklistStreak·=·this.mWifiScoreCard.getBssidBlocklistStreak(s2,·s,·n);
146 ········if·(bssidBlocklistStreak·<=·0·&&·incrementFailureCountForBssid.failureCount[n]·<·failureThresholdForReason)·{196 ········if·(bssidBlocklistStreak·<=·0·&&·incrementFailureCountForBssid.failureCount[n]·<·failureThresholdForReason)·{
147 ············return·false;197 ············return·false;
148 ········}198 ········}
149 ········if·(this.shouldWaitForWatchdogToTriggerFirst(s,·n))·{199 ········if·(this.shouldWaitForWatchdogToTriggerFirst(s,·n))·{
150 ············return·false;200 ············return·false;
151 ········}201 ········}
152 ········int·n2·=·this.mContext.getResources().getInteger(2131034118);202 ········this.addToBlocklist(incrementFailureCountForBssid,·this.getBlocklistDurationWithExponentialBackoff(bssidBlocklistStreak,·this.getBaseBlockDurationForReason(n)),·n,·n2);
153 ········if·((n·==·5·||·n·==·8)·&&·b)·{ 
154 ············n2·=·this.mContext.getResources().getInteger(2131034119); 
155 ········} 
156 ········this.addToBlocklist(incrementFailureCountForBssid,·this.getBlocklistDurationWithExponentialBackoff(bssidBlocklistStreak,·n2),·this.getFailureReasonString(n)); 
157 ········this.mWifiScoreCard.incrementBssidBlocklistStreak(s2,·s,·n);203 ········this.mWifiScoreCard.incrementBssidBlocklistStreak(s2,·s,·n);
158 ········return·true;204 ········return·true;
159 ····}205 ····}
160 ····206 ····
161 ····private·BssidBlocklistMonitor$BssidStatus·incrementFailureCountForBssid(final·String·s,·final·String·s2,·final·int·n)·{207 ····private·BssidBlocklistMonitor$BssidStatus·incrementFailureCountForBssid(final·String·s,·final·String·s2,·final·int·n)·{
162 ········final·BssidBlocklistMonitor$BssidStatus·orCreateBssidStatus·=·this.getOrCreateBssidStatus(s,·s2);208 ········final·BssidBlocklistMonitor$BssidStatus·orCreateBssidStatus·=·this.getOrCreateBssidStatus(s,·s2);
163 ········orCreateBssidStatus.incrementFailureCount(n);209 ········orCreateBssidStatus.incrementFailureCount(n);
164 ········return·orCreateBssidStatus;210 ········return·orCreateBssidStatus;
165 ····}211 ····}
166 ····212 ····
167 ····private·boolean·isValidNetworkAndFailureReason(final·String·s,·final·String·s2,·final·int·n)·{213 ····private·boolean·isValidNetworkAndFailureReason(final·String·s,·final·String·s2,·final·int·n)·{
168 ········if·(s·!=·null·&&·s2·!=·null·&&·!"<unknown·ssid>".equals(s2)·&&·!s.equals("any")·&&·n·>=·0·&&·n·<·9)·{214 ········if·(s·!=·null·&&·s2·!=·null·&&·!"<unknown·ssid>".equals(s2)·&&·!s.equals("any")·&&·n·>=·0·&&·n·<·12)·{
169 ············return·true;215 ············return·true;
170 ········}216 ········}
171 ········final·StringBuilder·sb·=·new·StringBuilder();217 ········final·StringBuilder·sb·=·new·StringBuilder();
172 ········sb.append("Invalid·input:·BSSID=");218 ········sb.append("Invalid·input:·BSSID=");
173 ········sb.append(s);219 ········sb.append(s);
174 ········sb.append(",·SSID=");220 ········sb.append(",·SSID=");
175 ········sb.append(s2);221 ········sb.append(s2);
Offset 191, 35 lines modifiedOffset 237, 39 lines modified
191 ············b·=·b2;237 ············b·=·b2;
192 ········}238 ········}
193 ········return·b;239 ········return·b;
194 ····}240 ····}
195 ····241 ····
196 ····private·Stream·updateAndGetBssidBlocklistInternal()·{242 ····private·Stream·updateAndGetBssidBlocklistInternal()·{
197 ········final·Stream.Builder<Object>·builder·=·Stream.builder();243 ········final·Stream.Builder<Object>·builder·=·Stream.builder();
198 ········this.mBssidStatusMap.entrySet().removeIf((Predicate)new·-$$Lambda$BssidBlocklistMonitor$vhAcFFsSj5nGpzwlPOvUvRBPb6k(this,·this.mClock.getWallClockMillis(),·(Stream.Builder)builder));244 ········this.mBssidStatusMap.entrySet().removeIf((Predicate)new·-$$Lambda$BssidBlocklistMonitor$I2EPZj0K8dvxVGynj3cc2j_QR1s(this,·this.mClock.getWallClockMillis(),·(Stream.Builder)builder));
199 ········return·builder.build();245 ········return·builder.build();
200 ····}246 ····}
201 ····247 ····
202 ····public·void·blockBssidForDurationMs(final·String·s,·final·String·s2,·final·long·n)·{248 ····public·void·blockBssidForDurationMs(final·String·s,·final·String·s2,·final·long·n,·final·int·n2,·final·int·n3)·{
203 ········if·(s·==·null·||·s2·==·null·||·"<unknown·ssid>".equals(s2)·||·s.equals("any")·||·n·<=·0L)·{249 ········if·(n·<=·0L·||·this.isValidNetworkAndFailureReason(s,·s2,·n2))·{
204 ············final·StringBuilder·sb·=·new·StringBuilder();250 ············final·StringBuilder·sb·=·new·StringBuilder();
205 ············sb.append("Invalid·input:·BSSID=");251 ············sb.append("Invalid·input:·BSSID=");
206 ············sb.append(s);252 ············sb.append(s);
207 ············sb.append(",·SSID=");253 ············sb.append(",·SSID=");
208 ············sb.append(s2);254 ············sb.append(s2);
209 ············sb.append(",·durationMs=");255 ············sb.append(",·durationMs=");
210 ············sb.append(n);256 ············sb.append(n);
 257 ············sb.append(",·blockReason=");
 258 ············sb.append(n2);
 259 ············sb.append(",·rssi=");
 260 ············sb.append(n3);
211 ············Log.e("BssidBlocklistMonitor",·sb.toString());261 ············Log.e("BssidBlocklistMonitor",·sb.toString());
212 ············return;262 ············return;
213 ········}263 ········}
214 ········final·BssidBlocklistMonitor$BssidStatus·orCreateBssidStatus·=·this.getOrCreateBssidStatus(s,·s2);264 ········final·BssidBlocklistMonitor$BssidStatus·orCreateBssidStatus·=·this.getOrCreateBssidStatus(s,·s2);
215 ········if·(orCreateBssidStatus.isInBlocklist·&&·orCreateBssidStatus.blocklistEndTimeMs·-·this.mClock.getWallClockMillis()·>·n)·{265 ········if·(orCreateBssidStatus.isInBlocklist·&&·orCreateBssidStatus.blocklistEndTimeMs·-·this.mClock.getWallClockMillis()·>·n)·{
216 ············return;266 ············return;
217 ········}267 ········}
218 ········this.addToBlocklist(orCreateBssidStatus,·n,·"BlockedByFramework");268 ········this.addToBlocklist(orCreateBssidStatus,·n,·n2,·n3);
219 ····}269 ····}
220 ····270 ····
221 ····public·void·clearBssidBlocklist()·{271 ····public·void·clearBssidBlocklist()·{
222 ········if·(this.mBssidStatusMap.size()·>·0)·{272 ········if·(this.mBssidStatusMap.size()·>·0)·{
223 ············final·int·size·=·this.mBssidStatusMap.size();273 ············final·int·size·=·this.mBssidStatusMap.size();
224 ············final·Iterator<BssidBlocklistMonitor$BssidStatus>·iterator·=·this.mBssidStatusMap.values().iterator();274 ············final·Iterator<BssidBlocklistMonitor$BssidStatus>·iterator·=·this.mBssidStatusMap.values().iterator();
225 ············while·(iterator.hasNext())·{275 ············while·(iterator.hasNext())·{
Offset 256, 20 lines modifiedOffset 306, 23 lines modified
256 ········this.mBssidStatusHistoryLogger.dump(printWriter);306 ········this.mBssidStatusHistoryLogger.dump(printWriter);
257 ····}307 ····}
258 ····308 ····
259 ····public·int·getBssidStatusHistoryLoggerSize()·{309 ····public·int·getBssidStatusHistoryLoggerSize()·{
260 ········return·this.mBssidStatusHistoryLogger.size();310 ········return·this.mBssidStatusHistoryLogger.size();
261 ····}311 ····}
262 ····312 ····
263 ····public·int·getNumBlockedBssidsForSsid(final·String·s)·{313 ····public·Set·getFailureReasonsForSsid(final·String·s)·{
264 ········return·(int)this.updateAndGetBssidBlocklistInternal().filter((Predicate)new·-$$Lambda$BssidBlocklistMonitor$ZVbr9oSV2aA_MGjIFf8LUK7Kz1E(s)).count();314 ········if·(s·==·null)·{
 315 ············return·Collections.emptySet();
 316 ········}
 317 ········return·this.mBssidStatusMap.values().stream().filter((Predicate<?·super·Object>)new·-$$Lambda$BssidBlocklistMonitor$Mg2ZjValmGZuzQbBHBGHCp_UiKY(s)).map((Function<?·super·Object,·?>)-$$Lambda$BssidBlocklistMonitor$n_aQ5ms9qITu5S1AT92r3rwlwxc.INSTANCE).collect((Collector<?·super·Object,·Object,·Set<?·super·Object>>)Collectors.toSet());
265 ····}318 ····}
266 ····319 ····
267 ····public·boolean·handleBssidConnectionFailure(final·String·s,·final·String·s2,·final·int·n,·final·boolean·b)·{320 ····public·boolean·handleBssidConnectionFailure(final·String·s,·final·String·s2,·final·int·n,·final·int·n2)·{
268 ········return·this.isValidNetworkAndFailureReason(s,·s2,·n)·&&·(n·!=·8·||·this.mClock.getWallClockMillis()·-·this.mWifiScoreCard.getBssidConnectionTimestampMs(s2,·s)·<=·this.mContext.getResources().getInteger(2131034112))·&&·this.handleBssidConnectionFailureInternal(s,·s2,·n,·b);321 ········return·this.isValidNetworkAndFailureReason(s,·s2,·n)·&&·(n·!=·8·||·this.mClock.getWallClockMillis()·-·this.mWifiScoreCard.getBssidConnectionTimestampMs(s2,·s)·<=·this.mContext.getResources().getInteger(2131034112))·&&·this.handleBssidConnectionFailureInternal(s,·s2,·n,·n2);
269 ····}322 ····}
270 ····323 ····
271 ····public·void·handleBssidConnectionSuccess(final·String·s,·final·String·s2)·{324 ····public·void·handleBssidConnectionSuccess(final·String·s,·final·String·s2)·{
272 ········this.mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·0);325 ········this.mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·0);
273 ········final·WifiScoreCard·mWifiScoreCard·=·this.mWifiScoreCard;326 ········final·WifiScoreCard·mWifiScoreCard·=·this.mWifiScoreCard;
274 ········final·int·n·=·2;327 ········final·int·n·=·2;
275 ········mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·n);328 ········mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·n);
Offset 287, 14 lines modifiedOffset 340, 15 lines modified
287 ········mWifiScoreCard5.resetBssidBlocklistStreak(s2,·s,·n5);340 ········mWifiScoreCard5.resetBssidBlocklistStreak(s2,·s,·n5);
288 ········final·long·wallClockMillis·=·this.mClock.getWallClockMillis();341 ········final·long·wallClockMillis·=·this.mClock.getWallClockMillis();
289 ········final·long·n6·=·wallClockMillis·-·this.mWifiScoreCard.setBssidConnectionTimestampMs(s2,·s,·wallClockMillis);342 ········final·long·n6·=·wallClockMillis·-·this.mWifiScoreCard.setBssidConnectionTimestampMs(s2,·s,·wallClockMillis);
290 ········final·long·n7·=·lcmp(n6,·BssidBlocklistMonitor.ABNORMAL_DISCONNECT_RESET_TIME_MS);343 ········final·long·n7·=·lcmp(n6,·BssidBlocklistMonitor.ABNORMAL_DISCONNECT_RESET_TIME_MS);
291 ········final·int·n8·=·8;344 ········final·int·n8·=·8;
292 ········if·(n7·>·0)·{345 ········if·(n7·>·0)·{
293 ············this.mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·n8);346 ············this.mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·n8);
 347 ············this.mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·11);
294 ········}348 ········}
295 ········final·BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus·=·(BssidBlocklistMonitor$BssidStatus)this.mBssidStatusMap.get(s);349 ········final·BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus·=·(BssidBlocklistMonitor$BssidStatus)this.mBssidStatusMap.get(s);
296 ········if·(bssidBlocklistMonitor$BssidStatus·==·null)·{350 ········if·(bssidBlocklistMonitor$BssidStatus·==·null)·{
297 ············return;351 ············return;
298 ········}352 ········}
299 ········final·int[]·failureCount·=·bssidBlocklistMonitor$BssidStatus.failureCount;353 ········final·int[]·failureCount·=·bssidBlocklistMonitor$BssidStatus.failureCount;
300 ········failureCount[n]·=·(failureCount[0]·=·0);354 ········failureCount[n]·=·(failureCount[0]·=·0);
Offset 326, 26 lines modifiedOffset 380, 73 lines modified
326 ········final·int·n·=·1;380 ········final·int·n·=·1;
327 ········mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·n);381 ········mWifiScoreCard.resetBssidBlocklistStreak(s2,·s,·n);
328 ········final·BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus·=·(BssidBlocklistMonitor$BssidStatus)this.mBssidStatusMap.get(s);382 ········final·BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus·=·(BssidBlocklistMonitor$BssidStatus)this.mBssidStatusMap.get(s);
329 ········if·(bssidBlocklistMonitor$BssidStatus·==·null)·{383 ········if·(bssidBlocklistMonitor$BssidStatus·==·null)·{
330 ············return;384 ············return;
331 ········}385 ········}
332 ········bssidBlocklistMonitor$BssidStatus.failureCount[n]·=·0;386 ········bssidBlocklistMonitor$BssidStatus.failureCount[n]·=·0;
333 ········bssidBlocklistMonitor$BssidStatus.removeFromBlocklist();387 ········if·(bssidBlocklistMonitor$BssidStatus.isInBlocklist)·{
 388 ············this.mBssidStatusHistoryLogger.add(bssidBlocklistMonitor$BssidStatus,·"Network·validation·success");
 389 ············this.mBssidStatusMap.remove(s);
 390 ········}
 391 ····}
 392 ····
 393 ····public·void·tryEnablingBlockedBssids(final·List·list)·{
 394 ········if·(list·==·null)·{
 395 ············return;
 396 ········}
 397 ········final·Iterator<ScanDetail>·iterator·=·list.iterator();
 398 ········while·(iterator.hasNext())·{
 399 ············final·ScanResult·scanResult·=·((ScanDetail)iterator.next()).getScanResult();
 400 ············if·(scanResult·==·null)·{
 401 ················continue;
 402 ············}
 403 ············final·BssidBlocklistMonitor$BssidStatus·bssidBlocklistMonitor$BssidStatus·=·(BssidBlocklistMonitor$BssidStatus)this.mBssidStatusMap.get(scanResult.BSSID);
 404 ············if·(bssidBlocklistMonitor$BssidStatus·==·null·||·!bssidBlocklistMonitor$BssidStatus.isInBlocklist)·{
 405 ················continue;
 406 ············}
 407 ············if·(!BssidBlocklistMonitor.LOW_RSSI_SENSITIVE_FAILURES.contains(bssidBlocklistMonitor$BssidStatus.blockReason))·{
 408 ················continue;
 409 ············}
 410 ············final·int·sufficientRssi·=·this.mScoringParams.getSufficientRssi(scanResult.frequency);
 411 ············final·int·lastRssi·=·bssidBlocklistMonitor$BssidStatus.lastRssi;
 412 ············if·(lastRssi·>=·sufficientRssi)·{
 413 ················continue;
 414 ············}
 415 ············final·int·level·=·scanResult.level;
 416 ············if·(level·<·sufficientRssi·||·level·-·lastRssi·<·5)·{
 417 ················continue;
 418 ············}
 419 ············this.mBssidStatusHistoryLogger.add(bssidBlocklistMonitor$BssidStatus,·"rssi·significantly·improved");
 420 ············this.mBssidStatusMap.remove(bssidBlocklistMonitor$BssidStatus.bssid);
 421 ········}
334 ····}422 ····}
335 ····423 ····
336 ····public·Set·updateAndGetBssidBlocklist()·{424 ····public·Set·updateAndGetBssidBlocklist()·{
337 ········return·this.updateAndGetBssidBlocklistInternal().map((Function<?·super·Object,·?>)-$$Lambda$BssidBlocklistMonitor$IR5MLmoeNxDQ40KX7ud_PwD_e4M.INSTANCE).collect((Collector<?·super·Object,·Object,·Set<?·super·Object>>)Collectors.toSet());425 ········return·this.updateAndGetBssidBlocklistInternal().map((Function<?·super·Object,·?>)-$$Lambda$BssidBlocklistMonitor$y10i9Sv7__b6uz6ooLuITOo4q3A.INSTANCE).collect((Collector<?·super·Object,·Object,·Set<?·super·Object>>)Collectors.toSet());
 426 ····}
 427 ····
 428 ····public·Set·updateAndGetBssidBlocklistForSsid(final·String·s)·{
 429 ········final·int·numBlockedBssidsForSsid·=·this.getNumBlockedBssidsForSsid(s);
 430 ········final·Set·updateAndGetBssidBlocklist·=·this.updateAndGetBssidBlocklist();
 431 ········if·(this.getNumBlockedBssidsForSsid(s)·!=·numBlockedBssidsForSsid)·{
 432 ············this.updateFirmwareRoamingConfiguration(s);
 433 ········}
 434 ········return·updateAndGetBssidBlocklist;
 435 ····}
 436 ····
 437 ····public·int·updateAndGetNumBlockedBssidsForSsid(final·String·s)·{
 438 ········return·(int)this.updateAndGetBssidBlocklistInternal().filter((Predicate)new·-$$Lambda$BssidBlocklistMonitor$Sxk-cTBQCk_0SHkn4kYvzNh0-9I(s)).count();
338 ····}439 ····}
339 ····440 ····
340 ····public·void·updateFirmwareRoamingConfiguration(final·String·s)·{441 ····public·void·updateFirmwareRoamingConfiguration(final·String·s)·{
341 ········if·(!this.mConnectivityHelper.isFirmwareRoamingSupported())·{442 ········if·(!this.mConnectivityHelper.isFirmwareRoamingSupported())·{
342 ············return;443 ············return;
343 ········}444 ········}
344 ········ArrayList<?>·list·=·(ArrayList<?>)this.updateAndGetBssidBlocklistInternal().filter((Predicate<?·super·Object>)new·-$$Lambda$BssidBlocklistMonitor$0kWHBEDMDwyFhtpdfzfhoXfS5rs(s)).sorted((Comparator<?·super·Object>)-$$Lambda$BssidBlocklistMonitor$N7MQuU-tDrYrPJo28yGDfhw_YgQ.INSTANCE).map((Function<?·super·Object,·?>)-$$Lambda$BssidBlocklistMonitor$CbqxqKCQkWJBWBwmO_hgFa9w7e8.INSTANCE).collect(Collectors.toCollection((Supplier<ArrayList<?>>)-$$Lambda$OGSS2qx6njxlnp0dnKb4lA3jnw8.INSTANCE));445 ········ArrayList<?>·list·=·(ArrayList<?>)this.updateAndGetBssidBlocklistInternal().filter((Predicate<?·super·Object>)new·-$$Lambda$BssidBlocklistMonitor$5goGSdaC6NEACYS7wbOaLCCxYCY(s)).sorted((Comparator<?·super·Object>)-$$Lambda$BssidBlocklistMonitor$kGzSfU6wcZ_IZhPmnAT9ry9_M3s.INSTANCE).map((Function<?·super·Object,·?>)-$$Lambda$BssidBlocklistMonitor$dxai51gBeXZGiG3dnDxmTMvlzcM.INSTANCE).collect(Collectors.toCollection((Supplier<ArrayList<?>>)-$$Lambda$OGSS2qx6njxlnp0dnKb4lA3jnw8.INSTANCE));
345 ········final·int·maxNumBlacklistBssid·=·this.mConnectivityHelper.getMaxNumBlacklistBssid();446 ········final·int·maxNumBlacklistBssid·=·this.mConnectivityHelper.getMaxNumBlacklistBssid();
346 ········if·(maxNumBlacklistBssid·<=·0)·{447 ········if·(maxNumBlacklistBssid·<=·0)·{
347 ············final·StringBuilder·sb·=·new·StringBuilder();448 ············final·StringBuilder·sb·=·new·StringBuilder();
348 ············sb.append("Invalid·max·BSSID·blocklist·size:··");449 ············sb.append("Invalid·max·BSSID·blocklist·size:··");
349 ············sb.append(maxNumBlacklistBssid);450 ············sb.append(maxNumBlacklistBssid);
350 ············Log.e("BssidBlocklistMonitor",·sb.toString());451 ············Log.e("BssidBlocklistMonitor",·sb.toString());
351 ············return;452 ············return;