Check NETWORK_SETTINGS permission for getAllNetworkStateSnapshots

This is declared in the API surface, but the implementation
does not match.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testGetAllNetworkStateSnapshots
Bug: 188140631

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I97aa69651461ebe5c323ec669372f9a61b84e6a6
Change-Id: I97aa69651461ebe5c323ec669372f9a61b84e6a6
  (cherry-picked from ag/14601670)
This commit is contained in:
junyulai
2021-05-14 18:04:29 +08:00
committed by Junyu Lai
parent de3c20ecb5
commit eaaacb0d47

View File

@@ -2223,7 +2223,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
@NonNull @NonNull
public List<NetworkStateSnapshot> getAllNetworkStateSnapshots() { public List<NetworkStateSnapshot> getAllNetworkStateSnapshots() {
// This contains IMSI details, so make sure the caller is privileged. // This contains IMSI details, so make sure the caller is privileged.
PermissionUtils.enforceNetworkStackPermission(mContext); enforceNetworkStackOrSettingsPermission();
final ArrayList<NetworkStateSnapshot> result = new ArrayList<>(); final ArrayList<NetworkStateSnapshot> result = new ArrayList<>();
for (Network network : getAllNetworks()) { for (Network network : getAllNetworks()) {