Rename redactNetworkCapabilitiesForPackage and update its javadoc

The API won't modify the passed NetworkCapabilities and
LinkProperties, but redactNetworkCapabilitiesForPackage and
redactLinkPropertiesForPackage sound like they will. To reduce
the confusion, rename the API with prefix "getRedacted".
Also modify the javadoc to describe more about what the API will
do if the given UID doesn't have location permission.

Bug: 220367512
Test: atest CtsNetTestCases
Change-Id: I964f1062da1ae96df9b369b911486da1379b8a19
This commit is contained in:
lucaslin
2022-03-02 10:56:57 +08:00
parent 87db609348
commit d2b0613814
5 changed files with 34 additions and 30 deletions

View File

@@ -1643,10 +1643,10 @@ public class ConnectivityManager {
android.Manifest.permission.NETWORK_SETTINGS})
@SystemApi(client = MODULE_LIBRARIES)
@Nullable
public LinkProperties redactLinkPropertiesForPackage(@NonNull LinkProperties lp, int uid,
public LinkProperties getRedactedLinkPropertiesForPackage(@NonNull LinkProperties lp, int uid,
@NonNull String packageName) {
try {
return mService.redactLinkPropertiesForPackage(
return mService.getRedactedLinkPropertiesForPackage(
lp, uid, packageName, getAttributionTag());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -1683,9 +1683,11 @@ public class ConnectivityManager {
* Redact {@link NetworkCapabilities} for a given package.
*
* Returns an instance of {@link NetworkCapabilities} that is appropriately redacted to send
* to the given package, considering its permissions. Calling this method will blame the UID for
* retrieving the device location if the passed capabilities contain location-sensitive
* information.
* to the given package, considering its permissions. If the passed capabilities contain
* location-sensitive information, they will be redacted to the correct degree for the location
* permissions of the app (COARSE or FINE), and will blame the UID accordingly for retrieving
* that level of location. If the UID holds no location permission, the returned object will
* contain no location-sensitive information and the UID is not blamed.
*
* @param nc A {@link NetworkCapabilities} instance which will be redacted.
* @param uid The target uid.
@@ -1700,11 +1702,11 @@ public class ConnectivityManager {
android.Manifest.permission.NETWORK_SETTINGS})
@SystemApi(client = MODULE_LIBRARIES)
@Nullable
public NetworkCapabilities redactNetworkCapabilitiesForPackage(
public NetworkCapabilities getRedactedNetworkCapabilitiesForPackage(
@NonNull NetworkCapabilities nc,
int uid, @NonNull String packageName) {
try {
return mService.redactNetworkCapabilitiesForPackage(nc, uid, packageName,
return mService.getRedactedNetworkCapabilitiesForPackage(nc, uid, packageName,
getAttributionTag());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();