Merge "Remove NetworkPolicyManager.isUidBlocked() API." am: 9cff99d059
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652550 Change-Id: Ia95b11bcf91f18338b26146f6bb9488861555303
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