From 4cf96ab3ccf4799ab7ad586995e416123ef69c12 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Tue, 16 Mar 2021 18:06:06 +0900 Subject: [PATCH] Add startCaptivePortalApp to system API The API is already used by settings and should be usable by setup wizards. It is the only way for a caller outside of the system_server to trigger the captive portal application. The API is already CTS tested in android.net.cts.CaptivePortalTest. Fixes: 182871577 Test: atest CtsNetTestCases:android.net.cts.CaptivePortalTest Change-Id: Ie8d9a546b54524ba837715baa94a07d1f993d8d3 --- framework/api/module-lib-current.txt | 1 + framework/src/android/net/ConnectivityManager.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/api/module-lib-current.txt b/framework/api/module-lib-current.txt index ab039165ad..37312fa79d 100644 --- a/framework/api/module-lib-current.txt +++ b/framework/api/module-lib-current.txt @@ -19,6 +19,7 @@ package android.net { method @RequiresPermission(android.Manifest.permission.NETWORK_STACK) public void setGlobalProxy(@Nullable android.net.ProxyInfo); method @RequiresPermission(android.Manifest.permission.NETWORK_STACK) public void setProfileNetworkPreference(@NonNull android.os.UserHandle, int, @Nullable java.util.concurrent.Executor, @Nullable Runnable); method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_TEST_NETWORKS, android.Manifest.permission.NETWORK_STACK}) public void simulateDataStall(int, long, @NonNull android.net.Network, @NonNull android.os.PersistableBundle); + method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public void startCaptivePortalApp(@NonNull android.net.Network); method public void systemReady(); field public static final String PRIVATE_DNS_MODE_OFF = "off"; field public static final String PRIVATE_DNS_MODE_OPPORTUNISTIC = "opportunistic"; diff --git a/framework/src/android/net/ConnectivityManager.java b/framework/src/android/net/ConnectivityManager.java index 786ed240e3..fe05f3a9de 100644 --- a/framework/src/android/net/ConnectivityManager.java +++ b/framework/src/android/net/ConnectivityManager.java @@ -4461,12 +4461,20 @@ public class ConnectivityManager { /** * Requests that the system open the captive portal app on the specified network. * + *

This is to be used on networks where a captive portal was detected, as per + * {@link NetworkCapabilities#NET_CAPABILITY_CAPTIVE_PORTAL}. + * * @param network The network to log into. * * @hide */ - @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) - public void startCaptivePortalApp(Network network) { + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + @RequiresPermission(anyOf = { + android.Manifest.permission.NETWORK_SETTINGS, + android.Manifest.permission.NETWORK_STACK, + NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK + }) + public void startCaptivePortalApp(@NonNull Network network) { try { mService.startCaptivePortalApp(network); } catch (RemoteException e) {