[connectivity] use new redact(RedactionType) for output NetworkSpecifier
This commit replace the existing usage of NetworkSpecifier#redact() to
the new NetworkSpecifier#redact(RedactionType) API.
This doesn't change the existing behavior because redact() is still
called for NetworkSpecifiers which doesn't oevrride
getApplicableRedactions() method.
Bug: 374037595
Flag: NONE can't use simply flag guarding because the code needs to
maintain compatibility across different mainline and platform versions
Change-Id: I30d7257b8e5880218b315ade60d2d77fed1f89fb
This commit is contained in:
parent
b9c6df36de
commit
997c5651d0
1 changed files with 101 additions and 5 deletions
|
|
@ -3326,12 +3326,22 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
newNc.setUids(null);
|
||||
newNc.setSSID(null);
|
||||
}
|
||||
// The NetworkCapabilities constructor above will only have redacted the
|
||||
// specifier if it implements the getApplicableRedactions method. If it does
|
||||
// not, then redact() must be called.
|
||||
if (newNc.getNetworkSpecifier() != null) {
|
||||
newNc.setNetworkSpecifier(newNc.getNetworkSpecifier().redact());
|
||||
// This code does not need to call redact(long) because that was already done above during
|
||||
// the construction of newNc.
|
||||
// If {@code getApplicableRedactions()} of a NetworkSpecifier subclass returns
|
||||
// {@code REDACT_NONE}, it's because either 1) it doesn't override it or 2) it does
|
||||
// override it, and the implementation returned REDACT_NONE. For the first case, call
|
||||
// {@code redact()} for backward compatibility with existing NetworkSpecifier such as
|
||||
// WifiNetworkSpecifier. For the second case, it's still okay to call {@code redact()} as
|
||||
// it's suggested that all new NetworkSpecifier subclasses should not override the default
|
||||
// {@code redact()} and it will do nothing (this is consistent with what REDACT_NONE
|
||||
// indicates).
|
||||
final NetworkSpecifier specifier = newNc.getNetworkSpecifier();
|
||||
if (specifier != null
|
||||
&& RedactionHelper.getSpecifierApplicableRedactions(specifier) == REDACT_NONE) {
|
||||
newNc.setNetworkSpecifier(specifier.redact());
|
||||
}
|
||||
|
||||
if (!hasAnyPermissionOf(mContext, callingPid, callingUid,
|
||||
android.Manifest.permission.NETWORK_STACK,
|
||||
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue