Add permission check for CaptivePortal#reevaluateNetwork

CaptivePortal#reevaluateNetwork is added as a system API which
requires a proper permission check.

Bug: 148379628
Test: Manually check with captive portal
Test: atest FrameworksNetTests
Test: make test-api-stubs-docs-update-current-api \
      system-api-stubs-docs-update-current-api

Change-Id: I3f974339d5bd53a6f6ecb0842c02a8264dc3a5f9
Merged-In: I559d42089aeb09801d14c251c5165fca793c3cb3
This commit is contained in:
Chiachang Wang
2020-02-12 13:44:50 +08:00
parent fc72c2ee39
commit f7a0f125db
2 changed files with 3 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
package android.net;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.os.IBinder;
@@ -153,6 +154,7 @@ public class CaptivePortal implements Parcelable {
*/
@SystemApi
@TestApi
@RequiresPermission(android.Manifest.permission.NETWORK_STACK)
public void reevaluateNetwork() {
try {
ICaptivePortal.Stub.asInterface(mBinder).appRequest(APP_REQUEST_REEVALUATION_REQUIRED);

View File

@@ -3744,6 +3744,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (nm == null) return;
if (request == CaptivePortal.APP_REQUEST_REEVALUATION_REQUIRED) {
checkNetworkStackPermission();
nm.forceReevaluation(Binder.getCallingUid());
}
}