Remove NetworkPolicyManager.isUidBlocked() API.
It isn't used by ConnectivityService any more and even if it needs such utility method in the future, we could create one which is part of connectivity module and doesn't need to be exposed as part of NetworkPolicyManager API surface. Bug: 183696103 Test: atest ./tests/net/java/com/android/server/ConnectivityServiceTest.java Change-Id: Ie3c681f88e4b2b9bb92d2224c5ea96b074f155d5
This commit is contained in:
@@ -31,6 +31,7 @@ import static android.content.pm.PackageManager.PERMISSION_DENIED;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static android.net.ConnectivityManager.ACTION_CAPTIVE_PORTAL_SIGN_IN;
|
||||
import static android.net.ConnectivityManager.BLOCKED_METERED_REASON_DATA_SAVER;
|
||||
import static android.net.ConnectivityManager.BLOCKED_METERED_REASON_MASK;
|
||||
import static android.net.ConnectivityManager.BLOCKED_METERED_REASON_USER_RESTRICTED;
|
||||
import static android.net.ConnectivityManager.BLOCKED_REASON_BATTERY_SAVER;
|
||||
import static android.net.ConnectivityManager.BLOCKED_REASON_NONE;
|
||||
@@ -1373,10 +1374,21 @@ public class ConnectivityServiceTest {
|
||||
}
|
||||
|
||||
private void mockUidNetworkingBlocked() {
|
||||
doAnswer(i -> NetworkPolicyManager.isUidBlocked(mBlockedReasons, i.getArgument(1))
|
||||
doAnswer(i -> isUidBlocked(mBlockedReasons, i.getArgument(1))
|
||||
).when(mNetworkPolicyManager).isUidNetworkingBlocked(anyInt(), anyBoolean());
|
||||
}
|
||||
|
||||
private boolean isUidBlocked(int blockedReasons, boolean meteredNetwork) {
|
||||
final int blockedOnAllNetworksReason = (blockedReasons & ~BLOCKED_METERED_REASON_MASK);
|
||||
if (blockedOnAllNetworksReason != BLOCKED_REASON_NONE) {
|
||||
return true;
|
||||
}
|
||||
if (meteredNetwork) {
|
||||
return blockedReasons != BLOCKED_REASON_NONE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setBlockedReasonChanged(int blockedReasons) {
|
||||
mBlockedReasons = blockedReasons;
|
||||
mPolicyCallback.onUidBlockedReasonChanged(Process.myUid(), blockedReasons);
|
||||
|
||||
Reference in New Issue
Block a user