Merge "Rename getXXX to makeXXX in TetheringDependencies" into main

This commit is contained in:
Treehugger Robot 2023-12-05 06:42:25 +00:00 • committed by Gerrit Code Review
commit ef41398c1f
4 changed files with 56 additions and 56 deletions

View file

@ -303,9 +303,9 @@ public class Tethering {
mContext = mDeps.getContext();
mNetd = mDeps.getINetd(mContext);
mRoutingCoordinator = mDeps.getRoutingCoordinator(mContext);
mLooper = mDeps.getTetheringLooper();
mNotificationUpdater = mDeps.getNotificationUpdater(mContext, mLooper);
mTetheringMetrics = mDeps.getTetheringMetrics();
mLooper = mDeps.makeTetheringLooper();
mNotificationUpdater = mDeps.makeNotificationUpdater(mContext, mLooper);
mTetheringMetrics = mDeps.makeTetheringMetrics();
// This is intended to ensrure that if something calls startTethering(bluetooth) just after
// bluetooth is enabled. Before onServiceConnected is called, store the calls into this
@ -319,7 +319,7 @@ public class Tethering {
mTetherMainSM.start();
mHandler = mTetherMainSM.getHandler();
mOffloadController = mDeps.getOffloadController(mHandler, mLog,
mOffloadController = mDeps.makeOffloadController(mHandler, mLog,
new OffloadController.Dependencies() {
@Override
@ -327,7 +327,7 @@ public class Tethering {
return mConfig;
}
});
mUpstreamNetworkMonitor = mDeps.getUpstreamNetworkMonitor(mContext, mHandler, mLog,
mUpstreamNetworkMonitor = mDeps.makeUpstreamNetworkMonitor(mContext, mHandler, mLog,
(what, obj) -> {
mTetherMainSM.sendMessage(TetherMainSM.EVENT_UPSTREAM_CALLBACK, what, 0, obj);
});
@ -337,7 +337,7 @@ public class Tethering {
filter.addAction(ACTION_CARRIER_CONFIG_CHANGED);
// EntitlementManager will send EVENT_UPSTREAM_PERMISSION_CHANGED when cellular upstream
// permission is changed according to entitlement check result.
mEntitlementMgr = mDeps.getEntitlementManager(mContext, mHandler, mLog,
mEntitlementMgr = mDeps.makeEntitlementManager(mContext, mHandler, mLog,
() -> mTetherMainSM.sendMessage(
TetherMainSM.EVENT_UPSTREAM_PERMISSION_CHANGED));
mEntitlementMgr.setOnTetherProvisioningFailedListener((downstream, reason) -> {
@ -373,11 +373,11 @@ public class Tethering {
// It is OK for the configuration to be passed to the PrivateAddressCoordinator at
// construction time because the only part of the configuration it uses is
// shouldEnableWifiP2pDedicatedIp(), and currently do not support changing that.
mPrivateAddressCoordinator = mDeps.getPrivateAddressCoordinator(mContext, mConfig);
mPrivateAddressCoordinator = mDeps.makePrivateAddressCoordinator(mContext, mConfig);
// Must be initialized after tethering configuration is loaded because BpfCoordinator
// constructor needs to use the configuration.
mBpfCoordinator = mDeps.getBpfCoordinator(
mBpfCoordinator = mDeps.makeBpfCoordinator(
new BpfCoordinator.Dependencies() {
@NonNull
public Handler getHandler() {
@ -406,7 +406,7 @@ public class Tethering {
});
if (SdkLevel.isAtLeastT() && mConfig.isWearTetheringEnabled()) {
mWearableConnectionManager = mDeps.getWearableConnectionManager(mContext);
mWearableConnectionManager = mDeps.makeWearableConnectionManager(mContext);
} else {
mWearableConnectionManager = null;
}
@ -875,7 +875,7 @@ public class Tethering {
private void changeBluetoothTetheringSettings(@NonNull final BluetoothPan bluetoothPan,
final boolean enable) {
final BluetoothPanShim panShim = mDeps.getBluetoothPanShim(bluetoothPan);
final BluetoothPanShim panShim = mDeps.makeBluetoothPanShim(bluetoothPan);
if (enable) {
if (mBluetoothIfaceRequest != null) {
Log.d(TAG, "Bluetooth tethering settings already enabled");
@ -1739,7 +1739,7 @@ public class Tethering {
addState(mSetDnsForwardersErrorState);
mNotifyList = new ArrayList<>();
mIPv6TetheringCoordinator = deps.getIPv6TetheringCoordinator(mNotifyList, mLog);
mIPv6TetheringCoordinator = deps.makeIPv6TetheringCoordinator(mNotifyList, mLog);
mOffload = new OffloadWrapper();
setInitialState(mInitialState);
@ -2844,7 +2844,7 @@ public class Tethering {
new IpServer(iface, mHandler, interfaceType, mLog, mNetd, mBpfCoordinator,
mRoutingCoordinator, new ControlCallback(), mConfig,
mPrivateAddressCoordinator, mTetheringMetrics,
mDeps.getIpServerDependencies()), isNcm);
mDeps.makeIpServerDependencies()), isNcm);
mTetherStates.put(iface, tetherState);
tetherState.ipServer.start();
}

View file

@ -53,58 +53,58 @@ import java.util.ArrayList;
*/
public abstract class TetheringDependencies {
/**
* Get a reference to the BpfCoordinator to be used by tethering.
* Make the BpfCoordinator to be used by tethering.
*/
public @NonNull BpfCoordinator getBpfCoordinator(
public @NonNull BpfCoordinator makeBpfCoordinator(
@NonNull BpfCoordinator.Dependencies deps) {
return new BpfCoordinator(deps);
}
/**
* Get a reference to the offload hardware interface to be used by tethering.
* Make the offload hardware interface to be used by tethering.
*/
public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) {
public OffloadHardwareInterface makeOffloadHardwareInterface(Handler h, SharedLog log) {
return new OffloadHardwareInterface(h, log);
}
/**
* Get a reference to the offload controller to be used by tethering.
* Make the offload controller to be used by tethering.
*/
@NonNull
public OffloadController getOffloadController(@NonNull Handler h,
public OffloadController makeOffloadController(@NonNull Handler h,
@NonNull SharedLog log, @NonNull OffloadController.Dependencies deps) {
final NetworkStatsManager statsManager =
(NetworkStatsManager) getContext().getSystemService(Context.NETWORK_STATS_SERVICE);
return new OffloadController(h, getOffloadHardwareInterface(h, log),
return new OffloadController(h, makeOffloadHardwareInterface(h, log),
getContext().getContentResolver(), statsManager, log, deps);
}
/**
* Get a reference to the UpstreamNetworkMonitor to be used by tethering.
* Make the UpstreamNetworkMonitor to be used by tethering.
*/
public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, Handler h,
public UpstreamNetworkMonitor makeUpstreamNetworkMonitor(Context ctx, Handler h,
SharedLog log, UpstreamNetworkMonitor.EventListener listener) {
return new UpstreamNetworkMonitor(ctx, h, log, listener);
}
/**
* Get a reference to the IPv6TetheringCoordinator to be used by tethering.
* Make the IPv6TetheringCoordinator to be used by tethering.
*/
public IPv6TetheringCoordinator getIPv6TetheringCoordinator(
public IPv6TetheringCoordinator makeIPv6TetheringCoordinator(
ArrayList<IpServer> notifyList, SharedLog log) {
return new IPv6TetheringCoordinator(notifyList, log);
}
/**
* Get dependencies to be used by IpServer.
* Make dependencies to be used by IpServer.
*/
public abstract IpServer.Dependencies getIpServerDependencies();
public abstract IpServer.Dependencies makeIpServerDependencies();
/**
* Get a reference to the EntitlementManager to be used by tethering.
* Make the EntitlementManager to be used by tethering.
*/
public EntitlementManager getEntitlementManager(Context ctx, Handler h, SharedLog log,
public EntitlementManager makeEntitlementManager(Context ctx, Handler h, SharedLog log,
Runnable callback) {
return new EntitlementManager(ctx, h, log, callback);
}
@ -136,17 +136,17 @@ public abstract class TetheringDependencies {
}
/**
* Get a reference to the TetheringNotificationUpdater to be used by tethering.
* Make the TetheringNotificationUpdater to be used by tethering.
*/
public TetheringNotificationUpdater getNotificationUpdater(@NonNull final Context ctx,
public TetheringNotificationUpdater makeNotificationUpdater(@NonNull final Context ctx,
@NonNull final Looper looper) {
return new TetheringNotificationUpdater(ctx, looper);
}
/**
* Get tethering thread looper.
* Make tethering thread looper.
*/
public abstract Looper getTetheringLooper();
public abstract Looper makeTetheringLooper();
/**
* Get Context of TetheringService.
@ -166,26 +166,26 @@ public abstract class TetheringDependencies {
}
/**
* Get a reference to PrivateAddressCoordinator to be used by Tethering.
* Make PrivateAddressCoordinator to be used by Tethering.
*/
public PrivateAddressCoordinator getPrivateAddressCoordinator(Context ctx,
public PrivateAddressCoordinator makePrivateAddressCoordinator(Context ctx,
TetheringConfiguration cfg) {
return new PrivateAddressCoordinator(ctx, cfg);
}
/**
* Get BluetoothPanShim object to enable/disable bluetooth tethering.
* Make BluetoothPanShim object to enable/disable bluetooth tethering.
*
* TODO: use BluetoothPan directly when mainline module is built with API 32.
*/
public BluetoothPanShim getBluetoothPanShim(BluetoothPan pan) {
public BluetoothPanShim makeBluetoothPanShim(BluetoothPan pan) {
return BluetoothPanShimImpl.newInstance(pan);
}
/**
* Get a reference to the TetheringMetrics to be used by tethering.
* Make the TetheringMetrics to be used by tethering.
*/
public TetheringMetrics getTetheringMetrics() {
public TetheringMetrics makeTetheringMetrics() {
return new TetheringMetrics();
}
@ -193,7 +193,7 @@ public abstract class TetheringDependencies {
* Returns the implementation of WearableConnectionManager.
*/
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
public WearableConnectionManager getWearableConnectionManager(Context ctx) {
public WearableConnectionManager makeWearableConnectionManager(Context ctx) {
return new WearableConnectionManager(ctx);
}
}

View file

@ -322,7 +322,7 @@ public class TetheringService extends Service {
public TetheringDependencies makeTetheringDependencies() {
return new TetheringDependencies() {
@Override
public Looper getTetheringLooper() {
public Looper makeTetheringLooper() {
final HandlerThread tetherThread = new HandlerThread("android.tethering");
tetherThread.start();
return tetherThread.getLooper();
@ -334,7 +334,7 @@ public class TetheringService extends Service {
}
@Override
public IpServer.Dependencies getIpServerDependencies() {
public IpServer.Dependencies makeIpServerDependencies() {
return new IpServer.Dependencies() {
@Override
public void makeDhcpServer(String ifName, DhcpServingParamsParcel params,

View file

@ -436,51 +436,51 @@ public class TetheringTest {
ArrayList<IpServer> mAllDownstreams;
@Override
public BpfCoordinator getBpfCoordinator(
public BpfCoordinator makeBpfCoordinator(
BpfCoordinator.Dependencies deps) {
return mBpfCoordinator;
}
@Override
public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) {
public OffloadHardwareInterface makeOffloadHardwareInterface(Handler h, SharedLog log) {
return mOffloadHardwareInterface;
}
@Override
public OffloadController getOffloadController(Handler h, SharedLog log,
public OffloadController makeOffloadController(Handler h, SharedLog log,
OffloadController.Dependencies deps) {
mOffloadCtrl = spy(super.getOffloadController(h, log, deps));
mOffloadCtrl = spy(super.makeOffloadController(h, log, deps));
// Return real object here instead of mock because
// testReportFailCallbackIfOffloadNotSupported depend on real OffloadController object.
return mOffloadCtrl;
}
@Override
public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, Handler h,
public UpstreamNetworkMonitor makeUpstreamNetworkMonitor(Context ctx, Handler h,
SharedLog log, UpstreamNetworkMonitor.EventListener listener) {
// Use a real object instead of a mock so that some tests can use a real UNM and some
// can use a mock.
mEventListener = listener;
mUpstreamNetworkMonitor = spy(super.getUpstreamNetworkMonitor(ctx, h, log, listener));
mUpstreamNetworkMonitor = spy(super.makeUpstreamNetworkMonitor(ctx, h, log, listener));
return mUpstreamNetworkMonitor;
}
@Override
public IPv6TetheringCoordinator getIPv6TetheringCoordinator(
public IPv6TetheringCoordinator makeIPv6TetheringCoordinator(
ArrayList<IpServer> notifyList, SharedLog log) {
mAllDownstreams = notifyList;
return mIPv6TetheringCoordinator;
}
@Override
public IpServer.Dependencies getIpServerDependencies() {
public IpServer.Dependencies makeIpServerDependencies() {
return mIpServerDependencies;
}
@Override
public EntitlementManager getEntitlementManager(Context ctx, Handler h, SharedLog log,
public EntitlementManager makeEntitlementManager(Context ctx, Handler h, SharedLog log,
Runnable callback) {
mEntitleMgr = spy(super.getEntitlementManager(ctx, h, log, callback));
mEntitleMgr = spy(super.makeEntitlementManager(ctx, h, log, callback));
return mEntitleMgr;
}
@ -503,7 +503,7 @@ public class TetheringTest {
}
@Override
public Looper getTetheringLooper() {
public Looper makeTetheringLooper() {
return mLooper.getLooper();
}
@ -518,7 +518,7 @@ public class TetheringTest {
}
@Override
public TetheringNotificationUpdater getNotificationUpdater(Context ctx, Looper looper) {
public TetheringNotificationUpdater makeNotificationUpdater(Context ctx, Looper looper) {
return mNotificationUpdater;
}
@ -528,19 +528,19 @@ public class TetheringTest {
}
@Override
public TetheringMetrics getTetheringMetrics() {
public TetheringMetrics makeTetheringMetrics() {
return mTetheringMetrics;
}
@Override
public PrivateAddressCoordinator getPrivateAddressCoordinator(Context ctx,
public PrivateAddressCoordinator makePrivateAddressCoordinator(Context ctx,
TetheringConfiguration cfg) {
mPrivateAddressCoordinator = super.getPrivateAddressCoordinator(ctx, cfg);
mPrivateAddressCoordinator = super.makePrivateAddressCoordinator(ctx, cfg);
return mPrivateAddressCoordinator;
}
@Override
public BluetoothPanShim getBluetoothPanShim(BluetoothPan pan) {
public BluetoothPanShim makeBluetoothPanShim(BluetoothPan pan) {
try {
when(mBluetoothPanShim.requestTetheredInterface(
any(), any())).thenReturn(mTetheredInterfaceRequestShim);