Revert "Return the registry in registerNetworkAgent."
Revert submission 3535182 Reason for revert: <Droidmonitor created revert due to b/404070202.Will be verified through ABTD for standard investigation.> Reverted changes: /q/submissionid:3535182 Change-Id: I2febd2ee7227d487d9cd69dcabd9c04f888fd2de
This commit is contained in:
parent
30fcf820f9
commit
653d5f1ef4
6 changed files with 32 additions and 104 deletions
|
|
@ -1252,13 +1252,9 @@ public class ConnectivityManager {
|
|||
* {@link ConnectivityManager#registerNetworkAgent}
|
||||
* @hide
|
||||
*/
|
||||
public static NetworkAndAgentRegistryParcelable registerNetworkAgentResult(
|
||||
public static Network registerNetworkAgentResult(
|
||||
@Nullable final Network network, @Nullable final INetworkAgentRegistry registry) {
|
||||
final NetworkAndAgentRegistryParcelable result =
|
||||
new NetworkAndAgentRegistryParcelable();
|
||||
result.network = network;
|
||||
result.registry = registry;
|
||||
return result;
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3972,8 +3968,7 @@ public class ConnectivityManager {
|
|||
@RequiresPermission(anyOf = {
|
||||
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
|
||||
android.Manifest.permission.NETWORK_FACTORY})
|
||||
public NetworkAndAgentRegistryParcelable registerNetworkAgent(
|
||||
@NonNull INetworkAgent na, @NonNull NetworkInfo ni,
|
||||
public Network registerNetworkAgent(@NonNull INetworkAgent na, @NonNull NetworkInfo ni,
|
||||
@NonNull LinkProperties lp, @NonNull NetworkCapabilities nc,
|
||||
@NonNull NetworkScore score, @NonNull NetworkAgentConfig config, int providerId) {
|
||||
return registerNetworkAgent(na, ni, lp, nc, null /* localNetworkConfig */, score, config,
|
||||
|
|
@ -3988,8 +3983,7 @@ public class ConnectivityManager {
|
|||
@RequiresPermission(anyOf = {
|
||||
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
|
||||
android.Manifest.permission.NETWORK_FACTORY})
|
||||
public NetworkAndAgentRegistryParcelable registerNetworkAgent(
|
||||
@NonNull INetworkAgent na, @NonNull NetworkInfo ni,
|
||||
public Network registerNetworkAgent(@NonNull INetworkAgent na, @NonNull NetworkInfo ni,
|
||||
@NonNull LinkProperties lp, @NonNull NetworkCapabilities nc,
|
||||
@Nullable LocalNetworkConfig localNetworkConfig, @NonNull NetworkScore score,
|
||||
@NonNull NetworkAgentConfig config, int providerId) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import android.net.LinkProperties;
|
|||
import android.net.LocalNetworkConfig;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkAgentConfig;
|
||||
import android.net.NetworkAndAgentRegistryParcelable;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.NetworkRequest;
|
||||
|
|
@ -147,8 +146,7 @@ interface IConnectivityManager
|
|||
|
||||
void declareNetworkRequestUnfulfillable(in NetworkRequest request);
|
||||
|
||||
NetworkAndAgentRegistryParcelable registerNetworkAgent(
|
||||
in INetworkAgent na, in NetworkInfo ni, in LinkProperties lp,
|
||||
Network registerNetworkAgent(in INetworkAgent na, in NetworkInfo ni, in LinkProperties lp,
|
||||
in NetworkCapabilities nc, in NetworkScore score,
|
||||
in LocalNetworkConfig localNetworkConfig, in NetworkAgentConfig config,
|
||||
in int factorySerialNumber);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import android.net.INetworkAgentRegistry;
|
|||
* @hide
|
||||
*/
|
||||
oneway interface INetworkAgent {
|
||||
void onRegistered();
|
||||
void onRegistered(in INetworkAgentRegistry registry);
|
||||
void onDisconnected();
|
||||
void onBandwidthUpdateRequested();
|
||||
void onValidationStatusChanged(int validationStatus,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import android.telephony.data.NrQosSessionAttributes;
|
|||
* Interface for NetworkAgents to send network properties.
|
||||
* @hide
|
||||
*/
|
||||
interface INetworkAgentRegistry {
|
||||
oneway interface INetworkAgentRegistry {
|
||||
void sendNetworkCapabilities(in NetworkCapabilities nc);
|
||||
void sendLinkProperties(in LinkProperties lp);
|
||||
// TODO: consider replacing this by "markConnected()" and removing
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ public abstract class NetworkAgent {
|
|||
@Nullable
|
||||
private volatile Network mNetwork;
|
||||
|
||||
// Null before the agent is registered
|
||||
@Nullable
|
||||
private volatile INetworkAgentRegistry mRegistry;
|
||||
|
||||
|
|
@ -122,8 +121,6 @@ public abstract class NetworkAgent {
|
|||
private NetworkInfo mNetworkInfo;
|
||||
@NonNull
|
||||
private final Object mRegisterLock = new Object();
|
||||
// TODO : move the preconnected queue to the system server and remove this
|
||||
private boolean mConnected = false;
|
||||
|
||||
/**
|
||||
* The ID of the {@link NetworkProvider} that created this object, or
|
||||
|
|
@ -609,16 +606,16 @@ public abstract class NetworkAgent {
|
|||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case EVENT_AGENT_CONNECTED: {
|
||||
// TODO : move the pre-connected queue to the system server, and remove
|
||||
// handling this EVENT_AGENT_CONNECTED message.
|
||||
synchronized (mPreConnectedQueue) {
|
||||
if (mConnected) {
|
||||
log("Received new connection while already connected!");
|
||||
} else {
|
||||
if (VDBG) log("NetworkAgent fully connected");
|
||||
if (mRegistry != null) {
|
||||
log("Received new connection while already connected!");
|
||||
} else {
|
||||
if (VDBG) log("NetworkAgent fully connected");
|
||||
synchronized (mPreConnectedQueue) {
|
||||
final INetworkAgentRegistry registry = (INetworkAgentRegistry) msg.obj;
|
||||
mRegistry = registry;
|
||||
for (RegistryAction a : mPreConnectedQueue) {
|
||||
try {
|
||||
a.execute(mRegistry);
|
||||
a.execute(registry);
|
||||
} catch (RemoteException e) {
|
||||
Log.wtf(LOG_TAG, "Communication error with registry", e);
|
||||
// Fall through
|
||||
|
|
@ -626,7 +623,6 @@ public abstract class NetworkAgent {
|
|||
}
|
||||
mPreConnectedQueue.clear();
|
||||
}
|
||||
mConnected = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -635,7 +631,7 @@ public abstract class NetworkAgent {
|
|||
// let the client know CS is done with us.
|
||||
onNetworkUnwanted();
|
||||
synchronized (mPreConnectedQueue) {
|
||||
mConnected = false;
|
||||
mRegistry = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -762,32 +758,20 @@ public abstract class NetworkAgent {
|
|||
}
|
||||
final ConnectivityManager cm = (ConnectivityManager) mInitialConfiguration.context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
final NetworkAndAgentRegistryParcelable result;
|
||||
if (mInitialConfiguration.localNetworkConfig == null) {
|
||||
// Call registerNetworkAgent without localNetworkConfig argument to pass
|
||||
// android.net.cts.NetworkAgentTest#testAgentStartsInConnecting in old cts
|
||||
result = cm.registerNetworkAgent(new NetworkAgentBinder(mHandler),
|
||||
mNetwork = cm.registerNetworkAgent(new NetworkAgentBinder(mHandler),
|
||||
new NetworkInfo(mInitialConfiguration.info),
|
||||
mInitialConfiguration.properties, mInitialConfiguration.capabilities,
|
||||
mInitialConfiguration.score, mInitialConfiguration.config, providerId);
|
||||
} else {
|
||||
result = cm.registerNetworkAgent(new NetworkAgentBinder(mHandler),
|
||||
mNetwork = cm.registerNetworkAgent(new NetworkAgentBinder(mHandler),
|
||||
new NetworkInfo(mInitialConfiguration.info),
|
||||
mInitialConfiguration.properties, mInitialConfiguration.capabilities,
|
||||
mInitialConfiguration.localNetworkConfig, mInitialConfiguration.score,
|
||||
mInitialConfiguration.config, providerId);
|
||||
}
|
||||
if (null == result && Process.isApplicationUid(Process.myUid())) {
|
||||
// Let it slide in tests to allow mocking, since NetworkAndAgentRegistryParcelable
|
||||
// is not public and can't be instantiated by CTS. The danger here is that if
|
||||
// this happens in production for some reason the code will crash later instead
|
||||
// of here. If this is a system app, it will still crash as expected.
|
||||
Log.e(LOG_TAG, "registerNetworkAgent returned null. This agent will not work. "
|
||||
+ "Is ConnectivityManager a mock ?");
|
||||
} else {
|
||||
mNetwork = result.network;
|
||||
mRegistry = result.registry;
|
||||
}
|
||||
mInitialConfiguration = null; // All this memory can now be GC'd
|
||||
}
|
||||
return mNetwork;
|
||||
|
|
@ -803,8 +787,8 @@ public abstract class NetworkAgent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRegistered() {
|
||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_AGENT_CONNECTED));
|
||||
public void onRegistered(@NonNull INetworkAgentRegistry registry) {
|
||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_AGENT_CONNECTED, registry));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -929,13 +913,11 @@ public abstract class NetworkAgent {
|
|||
*
|
||||
* @hide
|
||||
*/
|
||||
public INetworkAgent registerForTest(final Network network,
|
||||
final INetworkAgentRegistry registry) {
|
||||
public INetworkAgent registerForTest(final Network network) {
|
||||
log("Registering NetworkAgent for test");
|
||||
synchronized (mRegisterLock) {
|
||||
mNetwork = network;
|
||||
mInitialConfiguration = null;
|
||||
mRegistry = registry;
|
||||
}
|
||||
return new NetworkAgentBinder(mHandler);
|
||||
}
|
||||
|
|
@ -976,7 +958,7 @@ public abstract class NetworkAgent {
|
|||
FrameworkConnectivityStatsLog.CORE_NETWORKING_TERRIBLE_ERROR_OCCURRED__ERROR_TYPE__TYPE_MESSAGE_QUEUED_BEFORE_CONNECT
|
||||
);
|
||||
}
|
||||
if (mConnected) {
|
||||
if (mRegistry != null) {
|
||||
try {
|
||||
action.execute(mRegistry);
|
||||
} catch (RemoteException e) {
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2025 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;
|
||||
|
||||
import android.net.INetworkAgentRegistry;
|
||||
import android.net.Network;
|
||||
|
||||
/**
|
||||
* A pair of Network and NetworkAgentRegistry.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
@JavaDerive(toString=true)
|
||||
parcelable NetworkAndAgentRegistryParcelable {
|
||||
Network network;
|
||||
INetworkAgentRegistry registry;
|
||||
}
|
||||
Loading…
Reference in a new issue