Expose the enterprise per-profile networking API.

Also unify the listener for Oem settings, which have
never been released as public API (it is slated to be
released in S).

Test: FrameworksNetTests
Change-Id: I84ba363dd0ec03871c37b1c3a31e5557d9aa12e7
This commit is contained in:
Chalard Jean
2021-03-03 16:37:13 +09:00
parent b5a139f32a
commit 6010c00ecd
6 changed files with 22 additions and 59 deletions

View File

@@ -976,7 +976,7 @@ public class ConnectivityManager {
* Specify that the traffic for this user should by follow the default rules.
* @hide
*/
// TODO : @SystemApi
@SystemApi
public static final int PROFILE_NETWORK_PREFERENCE_DEFAULT = 0;
/**
@@ -986,7 +986,7 @@ public class ConnectivityManager {
* if no such network is available.
* @hide
*/
// TODO : @SystemApi
@SystemApi
public static final int PROFILE_NETWORK_PREFERENCE_ENTERPRISE = 1;
/** @hide */
@@ -5076,21 +5076,6 @@ public class ConnectivityManager {
TYPE_NONE, new CallbackHandler(handler));
}
/**
* Listener for {@link #setOemNetworkPreference(OemNetworkPreferences, Executor,
* OnSetOemNetworkPreferenceListener)}.
* @hide
*/
// TODO : remove this in favor of a vanilla runnable to follow API guidance to use
// functional interfaces when they are appropriate.
@SystemApi
public interface OnSetOemNetworkPreferenceListener {
/**
* Called when setOemNetworkPreference() successfully completes.
*/
void onComplete();
}
/**
* Used by automotive devices to set the network preferences used to direct traffic at an
* application level as per the given OemNetworkPreferences. An example use-case would be an
@@ -5113,16 +5098,16 @@ public class ConnectivityManager {
@RequiresPermission(android.Manifest.permission.CONTROL_OEM_PAID_NETWORK_PREFERENCE)
public void setOemNetworkPreference(@NonNull final OemNetworkPreferences preference,
@Nullable @CallbackExecutor final Executor executor,
@Nullable final OnSetOemNetworkPreferenceListener listener) {
@Nullable final Runnable listener) {
Objects.requireNonNull(preference, "OemNetworkPreferences must be non-null");
if (null != listener) {
Objects.requireNonNull(executor, "Executor must be non-null");
}
final IOnSetOemNetworkPreferenceListener listenerInternal = listener == null ? null :
new IOnSetOemNetworkPreferenceListener.Stub() {
final IOnCompleteListener listenerInternal = listener == null ? null :
new IOnCompleteListener.Stub() {
@Override
public void onComplete() {
executor.execute(listener::onComplete);
executor.execute(listener::run);
}
};
@@ -5148,7 +5133,12 @@ public class ConnectivityManager {
* @throws SecurityException if missing the appropriate permissions.
* @hide
*/
// TODO : @SystemApi
// This function is for establishing per-profile default networking and can only be called by
// the device policy manager, running as the system server. It would make no sense to call it
// on a context for a user because it does not establish a setting on behalf of a user, rather
// it establishes a setting for a user on behalf of the DPM.
@SuppressLint({"UserHandle"})
@SystemApi(client = MODULE_LIBRARIES)
@RequiresPermission(android.Manifest.permission.NETWORK_STACK)
public void setProfileNetworkPreference(@NonNull final UserHandle profile,
@ProfileNetworkPreference final int preference,

View File

@@ -21,7 +21,6 @@ import android.net.ConnectionInfo;
import android.net.ConnectivityDiagnosticsManager;
import android.net.IConnectivityDiagnosticsCallback;
import android.net.IOnCompleteListener;
import android.net.IOnSetOemNetworkPreferenceListener;
import android.net.INetworkActivityListener;
import android.net.IQosCallback;
import android.net.ISocketKeepaliveCallback;
@@ -217,7 +216,7 @@ interface IConnectivityManager
void unregisterQosCallback(in IQosCallback callback);
void setOemNetworkPreference(in OemNetworkPreferences preference,
in IOnSetOemNetworkPreferenceListener listener);
in IOnCompleteListener listener);
void setProfileNetworkPreference(in UserHandle profile, int preference,
in IOnCompleteListener listener);

View File

@@ -1,23 +0,0 @@
/**
*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.net;
/** @hide */
oneway interface IOnSetOemNetworkPreferenceListener {
void onComplete();
}