Opt-out for always-on VPN: rename API.

Rename the opt-out flag in AndroidManifest to
SERVICE_META_DATA_SUPPORTS_ALWAYS_ON
as directed by the API Council.

Bug: 64331776
Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Change-Id: I24326fad7a89083a2409134640bda81ee0359d08
Merged-In: I24326fad7a89083a2409134640bda81ee0359d08
(cherry picked from commit c57a01c166)
This commit is contained in:
Charles He
2017-08-15 15:30:22 +01:00
parent a0a87e8108
commit 5da5ae3b96
8 changed files with 14 additions and 13 deletions

View File

@@ -26001,8 +26001,8 @@ package android.net {
method public boolean protect(java.net.Socket);
method public boolean protect(java.net.DatagramSocket);
method public boolean setUnderlyingNetworks(android.net.Network[]);
field public static final java.lang.String METADATA_SUPPORTS_ALWAYS_ON = "android.net.VpnService.SUPPORTS_ALWAYS_ON";
field public static final java.lang.String SERVICE_INTERFACE = "android.net.VpnService";
field public static final java.lang.String SERVICE_META_DATA_SUPPORTS_ALWAYS_ON = "android.net.VpnService.SUPPORTS_ALWAYS_ON";
}
public class VpnService.Builder {

View File

@@ -28265,8 +28265,8 @@ package android.net {
method public boolean protect(java.net.Socket);
method public boolean protect(java.net.DatagramSocket);
method public boolean setUnderlyingNetworks(android.net.Network[]);
field public static final java.lang.String METADATA_SUPPORTS_ALWAYS_ON = "android.net.VpnService.SUPPORTS_ALWAYS_ON";
field public static final java.lang.String SERVICE_INTERFACE = "android.net.VpnService";
field public static final java.lang.String SERVICE_META_DATA_SUPPORTS_ALWAYS_ON = "android.net.VpnService.SUPPORTS_ALWAYS_ON";
}
public class VpnService.Builder {

View File

@@ -26110,8 +26110,8 @@ package android.net {
method public boolean protect(java.net.Socket);
method public boolean protect(java.net.DatagramSocket);
method public boolean setUnderlyingNetworks(android.net.Network[]);
field public static final java.lang.String METADATA_SUPPORTS_ALWAYS_ON = "android.net.VpnService.SUPPORTS_ALWAYS_ON";
field public static final java.lang.String SERVICE_INTERFACE = "android.net.VpnService";
field public static final java.lang.String SERVICE_META_DATA_SUPPORTS_ALWAYS_ON = "android.net.VpnService.SUPPORTS_ALWAYS_ON";
}
public class VpnService.Builder {

View File

@@ -3912,7 +3912,7 @@ public class DevicePolicyManager {
* {@link android.Manifest.permission#BIND_VPN_SERVICE};</li>
* <li>target {@link android.os.Build.VERSION_CODES#N API 24} or above; and</li>
* <li><i>not</i> explicitly opt out of the feature through
* {@link android.net.VpnService#METADATA_SUPPORTS_ALWAYS_ON}.</li>
* {@link android.net.VpnService#SERVICE_META_DATA_SUPPORTS_ALWAYS_ON}.</li>
* </ul>
* The call will fail if called with the package name of an unsupported VPN app.
*

View File

@@ -840,8 +840,8 @@ public class ConnectivityManager {
* In order to support the always-on feature, an app has to
* <ul>
* <li>target {@link VERSION_CODES#N API 24} or above, and
* <li>not opt out through the {@link VpnService#METADATA_SUPPORTS_ALWAYS_ON} meta-data
* field.
* <li>not opt out through the {@link VpnService#SERVICE_META_DATA_SUPPORTS_ALWAYS_ON}
* meta-data field.
* </ul>
*
* @param userId The identifier of the user for whom the VPN app is installed.

View File

@@ -145,9 +145,10 @@ public class VpnService extends Service {
* </service>
* } </pre>
*
* <p>This meta-data field defaults to {@code true} if absent.
* <p>This meta-data field defaults to {@code true} if absent. It will only have effect on
* {@link android.os.Build.VERSION_CODES#O_MR1} or higher.
*/
public static final String METADATA_SUPPORTS_ALWAYS_ON =
public static final String SERVICE_META_DATA_SUPPORTS_ALWAYS_ON =
"android.net.VpnService.SUPPORTS_ALWAYS_ON";
/**

View File

@@ -305,8 +305,8 @@ public class Vpn {
* In order to support the always-on feature, an app has to
* <ul>
* <li>target {@link VERSION_CODES#N API 24} or above, and
* <li>not opt out through the {@link VpnService#METADATA_SUPPORTS_ALWAYS_ON} meta-data
* field.
* <li>not opt out through the {@link VpnService#SERVICE_META_DATA_SUPPORTS_ALWAYS_ON}
* meta-data field.
* </ul>
*
* @param packageName the canonical package name of the VPN app
@@ -340,8 +340,8 @@ public class Vpn {
for (ResolveInfo rInfo : services) {
final Bundle metaData = rInfo.serviceInfo.metaData;
if (metaData != null
&& !metaData.getBoolean(VpnService.METADATA_SUPPORTS_ALWAYS_ON, true)) {
if (metaData != null &&
!metaData.getBoolean(VpnService.SERVICE_META_DATA_SUPPORTS_ALWAYS_ON, true)) {
return false;
}
}

View File

@@ -346,7 +346,7 @@ public class VpnTest extends AndroidTestCase {
// Apps that opt out explicitly are not supported
appInfo.targetSdkVersion = VERSION_CODES.CUR_DEVELOPMENT;
Bundle metaData = new Bundle();
metaData.putBoolean(VpnService.METADATA_SUPPORTS_ALWAYS_ON, false);
metaData.putBoolean(VpnService.SERVICE_META_DATA_SUPPORTS_ALWAYS_ON, false);
svcInfo.metaData = metaData;
assertFalse(vpn.isAlwaysOnPackageSupported(PKGS[0]));
}